2025-07-03 14:09:36 -07:00
|
|
|
"""Define the state structures for the agent."""
|
2025-04-19 23:25:06 -07:00
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from dataclasses import dataclass, field
|
2025-07-24 14:43:48 -07:00
|
|
|
from typing import Any
|
|
|
|
|
|
2025-04-20 19:19:35 -07:00
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
2025-07-24 14:43:48 -07:00
|
|
|
|
2025-07-06 17:51:24 -07:00
|
|
|
from app.services.streaming_service import StreamingService
|
2025-04-19 23:25:06 -07:00
|
|
|
|
2025-07-24 14:43:48 -07:00
|
|
|
|
2025-04-19 23:25:06 -07:00
|
|
|
@dataclass
|
|
|
|
|
class State:
|
|
|
|
|
"""Defines the dynamic state for the agent during execution.
|
|
|
|
|
|
|
|
|
|
This state tracks the database session and the outputs generated by the agent's nodes.
|
|
|
|
|
See: https://langchain-ai.github.io/langgraph/concepts/low_level/#state
|
|
|
|
|
for more information.
|
|
|
|
|
"""
|
2025-07-24 14:43:48 -07:00
|
|
|
|
2025-04-19 23:25:06 -07:00
|
|
|
# Runtime context (not part of actual graph state)
|
|
|
|
|
db_session: AsyncSession
|
2025-07-24 14:43:48 -07:00
|
|
|
|
2025-04-20 19:19:35 -07:00
|
|
|
# Streaming service
|
|
|
|
|
streaming_service: StreamingService
|
2025-07-24 14:43:48 -07:00
|
|
|
|
|
|
|
|
chat_history: list[Any] | None = field(default_factory=list)
|
|
|
|
|
|
|
|
|
|
reformulated_query: str | None = field(default=None)
|
2025-04-19 23:25:06 -07:00
|
|
|
# Using field to explicitly mark as part of state
|
2025-07-24 14:43:48 -07:00
|
|
|
answer_outline: Any | None = field(default=None)
|
|
|
|
|
further_questions: Any | None = field(default=None)
|
|
|
|
|
|
2025-07-10 14:37:31 -07:00
|
|
|
# Temporary field to hold reranked documents from sub-agents for further question generation
|
2025-07-24 14:43:48 -07:00
|
|
|
reranked_documents: list[Any] | None = field(default=None)
|
|
|
|
|
|
2025-04-19 23:25:06 -07:00
|
|
|
# OUTPUT: Populated by agent nodes
|
|
|
|
|
# Using field to explicitly mark as part of state
|
2025-07-24 14:43:48 -07:00
|
|
|
final_written_report: str | None = field(default=None)
|