feat(chat): Implement real-time SSE streaming with reasoning steps and improved UI indicators.
This commit is contained in:
@@ -52,6 +52,11 @@ def decode_access_token(token: str) -> Optional[dict]:
|
||||
|
||||
def convert_to_json_compatible(obj: Any) -> Any:
|
||||
"""Recursively convert LangChain objects, Pydantic models, and others to JSON compatible formats."""
|
||||
# Handle known non-serializable types first to avoid recursion
|
||||
type_name = type(obj).__name__
|
||||
if type_name == "Figure" or type_name == "DataFrame":
|
||||
return f"<{type_name} object>"
|
||||
|
||||
if isinstance(obj, list):
|
||||
return [convert_to_json_compatible(item) for item in obj]
|
||||
elif isinstance(obj, dict):
|
||||
@@ -91,4 +96,11 @@ def convert_to_json_compatible(obj: Any) -> Any:
|
||||
return str(obj.content)
|
||||
elif isinstance(obj, (datetime, timezone)):
|
||||
return obj.isoformat()
|
||||
return obj
|
||||
|
||||
# Final fallback for any other types that might not be JSON serializable
|
||||
import json
|
||||
try:
|
||||
json.dumps(obj)
|
||||
return obj
|
||||
except (TypeError, OverflowError):
|
||||
return str(obj)
|
||||
Reference in New Issue
Block a user