092_agent_api / state.py
anhkhoiphan's picture
Thêm tính năng custom prompt
b784540
from __future__ import annotations
from typing import Annotated, Literal
from langchain_core.messages import BaseMessage
from langgraph.graph.message import add_messages
from typing_extensions import TypedDict
MAX_ITERS = 1
QueryType = Literal["respond", "summary"]
class AgentState(TypedDict):
"""
Trạng thái duy nhất chạy xuyên suốt graph.
conversation_id : ID cuộc hội thoại DM (dùng để tool truy vấn tin nhắn)
sender_id : ID người dùng, ví dụ "user-uuid" hoặc "@NguyenVanA"
time : Thời điểm gửi (ISO-8601)
raw_query : Nội dung tin nhắn gốc
query_type : Nhãn phân loại từ RouterNode
messages : HumanMessage / AIMessage / ToolMessage (tự động append)
iters : Số lần Orchestrator đã gọi tool
max_iters : Giới hạn vòng lặp tool
final_answer : Câu trả lời cuối cùng
"""
conversation_id: str
sender_id: str
time: str
raw_query: str
query_type: QueryType | None
messages: Annotated[list[BaseMessage], add_messages]
iters: int
max_iters: int
final_answer: str | None
custom_prompt: str | None