Update cool_agent.py
Browse files- cool_agent.py +0 -24
cool_agent.py
CHANGED
|
@@ -17,33 +17,10 @@ from smolagents import (
|
|
| 17 |
CodeAgent,
|
| 18 |
LiteLLMModel,
|
| 19 |
ToolCallingAgent,
|
| 20 |
-
Tool,
|
| 21 |
)
|
| 22 |
import threading
|
| 23 |
|
| 24 |
|
| 25 |
-
class WikiSearchTool(Tool):
|
| 26 |
-
name = "wiki_search"
|
| 27 |
-
description = "Search Wikipedia for a query and return maximum 2 results."
|
| 28 |
-
inputs = {
|
| 29 |
-
"query": {"type": "string", "description": "The search query to perform."},
|
| 30 |
-
}
|
| 31 |
-
output_type = "dict"
|
| 32 |
-
|
| 33 |
-
def __init__(self):
|
| 34 |
-
super().__init__(self)
|
| 35 |
-
|
| 36 |
-
def forward(self, query: str) -> dict:
|
| 37 |
-
search_docs = WikipediaLoader(query=query, load_max_docs=2).load()
|
| 38 |
-
formatted_search_docs = "\n\n---\n\n".join(
|
| 39 |
-
[
|
| 40 |
-
f'<Document source="{doc.metadata["source"]}" page="'
|
| 41 |
-
f'{doc.metadata.get("page", "")}"/>\n{doc.page_content}\n</Document>'
|
| 42 |
-
for doc in search_docs
|
| 43 |
-
])
|
| 44 |
-
return {"wiki_results": formatted_search_docs}
|
| 45 |
-
|
| 46 |
-
|
| 47 |
AUTHORIZED_IMPORTS = [
|
| 48 |
"requests",
|
| 49 |
"zipfile",
|
|
@@ -115,7 +92,6 @@ def create_agent(model_id="gpt-4o-mini"):
|
|
| 115 |
FindNextTool(browser),
|
| 116 |
ArchiveSearchTool(browser),
|
| 117 |
TextInspectorTool(model, text_limit),
|
| 118 |
-
WikiSearchTool(),
|
| 119 |
]
|
| 120 |
text_webbrowser_agent = ToolCallingAgent(
|
| 121 |
model=model,
|
|
|
|
| 17 |
CodeAgent,
|
| 18 |
LiteLLMModel,
|
| 19 |
ToolCallingAgent,
|
|
|
|
| 20 |
)
|
| 21 |
import threading
|
| 22 |
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
AUTHORIZED_IMPORTS = [
|
| 25 |
"requests",
|
| 26 |
"zipfile",
|
|
|
|
| 92 |
FindNextTool(browser),
|
| 93 |
ArchiveSearchTool(browser),
|
| 94 |
TextInspectorTool(model, text_limit),
|
|
|
|
| 95 |
]
|
| 96 |
text_webbrowser_agent = ToolCallingAgent(
|
| 97 |
model=model,
|