ArslanFOX commited on
Commit
74730de
·
verified ·
1 Parent(s): ca755db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -22,6 +22,7 @@ def find_recycling_center(waste_type: str, location: str) -> str:
22
  return f"In {location}, {recycling_info[waste_type.lower()]} Please check their website for opening hours."
23
  else:
24
  return f"Sorry, I don't have information about recycling {waste_type} in {location}. Please contact your local waste management service for assistance."
 
25
  @tool
26
  def get_current_time_in_timezone(timezone: str) -> str:
27
  """
@@ -35,23 +36,32 @@ def get_current_time_in_timezone(timezone: str) -> str:
35
  return f"The current local time in {timezone} is: {local_time}"
36
  except Exception as e:
37
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
 
38
  final_answer = FinalAnswerTool()
 
 
39
  AI_assistant = {
40
  'role1': 'conversion1',
41
  'role2': 'conversion2'
 
42
  }
 
 
43
  model = HfApiModel(
44
  max_tokens=2096,
45
  temperature=0.5,
46
  model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
47
  custom_role_conversions=AI_assistant,
48
  )
 
 
49
  with open("prompts.yaml", 'r') as stream:
50
  prompt_templates = yaml.safe_load(stream)
51
 
 
52
  agent = CodeAgent(
53
  model=model,
54
- tools=[final_answer, find_recycling_center],
55
  max_steps=6,
56
  verbosity_level=1,
57
  grammar=None,
@@ -60,8 +70,6 @@ agent = CodeAgent(
60
  description=None,
61
  prompt_templates=prompt_templates
62
  )
63
- GradioUI(agent).launch(ssr=False)
64
-
65
-
66
-
67
 
 
 
 
22
  return f"In {location}, {recycling_info[waste_type.lower()]} Please check their website for opening hours."
23
  else:
24
  return f"Sorry, I don't have information about recycling {waste_type} in {location}. Please contact your local waste management service for assistance."
25
+
26
  @tool
27
  def get_current_time_in_timezone(timezone: str) -> str:
28
  """
 
36
  return f"The current local time in {timezone} is: {local_time}"
37
  except Exception as e:
38
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
39
+
40
  final_answer = FinalAnswerTool()
41
+
42
+ # Define AI_assistant or import it if it's from another module
43
  AI_assistant = {
44
  'role1': 'conversion1',
45
  'role2': 'conversion2'
46
+ # Add other role conversions as needed
47
  }
48
+
49
+ # Initialize the model
50
  model = HfApiModel(
51
  max_tokens=2096,
52
  temperature=0.5,
53
  model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
54
  custom_role_conversions=AI_assistant,
55
  )
56
+
57
+ # Load prompt templates from a YAML file
58
  with open("prompts.yaml", 'r') as stream:
59
  prompt_templates = yaml.safe_load(stream)
60
 
61
+ # Create the agent with the specified model and tools
62
  agent = CodeAgent(
63
  model=model,
64
+ tools=[final_answer, find_recycling_center], # Add the recycling tool here
65
  max_steps=6,
66
  verbosity_level=1,
67
  grammar=None,
 
70
  description=None,
71
  prompt_templates=prompt_templates
72
  )
 
 
 
 
73
 
74
+ # Launch the Gradio UI with the agent
75
+ GradioUI(agent).launch()