mirror of
https://github.com/VinciGit00/Scrapegraph-ai.git
synced 2026-07-18 21:00:31 +08:00
fix: resolved outparser issue
This commit is contained in:
parent
65d39bbaf0
commit
e8cabfd1ae
6
.ipynb_checkpoints/Untitled-checkpoint.ipynb
Normal file
6
.ipynb_checkpoints/Untitled-checkpoint.ipynb
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cells": [],
|
||||||
|
"metadata": {},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
@ -122,11 +122,11 @@ class GenerateAnswerNode(BaseNode):
|
|||||||
partial_variables={"context": doc, "format_instructions": format_instructions}
|
partial_variables={"context": doc, "format_instructions": format_instructions}
|
||||||
)
|
)
|
||||||
chain = prompt | self.llm_model
|
chain = prompt | self.llm_model
|
||||||
raw_response = str((prompt | self.llm_model).invoke({"question": user_prompt}))
|
raw_response = chain.invoke({"question": user_prompt})
|
||||||
|
|
||||||
if output_parser:
|
if output_parser:
|
||||||
try:
|
try:
|
||||||
answer = output_parser.parse(raw_response)
|
answer = output_parser.parse(raw_response.content)
|
||||||
except JSONDecodeError:
|
except JSONDecodeError:
|
||||||
lines = raw_response.split('\n')
|
lines = raw_response.split('\n')
|
||||||
if lines[0].strip().startswith('```'):
|
if lines[0].strip().startswith('```'):
|
||||||
@ -136,7 +136,7 @@ class GenerateAnswerNode(BaseNode):
|
|||||||
cleaned_response = '\n'.join(lines)
|
cleaned_response = '\n'.join(lines)
|
||||||
answer = output_parser.parse(cleaned_response)
|
answer = output_parser.parse(cleaned_response)
|
||||||
else:
|
else:
|
||||||
answer = raw_response
|
answer = raw_response.content
|
||||||
|
|
||||||
state.update({self.output[0]: answer})
|
state.update({self.output[0]: answer})
|
||||||
return state
|
return state
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user