ffreemt
commited on
Commit
·
bfeba31
1
Parent(s):
e49f581
Update
Browse files- app.py +17 -4
- requirements.txt +2 -0
app.py
CHANGED
|
@@ -6,6 +6,8 @@ import datetime
|
|
| 6 |
# import requests
|
| 7 |
import pytz
|
| 8 |
import yaml
|
|
|
|
|
|
|
| 9 |
from smolagents import (
|
| 10 |
CodeAgent,
|
| 11 |
# DuckDuckGoSearchTool,
|
|
@@ -13,7 +15,6 @@ from smolagents import (
|
|
| 13 |
load_tool,
|
| 14 |
tool,
|
| 15 |
)
|
| 16 |
-
from Gradio_UI import GradioUI
|
| 17 |
from tools.final_answer import FinalAnswerTool
|
| 18 |
|
| 19 |
|
|
@@ -41,6 +42,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 41 |
timezone: A string representing a valid timezone (e.g., 'America/New_York').
|
| 42 |
|
| 43 |
"""
|
|
|
|
| 44 |
try:
|
| 45 |
# Create timezone object
|
| 46 |
tz = pytz.timezone(timezone)
|
|
@@ -48,6 +50,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 48 |
local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
| 49 |
return f"The current local time in {timezone} is: {local_time}"
|
| 50 |
except Exception as e:
|
|
|
|
| 51 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 52 |
|
| 53 |
|
|
@@ -68,7 +71,11 @@ with open("prompts.yaml", "r", encoding="utf8") as stream:
|
|
| 68 |
|
| 69 |
agent = CodeAgent(
|
| 70 |
model=model,
|
| 71 |
-
tools=[
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
max_steps=6,
|
| 73 |
verbosity_level=1,
|
| 74 |
grammar=None,
|
|
@@ -78,5 +85,11 @@ agent = CodeAgent(
|
|
| 78 |
prompt_templates=prompt_templates,
|
| 79 |
)
|
| 80 |
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
# import requests
|
| 7 |
import pytz
|
| 8 |
import yaml
|
| 9 |
+
from Gradio_UI import GradioUI
|
| 10 |
+
from loguru import logger
|
| 11 |
from smolagents import (
|
| 12 |
CodeAgent,
|
| 13 |
# DuckDuckGoSearchTool,
|
|
|
|
| 15 |
load_tool,
|
| 16 |
tool,
|
| 17 |
)
|
|
|
|
| 18 |
from tools.final_answer import FinalAnswerTool
|
| 19 |
|
| 20 |
|
|
|
|
| 42 |
timezone: A string representing a valid timezone (e.g., 'America/New_York').
|
| 43 |
|
| 44 |
"""
|
| 45 |
+
logger.debug(f" get_current_time_in_timezone {timezone=}")
|
| 46 |
try:
|
| 47 |
# Create timezone object
|
| 48 |
tz = pytz.timezone(timezone)
|
|
|
|
| 50 |
local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
| 51 |
return f"The current local time in {timezone} is: {local_time}"
|
| 52 |
except Exception as e:
|
| 53 |
+
logger.error(e)
|
| 54 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 55 |
|
| 56 |
|
|
|
|
| 71 |
|
| 72 |
agent = CodeAgent(
|
| 73 |
model=model,
|
| 74 |
+
tools=[
|
| 75 |
+
my_cutom_tool,
|
| 76 |
+
get_current_time_in_timezone,
|
| 77 |
+
final_answer,
|
| 78 |
+
], ## add your tools here (don't remove final answer)
|
| 79 |
max_steps=6,
|
| 80 |
verbosity_level=1,
|
| 81 |
grammar=None,
|
|
|
|
| 85 |
prompt_templates=prompt_templates,
|
| 86 |
)
|
| 87 |
|
| 88 |
+
debug = True
|
| 89 |
+
share = True
|
| 90 |
+
ssr = True
|
| 91 |
+
GradioUI(agent).launch(
|
| 92 |
+
debug=debug,
|
| 93 |
+
share=share,
|
| 94 |
+
ssr=ssr,
|
| 95 |
+
)
|
requirements.txt
CHANGED
|
@@ -3,3 +3,5 @@ smolagents
|
|
| 3 |
requests
|
| 4 |
duckduckgo_search
|
| 5 |
pandas
|
|
|
|
|
|
|
|
|
| 3 |
requests
|
| 4 |
duckduckgo_search
|
| 5 |
pandas
|
| 6 |
+
|
| 7 |
+
loguru
|