Agente de web search construido e implementado(Tavily ejemplo de .env en readme)

This commit is contained in:
Sebastian
2025-11-08 10:18:32 +00:00
parent 70f2a42502
commit a23f45ca6d
9 changed files with 358 additions and 6 deletions

View File

@@ -6,7 +6,7 @@ from pydantic_ai.ui.vercel_ai import VercelAIAdapter
from starlette.requests import Request
from starlette.responses import Response
from app.agents import form_auditor
from app.agents import form_auditor, web_search
from app.core.config import settings
provider = AzureProvider(
@@ -361,6 +361,14 @@ async def build_audit_report():
return result.model_dump()
@agent.tool_plain
async def search_web_information(query: str, max_results: int = 5):
"""Search the web for up-to-date information using Tavily. Use this when you need current information, news, research, or facts not in your knowledge base."""
result = await web_search.search_web(query=query, max_results=max_results)
return result.model_dump()
@router.post("/chat")
async def chat(request: Request) -> Response:
return await VercelAIAdapter.dispatch_request(request, agent=agent)