Première version agent
Dérivé TP3
This commit is contained in:
37
AgentReact/utils/tools.py
Normal file
37
AgentReact/utils/tools.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from langchain.tools import tool
|
||||
from tavily import TavilyClient
|
||||
from typing import List
|
||||
|
||||
@tool
|
||||
def internet_search(query: str)->dict:
|
||||
"""
|
||||
Rechercher une information sur internet
|
||||
|
||||
Args:
|
||||
query (str): Terme recherché
|
||||
Returns:
|
||||
dict: Retour de la recherche
|
||||
"""
|
||||
return TavilyClient().search(query, model='auto')
|
||||
|
||||
|
||||
@tool
|
||||
def write_file(content: str) -> str:
|
||||
"""
|
||||
Écrire les données dans un fichier
|
||||
|
||||
Args:
|
||||
content (str): Contenu du fichier à écrire
|
||||
|
||||
Returns:
|
||||
str: Résultat de l'écriture
|
||||
"""
|
||||
print("==ECRITURE FICHIER==")
|
||||
print(content)
|
||||
return "Fichier écrit"
|
||||
|
||||
def getTools()->List['Tools']:
|
||||
"""
|
||||
Récupérer la liste des tools
|
||||
"""
|
||||
return [internet_search, write_file]
|
||||
Reference in New Issue
Block a user