Spaces:
Sleeping
Sleeping
ernani
commited on
Commit
·
57fe70d
1
Parent(s):
b13a99c
New tests - search tool parsing
Browse files- manage_agents.py +1 -1
- tools.py +0 -6
manage_agents.py
CHANGED
|
@@ -1406,7 +1406,7 @@ class MainAgent:
|
|
| 1406 |
response = self.llm.invoke(answer_prompt)
|
| 1407 |
answer = response.content if hasattr(response, 'content') else str(response)
|
| 1408 |
# Remove any prefix like "Final Answer:" or "Answer:" and strip whitespace
|
| 1409 |
-
answer = re.sub(r'^(Final Answer:|Answer:)', '', answer, flags=re.IGNORECASE).strip()
|
| 1410 |
state.messages.append(AIMessage(content=answer))
|
| 1411 |
return state
|
| 1412 |
builder.add_node("synthesize_answer", _synthesize_answer)
|
|
|
|
| 1406 |
response = self.llm.invoke(answer_prompt)
|
| 1407 |
answer = response.content if hasattr(response, 'content') else str(response)
|
| 1408 |
# Remove any prefix like "Final Answer:" or "Answer:" and strip whitespace
|
| 1409 |
+
answer = re.sub(r'^(Final Answer:|Answer:|NASA award number:)', '', answer, flags=re.IGNORECASE).strip()
|
| 1410 |
state.messages.append(AIMessage(content=answer))
|
| 1411 |
return state
|
| 1412 |
builder.add_node("synthesize_answer", _synthesize_answer)
|
tools.py
CHANGED
|
@@ -95,7 +95,6 @@ class WikipediaTool(BaseTool):
|
|
| 95 |
wikipedia_tool: WikipediaQueryRun = Field(default_factory=lambda: WikipediaQueryRun(
|
| 96 |
api_wrapper=WikipediaAPIWrapper(top_k_results=5)
|
| 97 |
))
|
| 98 |
-
print("WikipediaTool initialized")
|
| 99 |
def _run(self, question: str) -> str:
|
| 100 |
"""Search Wikipedia and return the result as a string"""
|
| 101 |
try:
|
|
@@ -611,8 +610,6 @@ class ExcelTool(BaseContentTool):
|
|
| 611 |
"""Convert DataFrame to a readable text format optimized for LLM analysis."""
|
| 612 |
# Use to_string for a clean, tabular format
|
| 613 |
table_str = df.to_string(index=False)
|
| 614 |
-
print("table_str")
|
| 615 |
-
print(table_str)
|
| 616 |
return f"Table:\n{table_str}"
|
| 617 |
|
| 618 |
def _run(self, task_id: str, question: str = "") -> List[Document]:
|
|
@@ -694,7 +691,6 @@ class WebSearchTool(BaseTool):
|
|
| 694 |
#search_tool: DuckDuckGoSearchResults = Field(default_factory=DuckDuckGoSearchResults)
|
| 695 |
search_tool: TavilySearchResults = Field(default_factory=TavilySearchResults)
|
| 696 |
|
| 697 |
-
print("WebSearchTool initialized")
|
| 698 |
def _extract_links_from_results(self, search_result) -> list:
|
| 699 |
"""Extract links from search results, robust to type."""
|
| 700 |
links = []
|
|
@@ -783,8 +779,6 @@ class WebSearchTool(BaseTool):
|
|
| 783 |
def _run(self, query: str) -> str:
|
| 784 |
try:
|
| 785 |
search_result = self.search_tool.run(query, max_results=5)
|
| 786 |
-
print("query")
|
| 787 |
-
print(query)
|
| 788 |
links = self._extract_links_from_results(search_result)
|
| 789 |
seen = set()
|
| 790 |
results = []
|
|
|
|
| 95 |
wikipedia_tool: WikipediaQueryRun = Field(default_factory=lambda: WikipediaQueryRun(
|
| 96 |
api_wrapper=WikipediaAPIWrapper(top_k_results=5)
|
| 97 |
))
|
|
|
|
| 98 |
def _run(self, question: str) -> str:
|
| 99 |
"""Search Wikipedia and return the result as a string"""
|
| 100 |
try:
|
|
|
|
| 610 |
"""Convert DataFrame to a readable text format optimized for LLM analysis."""
|
| 611 |
# Use to_string for a clean, tabular format
|
| 612 |
table_str = df.to_string(index=False)
|
|
|
|
|
|
|
| 613 |
return f"Table:\n{table_str}"
|
| 614 |
|
| 615 |
def _run(self, task_id: str, question: str = "") -> List[Document]:
|
|
|
|
| 691 |
#search_tool: DuckDuckGoSearchResults = Field(default_factory=DuckDuckGoSearchResults)
|
| 692 |
search_tool: TavilySearchResults = Field(default_factory=TavilySearchResults)
|
| 693 |
|
|
|
|
| 694 |
def _extract_links_from_results(self, search_result) -> list:
|
| 695 |
"""Extract links from search results, robust to type."""
|
| 696 |
links = []
|
|
|
|
| 779 |
def _run(self, query: str) -> str:
|
| 780 |
try:
|
| 781 |
search_result = self.search_tool.run(query, max_results=5)
|
|
|
|
|
|
|
| 782 |
links = self._extract_links_from_results(search_result)
|
| 783 |
seen = set()
|
| 784 |
results = []
|