dlaima commited on
Commit
8958223
·
verified ·
1 Parent(s): 9e8ea68

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -7
app.py CHANGED
@@ -12,13 +12,37 @@ from smolagents.models import OpenAIServerModel
12
  from smolagents import Tool
13
  from wikipedia_searcher import WikipediaSearcher
14
 
15
- wikipedia_search_tool = Tool(
16
- name="wikipedia_search",
17
- func=WikipediaSearcher().search,
18
- description="Search Wikipedia for a given query.",
19
- inputs={"query": "string"},
20
- output_type="string"
21
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
 
24
  # Define the system prompt
 
12
  from smolagents import Tool
13
  from wikipedia_searcher import WikipediaSearcher
14
 
15
+ #wikipedia_search_tool = Tool(
16
+ # name="wikipedia_search",
17
+ # func=WikipediaSearcher().search,
18
+ # description="Search Wikipedia for a given query.",
19
+ # inputs={"query": "string"},
20
+ # output_type="string"
21
+ #)
22
+
23
+
24
+
25
+ class WikipediaSearchTool(Tool):
26
+ def __init__(self):
27
+ super().__init__(
28
+ name="wikipedia_search",
29
+ description="Search Wikipedia for a given query.",
30
+ inputs={"query": "string"},
31
+ output_type="string",
32
+ )
33
+ self.searcher = WikipediaSearcher()
34
+
35
+ def __call__(self, inputs: dict) -> str:
36
+ query = inputs.get("query", "")
37
+ return self.searcher.search(query)
38
+
39
+ wikipedia_search_tool = WikipediaSearchTool()
40
+
41
+
42
+
43
+
44
+
45
+
46
 
47
 
48
  # Define the system prompt