File size: 1,772 Bytes
a068c58
9b5b26a
 
 
c19d193
6aae614
9b5b26a
 
a068c58
9b5b26a
a068c58
 
9b5b26a
a068c58
 
 
9b5b26a
a068c58
 
8c01ffb
a068c58
 
6aae614
ae7a494
a068c58
e121372
a068c58
 
 
 
13d500a
8c01ffb
a068c58
9b5b26a
8c01ffb
a068c58
861422e
 
a068c58
 
8c01ffb
8fe992b
a068c58
8c01ffb
 
 
 
 
 
861422e
8fe992b
 
8c01ffb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
import datetime
import requests
import pytz
import yaml
from tools.final_answer import FinalAnswerTool
from Gradio_UI import GradioUI

# Custom tool for constructing the search query
@tool
def construct_course_search_query(interest: str, expertise: str, budget: str) -> str:
    """Constructs a search query for finding AI courses based on user preferences.
    Args:
        interest: The area of interest within AI (e.g., 'machine learning', 'deep learning').
        expertise: The user's current level of expertise (e.g., 'beginner', 'intermediate').
        budget: The budget available for the course (e.g., '$100', 'free').
    """
    query = f"best {interest} courses for {expertise} under {budget}"
    return query

# Existing tools from the template
search_tool = DuckDuckGoSearchTool()
final_answer = FinalAnswerTool()

# Model configuration (unchanged from template)
model = HfApiModel(
    max_tokens=2096,
    temperature=0.5,
    model_id='Llama',  # Note: May need to switch if overloaded
    custom_role_conversions=None,
)

# Import tool from Hub (unchanged from template)
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)

# Load prompt templates (unchanged from template)
with open("prompts.yaml", 'r') as stream:
    prompt_templates = yaml.safe_load(stream)

# Initialize the agent with the updated tools list
agent = CodeAgent(
    model=model,
    tools=[construct_course_search_query, search_tool, final_answer],  # Added custom tool
    max_steps=6,
    verbosity_level=1,
    grammar=None,
    planning_interval=None,
    name=None,
    description=None,
    prompt_templates=prompt_templates
)

GradioUI(agent).launch()