-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtool_selector.py
More file actions
25 lines (20 loc) · 839 Bytes
/
tool_selector.py
File metadata and controls
25 lines (20 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from tools import calculator_tool
from pdf_qa_tool import search_pdf
def select_tool(query, texts, embeddings):
query_lower = query.lower()
# Detect calculator intent
if any(op in query_lower for op in ["+", "-", "*", "/", "calculate", "sum", "total", "difference", "product", "multiply", "divide"]):
return "calculator"
# Detect PDF-related intent
elif any(kw in query_lower for kw in ["pdf", "document", "section", "content", "in the pdf", "in the document", "what does the pdf say", "mention"]):
return "pdf"
# Default to LLM
else:
return "llm"
def run_tool(tool_name, query, texts, embeddings):
if tool_name == "calculator":
return calculator_tool(query)
elif tool_name == "pdf":
return search_pdf(query, texts, embeddings)
else:
return None