Spaces:
Sleeping
Sleeping
add_tools_and_change_model
Browse files
app.py
CHANGED
@@ -33,6 +33,22 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
33 |
except Exception as e:
|
34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
final_answer = FinalAnswerTool()
|
38 |
|
@@ -42,7 +58,8 @@ final_answer = FinalAnswerTool()
|
|
42 |
model = HfApiModel(
|
43 |
max_tokens=2096,
|
44 |
temperature=0.5,
|
45 |
-
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
|
|
|
46 |
custom_role_conversions=None,
|
47 |
)
|
48 |
|
@@ -55,7 +72,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
55 |
|
56 |
agent = CodeAgent(
|
57 |
model=model,
|
58 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
59 |
max_steps=6,
|
60 |
verbosity_level=1,
|
61 |
grammar=None,
|
|
|
33 |
except Exception as e:
|
34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
35 |
|
36 |
+
def get_temperature(location: str) -> str:
|
37 |
+
"""A tool that fetches the current temperature in a specified location.
|
38 |
+
Args:
|
39 |
+
location: The name of the city or place (e.g., 'New York').
|
40 |
+
"""
|
41 |
+
try:
|
42 |
+
response = requests.get(f'https://wttr.in/{location}?format=%t')
|
43 |
+
if response.status_code == 200:
|
44 |
+
return f"The current temperature in {location} is {response.text}"
|
45 |
+
else:
|
46 |
+
return "Failed to retrieve temperature. Please check the location name."
|
47 |
+
except Exception as e:
|
48 |
+
return f"Error fetching temperature for '{location}': {str(e)}"
|
49 |
+
|
50 |
+
|
51 |
+
|
52 |
|
53 |
final_answer = FinalAnswerTool()
|
54 |
|
|
|
58 |
model = HfApiModel(
|
59 |
max_tokens=2096,
|
60 |
temperature=0.5,
|
61 |
+
#model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
|
62 |
+
model_id= 'https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
63 |
custom_role_conversions=None,
|
64 |
)
|
65 |
|
|
|
72 |
|
73 |
agent = CodeAgent(
|
74 |
model=model,
|
75 |
+
tools=[get_temperature, get_current_time_in_timezone,final_answer], ## add your tools here (don't remove final answer)
|
76 |
max_steps=6,
|
77 |
verbosity_level=1,
|
78 |
grammar=None,
|