Update cool_agent.py
Browse files- cool_agent.py +19 -2
cool_agent.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
-
import os
|
| 2 |
from linkup_utils import LinkupSearchTool
|
| 3 |
from text_inspector_tool import TextInspectorTool
|
|
|
|
| 4 |
from text_web_browser import (
|
| 5 |
ArchiveSearchTool,
|
| 6 |
FinderTool,
|
|
@@ -18,6 +19,21 @@ from smolagents import (
|
|
| 18 |
ToolCallingAgent,
|
| 19 |
)
|
| 20 |
import threading
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
|
| 23 |
AUTHORIZED_IMPORTS = [
|
|
@@ -91,6 +107,7 @@ def create_agent(model_id="gpt-4o-mini"):
|
|
| 91 |
FindNextTool(browser),
|
| 92 |
ArchiveSearchTool(browser),
|
| 93 |
TextInspectorTool(model, text_limit),
|
|
|
|
| 94 |
]
|
| 95 |
text_webbrowser_agent = ToolCallingAgent(
|
| 96 |
model=model,
|
|
@@ -123,4 +140,4 @@ def create_agent(model_id="gpt-4o-mini"):
|
|
| 123 |
managed_agents=[text_webbrowser_agent],
|
| 124 |
)
|
| 125 |
|
| 126 |
-
return manager_agent
|
|
|
|
| 1 |
+
import os
|
| 2 |
from linkup_utils import LinkupSearchTool
|
| 3 |
from text_inspector_tool import TextInspectorTool
|
| 4 |
+
from langchain_community.document_loaders import WikipediaLoader
|
| 5 |
from text_web_browser import (
|
| 6 |
ArchiveSearchTool,
|
| 7 |
FinderTool,
|
|
|
|
| 19 |
ToolCallingAgent,
|
| 20 |
)
|
| 21 |
import threading
|
| 22 |
+
from langchain_core.tools import tool
|
| 23 |
+
|
| 24 |
+
@tool
|
| 25 |
+
def wiki_search(query: str) -> str:
|
| 26 |
+
"""Search Wikipedia for a query and return maximum 2 results.
|
| 27 |
+
|
| 28 |
+
Args:
|
| 29 |
+
query: The search query."""
|
| 30 |
+
search_docs = WikipediaLoader(query=query, load_max_docs=2).load()
|
| 31 |
+
formatted_search_docs = "\n\n---\n\n".join(
|
| 32 |
+
[
|
| 33 |
+
f'<Document source="{doc.metadata["source"]}" page="{doc.metadata.get("page", "")}"/>\n{doc.page_content}\n</Document>'
|
| 34 |
+
for doc in search_docs
|
| 35 |
+
])
|
| 36 |
+
return {"wiki_results": formatted_search_docs}
|
| 37 |
|
| 38 |
|
| 39 |
AUTHORIZED_IMPORTS = [
|
|
|
|
| 107 |
FindNextTool(browser),
|
| 108 |
ArchiveSearchTool(browser),
|
| 109 |
TextInspectorTool(model, text_limit),
|
| 110 |
+
wiki_search(),
|
| 111 |
]
|
| 112 |
text_webbrowser_agent = ToolCallingAgent(
|
| 113 |
model=model,
|
|
|
|
| 140 |
managed_agents=[text_webbrowser_agent],
|
| 141 |
)
|
| 142 |
|
| 143 |
+
return manager_agent
|