mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-05-09 07:12:37 +02:00
Catch JSON parse errors in prompt processor
This commit is contained in:
parent
20f983eec9
commit
ba056b93ed
12 changed files with 151 additions and 145 deletions
|
|
@ -91,13 +91,14 @@ class Processor(ConsumerProducer):
|
|||
|
||||
prompt = to_definitions(v.chunk)
|
||||
|
||||
print(prompt)
|
||||
|
||||
ans = self.llm.request(prompt)
|
||||
|
||||
print(ans)
|
||||
|
||||
defs = json.loads(ans)
|
||||
# Silently ignore JSON parse error
|
||||
try:
|
||||
defs = json.loads(ans)
|
||||
except:
|
||||
print("JSON parse error, ignored", flush=True)
|
||||
defs = []
|
||||
|
||||
output = []
|
||||
|
||||
|
|
@ -114,7 +115,7 @@ class Processor(ConsumerProducer):
|
|||
)
|
||||
|
||||
except:
|
||||
pass
|
||||
print("definition fields missing, ignored", flush=True)
|
||||
|
||||
print("Send response...", flush=True)
|
||||
r = PromptResponse(definitions=output)
|
||||
|
|
@ -128,7 +129,12 @@ class Processor(ConsumerProducer):
|
|||
|
||||
ans = self.llm.request(prompt)
|
||||
|
||||
defs = json.loads(ans)
|
||||
# Silently ignore JSON parse error
|
||||
try:
|
||||
defs = json.loads(ans)
|
||||
except:
|
||||
print("JSON parse error, ignored", flush=True)
|
||||
defs = []
|
||||
|
||||
output = []
|
||||
|
||||
|
|
@ -145,7 +151,7 @@ class Processor(ConsumerProducer):
|
|||
)
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print("relationship fields missing, ignored", flush=True)
|
||||
|
||||
print("Send response...", flush=True)
|
||||
r = PromptResponse(relationships=output)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue