ERP-system / erp_core /state_definer.py
sarwarshafee8709809365's picture
deployment-1
c8e458d
raw
history blame contribute delete
839 Bytes
from typing import Annotated, Literal, Optional
from typing_extensions import TypedDict
from langgraph.graph.message import AnyMessage, add_messages
def update_dialog_stack(left: list[str], right: Optional[str]) -> list[str]:
"""Push or pop the state."""
if right is None:
return left
if right == "pop":
return left[:-1]
return left + [right]
class State(TypedDict):
messages: Annotated[list[AnyMessage], add_messages]
user_info: str
dialog_state: Annotated[
list[
Literal[
"assistant",
"Human_Resource",
"Financial_Management",
"Supply_Chain_Management",
"Project_Management",
"Customer_Relationship_Management",
]
],
update_dialog_stack,
]