Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,8 @@ from functools import partial
|
|
| 7 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 8 |
from langchain.agents import load_tools
|
| 9 |
from langgraph.graph import StateGraph, START, END
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# Importa as funções e a classe de estado do outro arquivo
|
| 12 |
from agente_functions import (
|
|
@@ -33,6 +35,15 @@ if not os.environ.get("GOOGLE_API_KEY") or not os.environ.get("TAVILY_API_KEY"):
|
|
| 33 |
print("Por favor, defina as variáveis de ambiente GOOGLE_API_KEY e TAVILY_API_KEY.")
|
| 34 |
exit()
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
# --- 2. Inicialização do Modelo e Ferramentas ---
|
| 37 |
llm = ChatGoogleGenerativeAI(model="gemini-1.5-flash")
|
| 38 |
web_tools = [busca_web]
|
|
|
|
| 7 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 8 |
from langchain.agents import load_tools
|
| 9 |
from langgraph.graph import StateGraph, START, END
|
| 10 |
+
from langchain_community.tools.tavily_search import TavilySearchResults
|
| 11 |
+
from langchain_core.tools import tool
|
| 12 |
|
| 13 |
# Importa as funções e a classe de estado do outro arquivo
|
| 14 |
from agente_functions import (
|
|
|
|
| 35 |
print("Por favor, defina as variáveis de ambiente GOOGLE_API_KEY e TAVILY_API_KEY.")
|
| 36 |
exit()
|
| 37 |
|
| 38 |
+
@tool
|
| 39 |
+
def busca_web(query: str) -> list:
|
| 40 |
+
"""
|
| 41 |
+
Busca na web por um termo específico
|
| 42 |
+
"""
|
| 43 |
+
tavily_search = TavilySearchResults(max_results=2, search_depth='advanced', max_tokens=1000)
|
| 44 |
+
resultado_busca = tavily_search.invoke(query)
|
| 45 |
+
return resultado_busca
|
| 46 |
+
|
| 47 |
# --- 2. Inicialização do Modelo e Ferramentas ---
|
| 48 |
llm = ChatGoogleGenerativeAI(model="gemini-1.5-flash")
|
| 49 |
web_tools = [busca_web]
|