Spaces:
Sleeping
Sleeping
feat: add some fun stuff
Browse files- app.py +15 -2
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -1,12 +1,13 @@
|
|
| 1 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
| 2 |
import datetime
|
| 3 |
import requests
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
|
|
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
from tools.visit_webpage import VisitWebpageTool
|
| 8 |
from tools.web_search import DuckDuckGoSearchTool
|
| 9 |
-
|
| 10 |
from Gradio_UI import GradioUI
|
| 11 |
|
| 12 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
|
@@ -19,6 +20,18 @@ def greeting(name:str)-> str: #it's import to specify the return type
|
|
| 19 |
"""
|
| 20 |
return f"Hi! {name}, nice to meet you, My boss is UyCode!"
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
@tool
|
| 23 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 24 |
"""A tool that fetches the current local time in a specified timezone.
|
|
@@ -58,7 +71,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 58 |
|
| 59 |
agent = CodeAgent(
|
| 60 |
model=model,
|
| 61 |
-
tools=[final_answer, web_search, visit_webpage, get_current_time_in_timezone, greeting], ## add your tools here (don't remove final answer)
|
| 62 |
max_steps=6,
|
| 63 |
verbosity_level=1,
|
| 64 |
grammar=None,
|
|
|
|
| 1 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
+
import names
|
| 5 |
import pytz
|
| 6 |
import yaml
|
| 7 |
+
import random
|
| 8 |
from tools.final_answer import FinalAnswerTool
|
| 9 |
from tools.visit_webpage import VisitWebpageTool
|
| 10 |
from tools.web_search import DuckDuckGoSearchTool
|
|
|
|
| 11 |
from Gradio_UI import GradioUI
|
| 12 |
|
| 13 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
|
|
|
| 20 |
"""
|
| 21 |
return f"Hi! {name}, nice to meet you, My boss is UyCode!"
|
| 22 |
|
| 23 |
+
|
| 24 |
+
@tool
|
| 25 |
+
def generate_random_name() -> str:
|
| 26 |
+
"""A tool that generates some random name
|
| 27 |
+
Args:
|
| 28 |
+
None
|
| 29 |
+
"""
|
| 30 |
+
# generate 1 or 0 for gender representation
|
| 31 |
+
gender = "female" if random.choice([0, 1]) == 0 else "male"
|
| 32 |
+
# generate a random name based on the gender
|
| 33 |
+
return names.get_first_name(gender=gender)
|
| 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.
|
|
|
|
| 71 |
|
| 72 |
agent = CodeAgent(
|
| 73 |
model=model,
|
| 74 |
+
tools=[final_answer, web_search, visit_webpage, get_current_time_in_timezone, greeting, generate_random_name], ## add your tools here (don't remove final answer)
|
| 75 |
max_steps=6,
|
| 76 |
verbosity_level=1,
|
| 77 |
grammar=None,
|
requirements.txt
CHANGED
|
@@ -3,3 +3,4 @@ smolagents==1.13.0
|
|
| 3 |
requests
|
| 4 |
duckduckgo_search
|
| 5 |
pandas
|
|
|
|
|
|
| 3 |
requests
|
| 4 |
duckduckgo_search
|
| 5 |
pandas
|
| 6 |
+
names
|