Update app.py
Browse files
app.py
CHANGED
|
@@ -13,29 +13,29 @@ import base64
|
|
| 13 |
from smolagents import load_tool
|
| 14 |
from typing import Any
|
| 15 |
|
| 16 |
-
class DuckDuckGoSearchTool(Tool):
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
|
| 40 |
|
| 41 |
model = InferenceClientModel("qwen/Qwen2.5-0.5B-Instruct",
|
|
@@ -112,11 +112,15 @@ tools = [
|
|
| 112 |
name="image-captioning",
|
| 113 |
description="Generates a caption for an input image."
|
| 114 |
),
|
| 115 |
-
# load_tool("duckduckgo-search", trust_remote_code=True),
|
| 116 |
DuckDuckGoSearchTool(),
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
]
|
| 121 |
# # ---------------------- AGENT SETUP ---------------------- #
|
| 122 |
# agent = CodeAgent(
|
|
|
|
| 13 |
from smolagents import load_tool
|
| 14 |
from typing import Any
|
| 15 |
|
| 16 |
+
# class DuckDuckGoSearchTool(Tool):
|
| 17 |
+
# name = "web_search"
|
| 18 |
+
# description = "Performs a duckduckgo web search based on your query (think a Google search) then returns the top search results."
|
| 19 |
+
# inputs = {'query': {'type': 'string', 'description': 'The search query to perform.'}}
|
| 20 |
+
# output_type = "string"
|
| 21 |
+
|
| 22 |
+
# def __init__(self, max_results=10, **kwargs):
|
| 23 |
+
# super().__init__()
|
| 24 |
+
# self.max_results = max_results
|
| 25 |
+
# try:
|
| 26 |
+
# from duckduckgo_search import DDGS
|
| 27 |
+
# except ImportError as e:
|
| 28 |
+
# raise ImportError(
|
| 29 |
+
# "You must install package `duckduckgo_search` to run this tool: for instance run `pip install duckduckgo-search`."
|
| 30 |
+
# ) from e
|
| 31 |
+
# self.ddgs = DDGS(**kwargs)
|
| 32 |
|
| 33 |
+
# def forward(self, query: str) -> str:
|
| 34 |
+
# results = self.ddgs.text(query, max_results=self.max_results)
|
| 35 |
+
# if len(results) == 0:
|
| 36 |
+
# raise Exception("No results found! Try a less restrictive/shorter query.")
|
| 37 |
+
# postprocessed_results = [f"[{result['title']}]({result['href']})\n{result['body']}" for result in results]
|
| 38 |
+
# return "## Search Results\n\n" + "\n\n".join(postprocessed_results)
|
| 39 |
|
| 40 |
|
| 41 |
model = InferenceClientModel("qwen/Qwen2.5-0.5B-Instruct",
|
|
|
|
| 112 |
name="image-captioning",
|
| 113 |
description="Generates a caption for an input image."
|
| 114 |
),
|
|
|
|
| 115 |
DuckDuckGoSearchTool(),
|
| 116 |
+
WikipediaSearchTool(),
|
| 117 |
+
PythonInterpreterTool(),
|
| 118 |
+
UserInputTool(),
|
| 119 |
+
# load_tool("duckduckgo-search", trust_remote_code=True),
|
| 120 |
+
# DuckDuckGoSearchTool(),
|
| 121 |
+
# load_tool("wikipedia", trust_remote_code=True),
|
| 122 |
+
# load_tool("python", trust_remote_code=True),
|
| 123 |
+
# load_tool("user-input", trust_remote_code=True),
|
| 124 |
]
|
| 125 |
# # ---------------------- AGENT SETUP ---------------------- #
|
| 126 |
# agent = CodeAgent(
|