Sandiago21 commited on
Commit
dd5b951
·
verified ·
1 Parent(s): f52d6bf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -14
app.py CHANGED
@@ -29,33 +29,49 @@ class BasicAgent:
29
 
30
 
31
  model = TransformersModel(
32
- # model_id="microsoft/phi-2", # ✅ small, reliable
33
- model_id="TinyLlama/TinyLlama-1.1B-Chat-v1.0",
34
- max_new_tokens=1024,
35
- temperature=0.0,
 
36
  )
37
 
38
  with open("prompts.yaml", 'r') as stream:
39
  prompt_templates = yaml.safe_load(stream)
40
 
41
- agent = CodeAgent(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  model=model,
43
- # tools=[DuckDuckGoSearchTool()],
44
- tools=[],
45
  max_steps=5,
46
  verbosity_level=1,
47
- grammar=None,
48
- planning_interval=None,
49
- name=None,
50
- description=None,
51
- prompt_templates=prompt_templates
52
  )
53
 
54
  agent_answer = agent.run(question)
55
 
56
- print(f"Agent Answer: {agent_answer}")
57
 
58
- return fixed_answer
59
 
60
  def run_and_submit_all( profile: gr.OAuthProfile | None):
61
  """
 
29
 
30
 
31
  model = TransformersModel(
32
+ # model_id="TinyLlama/TinyLlama-1.1B-Chat-v1.0",
33
+ # model_id="mistralai/Mistral-7B-Instruct-v0.2",
34
+ model_id="Qwen/Qwen2.5-Coder-7B-Instruct",
35
+ max_new_tokens=128,
36
+ temperature=0.1,
37
  )
38
 
39
  with open("prompts.yaml", 'r') as stream:
40
  prompt_templates = yaml.safe_load(stream)
41
 
42
+ prompt_templates["final_answer"] = {
43
+ "pre_messages": """You have reached the end of the task.
44
+
45
+ Review your reasoning and ensure that your result is correct.
46
+ You must now return the final answer using the `final_answer()` tool.
47
+
48
+ Do not output plain text — only use the tool.""",
49
+
50
+ "post_messages": """Write Python code that calls:
51
+
52
+ final_answer(result)
53
+
54
+ Where `result` is the final answer to the task.
55
+
56
+ Do not print anything else.
57
+ Do not return explanations.
58
+ Only call `final_answer` and do a final reason to make sure that you answer the question clearly and directly without additional information if not requested."""
59
+ }
60
+
61
+ agent_with_tools = CodeAgent(
62
  model=model,
63
+ tools=[DuckDuckGoSearchTool(),],
 
64
  max_steps=5,
65
  verbosity_level=1,
66
+ additional_authorized_imports=["pandas", "wiki", 'random', 'time', 'itertools', 'statistics', 'queue', 'math', 'collections', 'datetime', 'unicodedata', 're', 'stat'],
67
+ prompt_templates=prompt_templates,
 
 
 
68
  )
69
 
70
  agent_answer = agent.run(question)
71
 
72
+ # print(f"Agent Answer: {agent_answer}")
73
 
74
+ return agent_answer
75
 
76
  def run_and_submit_all( profile: gr.OAuthProfile | None):
77
  """