srkdev384 commited on
Commit
c6dfefe
·
verified ·
1 Parent(s): 94e5a71

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -1
app.py CHANGED
@@ -144,6 +144,32 @@ def get_today_matches() -> str:
144
 
145
  return result
146
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
 
148
  final_answer = FinalAnswerTool()
149
 
@@ -164,7 +190,7 @@ with open("prompts.yaml", 'r') as stream:
164
 
165
  agent = CodeAgent(
166
  model=model,
167
- tools=[final_answer, generate_image, get_current_time_in_timezone, get_live_cricket_score, get_today_matches], ## add your tools here (don't remove final answer)
168
  max_steps=6,
169
  verbosity_level=1,
170
  grammar=None,
 
144
 
145
  return result
146
 
147
+ @tool
148
+ def wiki_search(query: str) -> str:
149
+ """
150
+ Fetches a short summary from Wikipedia for a given topic.
151
+
152
+ Args:
153
+ query: Topic to search on Wikipedia.
154
+
155
+ Returns:
156
+ A short summary of the topic.
157
+ """
158
+
159
+ url = f"https://en.wikipedia.org/api/rest_v1/page/summary/{query}"
160
+
161
+ try:
162
+ response = requests.get(url, timeout=10)
163
+
164
+ if response.status_code != 200:
165
+ return "No Wikipedia page found for this topic."
166
+
167
+ data = response.json()
168
+
169
+ return data.get("extract", "No summary available.")
170
+
171
+ except Exception as e:
172
+ return f"Error fetching Wikipedia data: {str(e)}"
173
 
174
  final_answer = FinalAnswerTool()
175
 
 
190
 
191
  agent = CodeAgent(
192
  model=model,
193
+ tools=[final_answer, generate_image, get_current_time_in_timezone, get_live_cricket_score, get_today_matches, wiki_search], ## add your tools here (don't remove final answer)
194
  max_steps=6,
195
  verbosity_level=1,
196
  grammar=None,