mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-17 09:11:03 +02:00
Definitions is working again
This commit is contained in:
parent
8f1a44c06e
commit
5e86a3c3ae
4 changed files with 38 additions and 19 deletions
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
import _pulsar
|
||||
import json
|
||||
import dataclasses
|
||||
|
||||
from .. schema import PromptRequest, PromptResponse
|
||||
from .. schema import prompt_request_queue
|
||||
|
|
@ -13,6 +14,11 @@ WARN=_pulsar.LoggerLevel.Warn
|
|||
INFO=_pulsar.LoggerLevel.Info
|
||||
DEBUG=_pulsar.LoggerLevel.Debug
|
||||
|
||||
@dataclasses.dataclass
|
||||
class Definition:
|
||||
name: str
|
||||
definition: str
|
||||
|
||||
class PromptClient(BaseClient):
|
||||
|
||||
def __init__(
|
||||
|
|
@ -56,20 +62,25 @@ class PromptClient(BaseClient):
|
|||
|
||||
def request_definitions(self, chunk, timeout=300):
|
||||
|
||||
return self.request(
|
||||
defs = self.request(
|
||||
id="extract-definitions",
|
||||
terms={
|
||||
"chunk": chunk
|
||||
"text": chunk
|
||||
},
|
||||
timeout=timeout
|
||||
)
|
||||
|
||||
return [
|
||||
Definition(name=d["entity"], definition=d["definition"])
|
||||
for d in defs
|
||||
]
|
||||
|
||||
def request_relationships(self, chunk, timeout=300):
|
||||
|
||||
return self.call(
|
||||
id="extract-relationships",
|
||||
terms={
|
||||
"chunk": chunk
|
||||
"text": chunk
|
||||
},
|
||||
timeout=timeout
|
||||
)
|
||||
|
|
@ -79,7 +90,7 @@ class PromptClient(BaseClient):
|
|||
return self.call(
|
||||
id="extract-topics",
|
||||
terms={
|
||||
"chunk": chunk
|
||||
"text": chunk
|
||||
},
|
||||
timeout=timeout
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue