ModernMewtwo26 commited on
Commit
b1e6001
·
verified ·
1 Parent(s): 104e86a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -15,7 +15,7 @@ def construct_course_search_query(interest: str, expertise: str, budget: str) ->
15
  expertise: The user's current level of expertise (e.g., 'beginner', 'intermediate').
16
  budget: The budget available for the course (e.g., '$100', 'free').
17
  """
18
- query = f"best {interest} courses for {expertise} under {budget}"
19
  return query
20
 
21
  # Existing tools from the template
@@ -33,11 +33,11 @@ model = HfApiModel(
33
  # Import tool from Hub (unchanged from template)
34
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
35
 
36
- # Load prompt templates (unchanged from template)
37
  with open("prompts.yaml", 'r') as stream:
38
  prompt_templates = yaml.safe_load(stream)
39
 
40
- # Initialize the agent with the updated tools list
41
  agent = CodeAgent(
42
  model=model,
43
  tools=[construct_course_search_query, search_tool, final_answer], # Added custom tool
@@ -47,7 +47,8 @@ agent = CodeAgent(
47
  planning_interval=None,
48
  name=None,
49
  description=None,
50
- prompt_templates=prompt_templates
 
51
  )
52
 
53
  GradioUI(agent).launch()
 
15
  expertise: The user's current level of expertise (e.g., 'beginner', 'intermediate').
16
  budget: The budget available for the course (e.g., '$100', 'free').
17
  """
18
+ query = f"top {interest} courses for {expertise} under {budget}"
19
  return query
20
 
21
  # Existing tools from the template
 
33
  # Import tool from Hub (unchanged from template)
34
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
35
 
36
+ # Load prompt templates (unchanged from template, but updated in prompt.yaml)
37
  with open("prompts.yaml", 'r') as stream:
38
  prompt_templates = yaml.safe_load(stream)
39
 
40
+ # Initialize the agent with the updated tools list and custom logic
41
  agent = CodeAgent(
42
  model=model,
43
  tools=[construct_course_search_query, search_tool, final_answer], # Added custom tool
 
47
  planning_interval=None,
48
  name=None,
49
  description=None,
50
+ prompt_templates=prompt_templates,
51
+ custom_logic=lambda state: all(key in state for key in ['user_interest', 'user_expertise', 'user_budget'])
52
  )
53
 
54
  GradioUI(agent).launch()