ctattevin commited on
Commit
92842d4
·
verified ·
1 Parent(s): e8c7e85

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -27
app.py CHANGED
@@ -6,30 +6,7 @@ from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
6
  from tools.final_answer import FinalAnswerTool
7
  from Gradio_UI import GradioUI
8
 
9
- # 1. Get Current Weather Data
10
- @tool
11
- def get_weather(city: str) -> str:
12
- """Fetches current weather information for a specified city.
13
- Args:
14
- city: The name of the city (e.g., 'New York').
15
- Returns:
16
- A string with the weather description and temperature.
17
- """
18
- api_key = "ac662b5c2463cfa522e1acd2d4cf5a81"
19
- url = f"http://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}&units=metric"
20
-
21
- try:
22
- response = requests.get(url).json()
23
- if response["cod"] != 200:
24
- return f"Error: {response['message']}"
25
-
26
- temp = response["main"]["temp"]
27
- weather_desc = response["weather"][0]["description"]
28
- return f"The current weather in {city} is {weather_desc} with a temperature of {temp}°C."
29
- except Exception as e:
30
- return f"Error fetching weather data: {str(e)}"
31
-
32
- # 2. Get Current Time in Timezone
33
  @tool
34
  def get_current_time_in_timezone(timezone: str) -> str:
35
  """A tool that fetches the current local time in a specified timezone.
@@ -49,7 +26,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
49
  final_answer = FinalAnswerTool()
50
 
51
  # 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:
52
- model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
53
 
54
  print("Cyril model is ")
55
  print(model_id)
@@ -57,12 +34,12 @@ print(model_id)
57
  model = HfApiModel(
58
  max_tokens=2096,
59
  temperature=0.5,
60
- #model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
61
  #custom_role_conversions=None,
62
  )
63
 
64
  # Import tool from Hub
65
- image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
66
 
67
  with open("prompts.yaml", 'r') as stream:
68
  prompt_templates = yaml.safe_load(stream)
 
6
  from tools.final_answer import FinalAnswerTool
7
  from Gradio_UI import GradioUI
8
 
9
+ # 1. Get Current Time in Timezone
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  @tool
11
  def get_current_time_in_timezone(timezone: str) -> str:
12
  """A tool that fetches the current local time in a specified timezone.
 
26
  final_answer = FinalAnswerTool()
27
 
28
  # 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:
29
+ #model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
30
 
31
  print("Cyril model is ")
32
  print(model_id)
 
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
  # Import tool from Hub
42
+ #image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
43
 
44
  with open("prompts.yaml", 'r') as stream:
45
  prompt_templates = yaml.safe_load(stream)