File size: 1,104 Bytes
432144d
c19d193
432144d
9b5b26a
 
432144d
869f699
 
432144d
 
869f699
 
 
 
 
432144d
 
 
869f699
8669df0
 
 
 
5611040
869f699
 
 
e121372
e768d75
869f699
 
13d500a
8c01ffb
869f699
 
 
e768d75
 
8c01ffb
869f699
 
 
8c01ffb
8fe992b
869f699
 
 
 
 
 
432144d
8fe992b
 
869f699
 
 
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
54
55
56
57
from smolagents import CodeAgent, HfApiModel, load_tool, tool
import yaml

from Gradio_UI import GradioUI


# -------------------- TOOLS --------------------

@tool
def final_answer(answer: str) -> str:
    """Return the final answer to the user.

    Args:
        answer: The final response to display
    """
    return answer


# ✅ Stable image tool (no manual HF token handling needed)
image_generation_tool = load_tool(
    "agents-course/text-to-image",
    trust_remote_code=True
)


# -------------------- MODEL --------------------

model = HfApiModel(
    model_id="Qwen/Qwen2.5-Coder-32B-Instruct",
    max_tokens=1024,
    temperature=0.3,
)


# -------------------- PROMPTS --------------------

with open("prompts.yaml", "r") as f:
    prompt_templates = yaml.safe_load(f)


# -------------------- AGENT --------------------

agent = CodeAgent(
    model=model,
    tools=[
        final_answer,
        image_generation_tool
    ],
    max_steps=4,
    verbosity_level=1,
    prompt_templates=prompt_templates
)


# -------------------- UI --------------------

GradioUI(agent).launch()