fix: implement real-time streaming for responses

- Added streaming service support to the Q&A agent for real-time token streaming.
- Updated `answer_question` method to stream responses token-by-token to the frontend.
- Modified `handle_qna_workflow` to handle both custom and values streaming modes.
- Enhanced state management to include streaming service for improved user experience.
This commit is contained in:
DESKTOP-RTLN3BA\$punk 2025-12-05 00:14:36 -08:00
parent 264532b3cf
commit c97887a63d
5 changed files with 64 additions and 41 deletions

View file

@ -62,7 +62,7 @@ async def _process_extension_document(
individual_document_dict, search_space_id: int, user_id: str
):
"""Process extension document with new session."""
from pydantic import BaseModel
from pydantic import BaseModel, ConfigDict, Field
# Reconstruct the document object from dict
# You'll need to define the proper model for this
@ -75,8 +75,9 @@ async def _process_extension_document(
VisitedWebPageVisitDurationInMilliseconds: str
class IndividualDocument(BaseModel):
model_config = ConfigDict(populate_by_name=True)
metadata: DocumentMetadata
pageContent: str
page_content: str = Field(alias="pageContent")
individual_document = IndividualDocument(**individual_document_dict)