deniyoz commited on
Commit
64ad37d
·
verified ·
1 Parent(s): 7a4886d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -14
app.py CHANGED
@@ -7,7 +7,6 @@ from tools.final_answer import FinalAnswerTool
7
 
8
  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 convert_currency(amount: float, from_currency: str, to_currency: str) -> str:
13
  """
@@ -29,7 +28,7 @@ def convert_currency(amount: float, from_currency: str, to_currency: str) -> str
29
  if from_currency not in exchange_rates or to_currency not in exchange_rates:
30
  return f"Error: Invalid currency '{from_currency}' or '{to_currency}'"
31
 
32
- # Convert to USD first, then to target currency
33
  amount_in_usd = amount / exchange_rates[from_currency]
34
  converted_amount = amount_in_usd * exchange_rates[to_currency]
35
  return f"{amount} {from_currency} = {round(converted_amount, 2)} {to_currency}"
@@ -43,9 +42,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
43
  timezone: A string representing a valid timezone (e.g., 'America/New_York').
44
  """
45
  try:
46
- # Create timezone object
47
  tz = pytz.timezone(timezone)
48
- # Get current time in that timezone
49
  local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
50
  return f"The current local time in {timezone} is: {local_time}"
51
  except Exception as e:
@@ -54,17 +51,13 @@ def get_current_time_in_timezone(timezone: str) -> str:
54
 
55
  final_answer = FinalAnswerTool()
56
 
57
- # 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:
58
- # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
59
-
60
  model = HfApiModel(
61
- max_tokens=2096,
62
- temperature=0.5,
63
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
64
- custom_role_conversions=None,
65
  )
66
 
67
-
68
  # Import tool from Hub
69
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
70
 
@@ -77,7 +70,7 @@ agent = CodeAgent(
77
  final_answer,
78
  get_current_time_in_timezone,
79
  convert_currency
80
- ], # convert_currency aracını ekledik
81
  max_steps=6,
82
  verbosity_level=1,
83
  grammar=None,
@@ -88,5 +81,4 @@ agent = CodeAgent(
88
  )
89
 
90
 
91
-
92
  GradioUI(agent).launch()
 
7
 
8
  from Gradio_UI import GradioUI
9
 
 
10
  @tool
11
  def convert_currency(amount: float, from_currency: str, to_currency: str) -> str:
12
  """
 
28
  if from_currency not in exchange_rates or to_currency not in exchange_rates:
29
  return f"Error: Invalid currency '{from_currency}' or '{to_currency}'"
30
 
31
+ # Önce USD'ye çevirilir, sonra kullanıcıdan alınan dövize göre işlem yapılır
32
  amount_in_usd = amount / exchange_rates[from_currency]
33
  converted_amount = amount_in_usd * exchange_rates[to_currency]
34
  return f"{amount} {from_currency} = {round(converted_amount, 2)} {to_currency}"
 
42
  timezone: A string representing a valid timezone (e.g., 'America/New_York').
43
  """
44
  try:
 
45
  tz = pytz.timezone(timezone)
 
46
  local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
47
  return f"The current local time in {timezone} is: {local_time}"
48
  except Exception as e:
 
51
 
52
  final_answer = FinalAnswerTool()
53
 
 
 
 
54
  model = HfApiModel(
55
+ max_tokens=2096,
56
+ temperature=0.5,
57
+ model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
58
+ custom_role_conversions=None,
59
  )
60
 
 
61
  # Import tool from Hub
62
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
63
 
 
70
  final_answer,
71
  get_current_time_in_timezone,
72
  convert_currency
73
+ ], # convert_currency aracı eklendi
74
  max_steps=6,
75
  verbosity_level=1,
76
  grammar=None,
 
81
  )
82
 
83
 
 
84
  GradioUI(agent).launch()