mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-06-25 06:38:06 +02:00
* Starting to spawn base package * More package hacking * Bedrock and VertexAI * Parquet split * Updated templates * Utils
65 lines
1.4 KiB
Python
65 lines
1.4 KiB
Python
|
|
from pulsar.schema import Record, Bytes, String, Boolean, Array, Map, Integer
|
|
|
|
from . topic import topic
|
|
from . types import Error, RowSchema
|
|
|
|
############################################################################
|
|
|
|
# Prompt services, abstract the prompt generation
|
|
|
|
class Definition(Record):
|
|
name = String()
|
|
definition = String()
|
|
|
|
class Topic(Record):
|
|
name = String()
|
|
definition = String()
|
|
|
|
class Relationship(Record):
|
|
s = String()
|
|
p = String()
|
|
o = String()
|
|
o_entity = Boolean()
|
|
|
|
class Fact(Record):
|
|
s = String()
|
|
p = String()
|
|
o = String()
|
|
|
|
# extract-definitions:
|
|
# chunk -> definitions
|
|
# extract-relationships:
|
|
# chunk -> relationships
|
|
# kg-prompt:
|
|
# query, triples -> answer
|
|
# document-prompt:
|
|
# query, documents -> answer
|
|
# extract-rows
|
|
# schema, chunk -> rows
|
|
|
|
class PromptRequest(Record):
|
|
kind = String()
|
|
chunk = String()
|
|
query = String()
|
|
kg = Array(Fact())
|
|
documents = Array(Bytes())
|
|
row_schema = RowSchema()
|
|
|
|
class PromptResponse(Record):
|
|
error = Error()
|
|
answer = String()
|
|
definitions = Array(Definition())
|
|
topics = Array(Topic())
|
|
relationships = Array(Relationship())
|
|
rows = Array(Map(String()))
|
|
|
|
prompt_request_queue = topic(
|
|
'prompt', kind='non-persistent', namespace='request'
|
|
)
|
|
prompt_response_queue = topic(
|
|
'prompt-response', kind='non-persistent', namespace='response'
|
|
)
|
|
|
|
############################################################################
|
|
|