mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-17 09:11:03 +02:00
Prompt manager integrated and working with 6 tests
This commit is contained in:
parent
51aef6c730
commit
3da63a38ce
13 changed files with 472 additions and 63 deletions
|
|
@ -1,7 +1,8 @@
|
|||
|
||||
import _pulsar
|
||||
import json
|
||||
|
||||
from .. schema import PromptRequest, PromptResponse, Fact, RowSchema, Field
|
||||
from .. schema import PromptRequest, PromptResponse
|
||||
from .. schema import prompt_request_queue
|
||||
from .. schema import prompt_response_queue
|
||||
from . base import BaseClient
|
||||
|
|
@ -38,12 +39,20 @@ class PromptClient(BaseClient):
|
|||
output_schema=PromptResponse,
|
||||
)
|
||||
|
||||
def request_definitions(self, chunk, timeout=300):
|
||||
def request(self, id, terms, timeout=300):
|
||||
|
||||
return self.call(
|
||||
kind="extract-definitions", chunk=chunk,
|
||||
resp = self.call(
|
||||
id=id,
|
||||
terms={
|
||||
k: json.dumps(v)
|
||||
for k, v in terms.items()
|
||||
},
|
||||
timeout=timeout
|
||||
).definitions
|
||||
)
|
||||
|
||||
if resp.text: return resp.text
|
||||
|
||||
return json.loads(resp.object)
|
||||
|
||||
def request_topics(self, chunk, timeout=300):
|
||||
|
||||
|
|
|
|||
|
|
@ -39,20 +39,21 @@ class Fact(Record):
|
|||
# schema, chunk -> rows
|
||||
|
||||
class PromptRequest(Record):
|
||||
kind = String()
|
||||
chunk = String()
|
||||
query = String()
|
||||
kg = Array(Fact())
|
||||
documents = Array(Bytes())
|
||||
row_schema = RowSchema()
|
||||
id = String()
|
||||
|
||||
# JSON encoded values
|
||||
terms = Map(String())
|
||||
|
||||
class PromptResponse(Record):
|
||||
|
||||
# Error case
|
||||
error = Error()
|
||||
answer = String()
|
||||
definitions = Array(Definition())
|
||||
topics = Array(Topic())
|
||||
relationships = Array(Relationship())
|
||||
rows = Array(Map(String()))
|
||||
|
||||
# Just plain text
|
||||
text = String()
|
||||
|
||||
# JSON encoded
|
||||
object = String()
|
||||
|
||||
prompt_request_queue = topic(
|
||||
'prompt', kind='non-persistent', namespace='request'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue