Spaces:
Sleeping
Sleeping
Added Wikipedia Lookup facility
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
|
@@ -18,6 +19,19 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
| 18 |
"""
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 23 |
"""A tool that fetches the current local time in a specified timezone.
|
|
@@ -102,7 +116,12 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 102 |
|
| 103 |
agent = CodeAgent(
|
| 104 |
model=model,
|
| 105 |
-
tools=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
max_steps=6,
|
| 107 |
verbosity_level=1,
|
| 108 |
grammar=None,
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
import wikipedia
|
| 8 |
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
|
|
|
| 19 |
"""
|
| 20 |
return "What magic will you build ?"
|
| 21 |
|
| 22 |
+
|
| 23 |
+
@tool
|
| 24 |
+
def wikipedia_summary(query: str) -> str:
|
| 25 |
+
"""A tool that fetches a short summary from Wikipedia for a given topic.
|
| 26 |
+
Args:
|
| 27 |
+
query: The topic to search for.
|
| 28 |
+
"""
|
| 29 |
+
try:
|
| 30 |
+
return wikipedia.summary(query, sentences=2)
|
| 31 |
+
except Exception as e:
|
| 32 |
+
return f"Error fetching Wikipedia summary: {str(e)}"
|
| 33 |
+
|
| 34 |
+
|
| 35 |
@tool
|
| 36 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 37 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
|
| 116 |
|
| 117 |
agent = CodeAgent(
|
| 118 |
model=model,
|
| 119 |
+
tools=[
|
| 120 |
+
final_answer,
|
| 121 |
+
calculate_bmi,
|
| 122 |
+
get_current_time_in_timezone
|
| 123 |
+
wikipedia_summary
|
| 124 |
+
], ## add your tools here (don't remove final answer)
|
| 125 |
max_steps=6,
|
| 126 |
verbosity_level=1,
|
| 127 |
grammar=None,
|