fix
This commit is contained in:
@@ -60,5 +60,12 @@ async def llm_call(
|
||||
try:
|
||||
return response.parse()
|
||||
except Exception:
|
||||
# Fallback: sanitize control characters and parse manually
|
||||
return response_model.model_validate_json(_sanitize_json(response.content))
|
||||
# Fallback: extract content and parse manually
|
||||
# response.content could be a string or a list of Text objects
|
||||
content = response.content
|
||||
if isinstance(content, list):
|
||||
# Extract text from list of Text objects
|
||||
content = "".join([chunk.text if hasattr(chunk, 'text') else str(chunk) for chunk in content])
|
||||
elif not isinstance(content, str):
|
||||
content = str(content)
|
||||
return response_model.model_validate_json(_sanitize_json(content))
|
||||
|
||||
Reference in New Issue
Block a user