File size: 1,274 Bytes
cc342e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2ac6bb5
 
 
 
 
 
 
 
 
cc342e5
2ac6bb5
 
 
 
 
 
 
 
 
b784540
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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