Skip to content

Commit e8cabfd

Browse files
fix: resolved outparser issue
1 parent 65d39bb commit e8cabfd

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"cells": [],
3+
"metadata": {},
4+
"nbformat": 4,
5+
"nbformat_minor": 5
6+
}

scrapegraphai/nodes/generate_answer_node.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ def execute(self, state: dict) -> dict:
122122
partial_variables={"context": doc, "format_instructions": format_instructions}
123123
)
124124
chain = prompt | self.llm_model
125-
raw_response = str((prompt | self.llm_model).invoke({"question": user_prompt}))
125+
raw_response = chain.invoke({"question": user_prompt})
126126

127127
if output_parser:
128128
try:
129-
answer = output_parser.parse(raw_response)
129+
answer = output_parser.parse(raw_response.content)
130130
except JSONDecodeError:
131131
lines = raw_response.split('\n')
132132
if lines[0].strip().startswith('```'):
@@ -136,7 +136,7 @@ def execute(self, state: dict) -> dict:
136136
cleaned_response = '\n'.join(lines)
137137
answer = output_parser.parse(cleaned_response)
138138
else:
139-
answer = raw_response
139+
answer = raw_response.content
140140

141141
state.update({self.output[0]: answer})
142142
return state

0 commit comments

Comments
 (0)