37 lines
774 B
Python
37 lines
774 B
Python
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] |