lcapriles commited on
Commit
844f2bb
·
verified ·
1 Parent(s): 2d400d4

Created app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -46
app.py CHANGED
@@ -7,52 +7,8 @@ from tools.final_answer import FinalAnswerTool
7
 
8
  from Gradio_UI import GradioUI
9
 
10
- #Available tools
11
- @tool
12
- def get_current_time_in_timezone(timezone: str) -> str:
13
- """A tool that fetches the current local time in a specified timezone.
14
- Args:
15
- timezone: A string representing a valid timezone (e.g., 'America/New_York').
16
- Return:
17
- The following Python formatted string: f"The current local time in {timezone} is: {local_time}"
18
- """
19
- try:
20
- # Create timezone object
21
- tz = pytz.timezone(timezone)
22
- # Get current time in that timezone
23
- local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
24
- print(f"The current local time in {timezone} is: {local_time}")
25
- return f"The current local time in {timezone} is: {local_time}"
26
- except Exception as e:
27
- return f"Error fetching time for timezone '{timezone}': {str(e)}"
28
-
29
- final_answer = FinalAnswerTool()
30
-
31
-
32
- # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
33
- # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
34
- model = HfApiModel(
35
- max_tokens=2096,
36
- temperature=0.5,
37
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
38
- custom_role_conversions=None,
39
- )
40
-
41
-
42
- with open("prompts.yaml", 'r') as stream:
43
- prompt_templates = yaml.safe_load(stream)
44
-
45
- agent = CodeAgent(
46
- model=model,
47
- tools=[get_current_time_in_timezone,final_answer], ## add your tools here (don't remove final answer)
48
- max_steps=6,
49
- verbosity_level=1,
50
- grammar=None,
51
- planning_interval=None,
52
- name=None,
53
- description=None,
54
- prompt_templates=prompt_templates
55
- )
56
 
 
 
57
 
58
  GradioUI(agent).launch()
 
7
 
8
  from Gradio_UI import GradioUI
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
+ agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=HfApiModel())
12
+ agent.run("Search for the best music recommendations for a party at the Wayne's mansion.")
13
 
14
  GradioUI(agent).launch()