TodoElement est maintenant sérializable
Requis pour le state
This commit is contained in:
@@ -76,6 +76,7 @@ def editTodo(index:int, todoState:int, state: Annotated[dict, InjectedState], to
|
||||
# Erreur, l'index est trop grand
|
||||
return Command(update={"messages": [ToolMessage(content="Index en dehors de la liste, echec!", tool_call_id=tool_call_id)]})
|
||||
|
||||
state["todo"] = [TodoElement.fromJSON(e) for e in state["todo"]] # Convertion vers de vraies instances
|
||||
state["todo"][index].state = todoState # Modification de l'état de cette tâche
|
||||
|
||||
# Toutes les tâches complétées ?
|
||||
@@ -88,7 +89,7 @@ def editTodo(index:int, todoState:int, state: Annotated[dict, InjectedState], to
|
||||
if not found: state["todo"] = [] # Toutes les tâches terminées, je peux clear la TODO list du state
|
||||
return Command(update={
|
||||
"messages": [ToolMessage(content="Réussite!", tool_call_id=tool_call_id)],
|
||||
"todo": [x for x in state["todo"]] # Update du state, # medium.com/@o39joey/a-comprehensive-guide-to-langgraph-managing-agent-state-with-tools-ae932206c7d7
|
||||
"todo": [x.toJSON() for x in state["todo"]] # Update du state, # medium.com/@o39joey/a-comprehensive-guide-to-langgraph-managing-agent-state-with-tools-ae932206c7d7
|
||||
})
|
||||
|
||||
@tool
|
||||
@@ -102,10 +103,11 @@ def addTodo(name:str, description:str, state: Annotated[dict, InjectedState], to
|
||||
"""
|
||||
if "todo" not in state.keys(): state["todo"] = []
|
||||
|
||||
state["todo"] = [TodoElement.fromJSON(e) for e in state["todo"]] # Convertion vers de vraies instances
|
||||
state["todo"].append(TodoElement(name, description))
|
||||
return Command(update={
|
||||
"messages": [ToolMessage(content="Réussite!", tool_call_id=tool_call_id)],
|
||||
"todo": [x for x in state["todo"]] # Update du state, # medium.com/@o39joey/a-comprehensive-guide-to-langgraph-managing-agent-state-with-tools-ae932206c7d7
|
||||
"todo": [x.toJSON() for x in state["todo"]] # Update du state, # medium.com/@o39joey/a-comprehensive-guide-to-langgraph-managing-agent-state-with-tools-ae932206c7d7
|
||||
})
|
||||
|
||||
@tool
|
||||
|
||||
Reference in New Issue
Block a user