Spaces:
Sleeping
Sleeping
update tools
Browse files
agent.py
CHANGED
|
@@ -5,7 +5,7 @@ import numexpr
|
|
| 5 |
from langchain_community.document_loaders import ArxivLoader
|
| 6 |
from smolagents import (
|
| 7 |
CodeAgent,
|
| 8 |
-
|
| 9 |
InferenceClientModel,
|
| 10 |
WikipediaSearchTool,
|
| 11 |
tool,
|
|
@@ -40,19 +40,28 @@ def calculator(expression: str) -> str:
|
|
| 40 |
@tool
|
| 41 |
def arxiv_search_tool(query: str) -> str:
|
| 42 |
"""
|
| 43 |
-
Searches Arxiv and returns a summary or full text of the given topic, along with the page URL.
|
| 44 |
Args:
|
| 45 |
query: the topic to be searched
|
| 46 |
"""
|
| 47 |
-
|
| 48 |
-
if len(
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
return "No content found"
|
| 53 |
|
| 54 |
|
| 55 |
-
tools = [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
model_id = "Qwen/Qwen3-235B-A22B"
|
| 58 |
model = InferenceClientModel(
|
|
|
|
| 5 |
from langchain_community.document_loaders import ArxivLoader
|
| 6 |
from smolagents import (
|
| 7 |
CodeAgent,
|
| 8 |
+
GoogleSearchTool,
|
| 9 |
InferenceClientModel,
|
| 10 |
WikipediaSearchTool,
|
| 11 |
tool,
|
|
|
|
| 40 |
@tool
|
| 41 |
def arxiv_search_tool(query: str) -> str:
|
| 42 |
"""
|
| 43 |
+
Searches Arxiv and returns a summary or full text of the given topic of the 5 most likely related papers, along with the page URL.
|
| 44 |
Args:
|
| 45 |
query: the topic to be searched
|
| 46 |
"""
|
| 47 |
+
docs = ArxivLoader(query=query, load_max_docs=5).load()
|
| 48 |
+
if len(docs) > 0:
|
| 49 |
+
return "\n".join(
|
| 50 |
+
[
|
| 51 |
+
f'<Document source="{doc.metadata["source"]}" page="{doc.metadata.get("page", "")}"/>\n{doc.page_content[:1000]}\n</Document>'
|
| 52 |
+
for doc in docs
|
| 53 |
+
]
|
| 54 |
+
)
|
| 55 |
|
| 56 |
return "No content found"
|
| 57 |
|
| 58 |
|
| 59 |
+
tools = [
|
| 60 |
+
calculator,
|
| 61 |
+
arxiv_search_tool,
|
| 62 |
+
GoogleSearchTool(provider="serper"),
|
| 63 |
+
WikipediaSearchTool(),
|
| 64 |
+
]
|
| 65 |
|
| 66 |
model_id = "Qwen/Qwen3-235B-A22B"
|
| 67 |
model = InferenceClientModel(
|