Human in the loop

Implémentation fonctionelle de l'HITL !
This commit is contained in:
2026-02-06 22:07:47 +01:00
parent 523cea84fe
commit a9ff56c122
6 changed files with 71 additions and 7 deletions

View File

@@ -4,9 +4,11 @@ from tavily import TavilyClient
from pathlib import Path
from typing import List, Dict, Annotated
import sys
from .StateElements.TodoElement import TodoElement
from langgraph.types import interrupt
from .StateElements.TodoElement import TodoElement
from .VectorDatabase import VectorDatabase
from .InterruptPayload import InterruptPayload
@tool
def internet_search(query: str)->dict:
@@ -18,7 +20,16 @@ def internet_search(query: str)->dict:
Returns:
dict: Retour de la recherche
"""
return TavilyClient().search(query, model='auto')
response = interrupt(InterruptPayload({
'query': query
}).toJSON())
resp = InterruptPayload.fromJSON(response) # Je reforme mon objet depuis la string json
if resp.isAccepted():
return TavilyClient().search(resp.get("query"), model='auto')
else:
return {'error': "Utilisation de cet outil refusée par l'utilisateur"}
@tool