Stoyan Georgiev commited on
Commit
720dcea
·
1 Parent(s): e8517c9

Updated the Space with new features

Browse files
Files changed (1) hide show
  1. app.py +26 -9
app.py CHANGED
@@ -9,15 +9,32 @@ from Gradio_UI import GradioUI
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
- def my_cutom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
- #Keep this format for the description / args / args description but feel free to modify the tool
14
- """A tool that does nothing yet
15
  Args:
16
- arg1: the first argument
17
- arg2: the second argument
18
  """
19
- return "What magic will you build ?"
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  @tool
23
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -38,7 +55,7 @@ final_answer = FinalAnswerTool()
38
  model = HfApiModel(
39
  max_tokens=2096,
40
  temperature=0.5,
41
- model_id='https://wxknx1kg971u7k1n.us-east-1.aws.endpoints.huggingface.cloud',# it is possible that this model may be overloaded
42
  custom_role_conversions=None,
43
  )
44
 
@@ -51,13 +68,13 @@ with open("prompts.yaml", 'r') as stream:
51
 
52
  agent = CodeAgent(
53
  model=model,
54
- tools=[final_answer, get_current_time_in_timezone], # Add your tool here
55
  max_steps=6,
56
  verbosity_level=1,
57
  grammar=None,
58
  planning_interval=None,
59
  name="TimeZone Agent",
60
- description="An agent that can provide the current time in any timezone and perform other tasks.",
61
  prompt_templates=prompt_templates
62
  )
63
 
 
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
+ def my_cutom_tool(arg1: str, arg2: int) -> str:
13
+ """A tool that uses DuckDuckGoSearchTool to fetch Bitcoin news from today.
14
+
15
  Args:
16
+ arg1: (Unused) Reserved for future use.
17
+ arg2: (Unused) Reserved for future use.
18
  """
 
19
 
20
+ # Get today's date string (e.g., "2025-02-11")
21
+ today = datetime.now().strftime("%Y-%m-%d")
22
+
23
+ # Build a query that hints at today's news.
24
+ # Including the date in the query helps nudge the search towards recent articles.
25
+ query = f"Bitcoin news {today}"
26
+
27
+ # Initialize and run the search tool
28
+ search_tool = DuckDuckGoSearchTool()
29
+ results = search_tool.run(query)
30
+
31
+ # Optionally: filter the returned lines if they include today's date.
32
+ # (This assumes that the news snippets contain the publication date in "YYYY-MM-DD" format.)
33
+ filtered_results = "\n".join(
34
+ line for line in results.splitlines() if today in line
35
+ )
36
+
37
+ return filtered_results if filtered_results else "No current Bitcoin news found for today."
38
 
39
  @tool
40
  def get_current_time_in_timezone(timezone: str) -> str:
 
55
  model = HfApiModel(
56
  max_tokens=2096,
57
  temperature=0.5,
58
+ model_id='https://wxknx1kg971u7k1n.us-east-1.aws.endpoints.huggingface.cloud',
59
  custom_role_conversions=None,
60
  )
61
 
 
68
 
69
  agent = CodeAgent(
70
  model=model,
71
+ tools=[final_answer, get_current_time_in_timezone, my_cutom_tool], # Add your tool here
72
  max_steps=6,
73
  verbosity_level=1,
74
  grammar=None,
75
  planning_interval=None,
76
  name="TimeZone Agent",
77
+ description="An agent that can provide the current time in any timezone, get current news and perform other tasks.",
78
  prompt_templates=prompt_templates
79
  )
80