MD112575 commited on
Commit
869f699
·
verified ·
1 Parent(s): 432144d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -1
app.py CHANGED
@@ -4,27 +4,54 @@ import yaml
4
  from Gradio_UI import GradioUI
5
 
6
 
 
 
7
  @tool
8
  def final_answer(answer: str) -> str:
 
 
 
 
 
9
  return answer
10
 
11
 
 
12
  image_generation_tool = load_tool(
13
  "agents-course/text-to-image",
14
  trust_remote_code=True
15
  )
16
 
 
 
 
17
  model = HfApiModel(
18
  model_id="Qwen/Qwen2.5-Coder-32B-Instruct",
 
 
19
  )
20
 
 
 
 
21
  with open("prompts.yaml", "r") as f:
22
  prompt_templates = yaml.safe_load(f)
23
 
 
 
 
24
  agent = CodeAgent(
25
  model=model,
26
- tools=[final_answer, image_generation_tool],
 
 
 
 
 
27
  prompt_templates=prompt_templates
28
  )
29
 
 
 
 
30
  GradioUI(agent).launch()
 
4
  from Gradio_UI import GradioUI
5
 
6
 
7
+ # -------------------- TOOLS --------------------
8
+
9
  @tool
10
  def final_answer(answer: str) -> str:
11
+ """Return the final answer to the user.
12
+
13
+ Args:
14
+ answer: The final response to display
15
+ """
16
  return answer
17
 
18
 
19
+ # ✅ Stable image tool (no manual HF token handling needed)
20
  image_generation_tool = load_tool(
21
  "agents-course/text-to-image",
22
  trust_remote_code=True
23
  )
24
 
25
+
26
+ # -------------------- MODEL --------------------
27
+
28
  model = HfApiModel(
29
  model_id="Qwen/Qwen2.5-Coder-32B-Instruct",
30
+ max_tokens=1024,
31
+ temperature=0.3,
32
  )
33
 
34
+
35
+ # -------------------- PROMPTS --------------------
36
+
37
  with open("prompts.yaml", "r") as f:
38
  prompt_templates = yaml.safe_load(f)
39
 
40
+
41
+ # -------------------- AGENT --------------------
42
+
43
  agent = CodeAgent(
44
  model=model,
45
+ tools=[
46
+ final_answer,
47
+ image_generation_tool
48
+ ],
49
+ max_steps=4,
50
+ verbosity_level=1,
51
  prompt_templates=prompt_templates
52
  )
53
 
54
+
55
+ # -------------------- UI --------------------
56
+
57
  GradioUI(agent).launch()