- Add web_search tool with Jina Search/Reader/Rerank - Flash mode: top 3, 8s timeout, no Reader/Rerank - Pro mode: top 10, 20s timeout, concurrent Reader + Rerank top 5 - Add Redis async cache (TTL=300s) for search results - Register "search" in ALL_TOOLS mapping Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
24 lines
786 B
Python
24 lines
786 B
Python
"""LangChain tool definitions for the ReAct agent."""
|
|
|
|
from app.tools.kb import kb_search
|
|
from app.tools.tickets import ticket_list, ticket_detail
|
|
from app.tools.search import web_search
|
|
|
|
# Mapping from frontend tool names to LangChain tool objects.
|
|
# The frontend sends a list of tool *keys* (e.g. ["knowledge", "tickets"]);
|
|
# the backend resolves them here and binds them to the ReAct agent.
|
|
ALL_TOOLS: dict[str, list] = {
|
|
"knowledge": [kb_search],
|
|
"tickets": [ticket_list, ticket_detail],
|
|
"search": [web_search],
|
|
}
|
|
|
|
|
|
def resolve_tools(tool_keys: list[str]) -> list:
|
|
"""Return a flat list of LangChain tools for the given frontend keys."""
|
|
tools = []
|
|
for key in tool_keys:
|
|
if key in ALL_TOOLS:
|
|
tools.extend(ALL_TOOLS[key])
|
|
return tools
|