DirtyFock commited on
Commit
6dac870
·
1 Parent(s): 28a72c5

Use predefined manager_agent

Browse files
Files changed (3) hide show
  1. app.py +2 -19
  2. src/agents.py +68 -0
  3. src/models.py +1 -1
app.py CHANGED
@@ -3,16 +3,9 @@ import requests
3
 
4
  import gradio as gr
5
  import pandas as pd
6
- from smolagents import (
7
- DuckDuckGoSearchTool,
8
- WikipediaSearchTool,
9
- VisitWebpageTool,
10
- ToolCallingAgent,
11
- )
12
  import openlit
13
 
14
- from src.models import OllamaModel
15
- from src.tools_registry import ToolsRegistry
16
 
17
  # (Keep Constants as is)
18
  # --- Constants ---
@@ -45,17 +38,7 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
45
 
46
  # 1. Instantiate Agent ( modify this part to create your agent)
47
  try:
48
- agent = ToolCallingAgent(
49
- tools=[
50
- DuckDuckGoSearchTool(),
51
- VisitWebpageTool(),
52
- WikipediaSearchTool(content_type="text"),
53
- ],
54
- max_steps=20,
55
- model=OllamaModel(model_id="qwen3:14b", tools_registry=ToolsRegistry),
56
- planning_interval=5,
57
- add_base_tools=True,
58
- )
59
  except Exception as e:
60
  print(f"Error instantiating agent: {e}")
61
  return f"Error initializing agent: {e}", None
 
3
 
4
  import gradio as gr
5
  import pandas as pd
 
 
 
 
 
 
6
  import openlit
7
 
8
+ from src.agents import manager_agent
 
9
 
10
  # (Keep Constants as is)
11
  # --- Constants ---
 
38
 
39
  # 1. Instantiate Agent ( modify this part to create your agent)
40
  try:
41
+ agent = manager_agent
 
 
 
 
 
 
 
 
 
 
42
  except Exception as e:
43
  print(f"Error instantiating agent: {e}")
44
  return f"Error initializing agent: {e}", None
src/agents.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents import (
2
+ DuckDuckGoSearchTool,
3
+ VisitWebpageTool,
4
+ ToolCallingAgent,
5
+ CodeAgent,
6
+ )
7
+
8
+ from src.models import OllamaModel
9
+ from src.tools_registry import ToolsRegistry
10
+
11
+
12
+ def check_reasoning_and_answer(final_answer, agent_memory):
13
+ multimodal_model = OllamaModel(model_id="qwen3:14b", tools_registry=ToolsRegistry)
14
+ prompt = (
15
+ "You are a LLM which task is to check the summary of a reasoning and an answer given by other managed LLMs when queried to realise a task."
16
+ "Here is a user-given task and the agent steps: "
17
+ f"{agent_memory.get_succinct_steps()}."
18
+ "Here is the final answer:"
19
+ f"{final_answer}"
20
+ "Please check that the reasoning process and the answer are correct: do they correctly answer the given task?"
21
+ "To help you realize this task, here is some guidances:"
22
+ "1. First, list reasons why yes/no"
23
+ "2. Then check the answer is either a string (one or a few words), a number, or a comma separated list of strings or floats, unless specified otherwise. There is only one correct answer. "
24
+ "3. Conclude writing your final decision: PASS in caps lock if it is satisfactory, FAIL if it is not."
25
+ "4. Don't be harsh, if the task couldn't achieve a perfect reasoning because direct data couldn't be found, just PASS in caps lock."
26
+ )
27
+ messages = [
28
+ {
29
+ "role": "user",
30
+ "content": [
31
+ {
32
+ "type": "text",
33
+ "text": prompt,
34
+ }
35
+ ],
36
+ }
37
+ ]
38
+ output = multimodal_model(messages).content
39
+ print("Feedback: ", output)
40
+
41
+ if "FAIL" in output:
42
+ raise Exception(output)
43
+
44
+ return True
45
+
46
+
47
+ web_agent = ToolCallingAgent(
48
+ tools=[
49
+ DuckDuckGoSearchTool(),
50
+ VisitWebpageTool(),
51
+ ],
52
+ model=OllamaModel(model_id="qwen3:14b", tools_registry=ToolsRegistry),
53
+ name="web_agent",
54
+ description="Browses the web to find information",
55
+ verbosity_level=0,
56
+ max_steps=10,
57
+ )
58
+
59
+
60
+ manager_agent = CodeAgent(
61
+ model=OllamaModel(model_id="qwen3:14b"),
62
+ tools=[],
63
+ managed_agents=[web_agent],
64
+ planning_interval=5,
65
+ verbosity_level=2,
66
+ final_answer_checks=[check_reasoning_and_answer],
67
+ max_steps=15,
68
+ )
src/models.py CHANGED
@@ -9,7 +9,7 @@ from ollama import Message as OllamaMessage
9
 
10
  from tools_registry import ToolsRegistry
11
 
12
- DEFAULT_NUM_CTX = 8192
13
 
14
 
15
  class OllamaModel(ApiModel):
 
9
 
10
  from tools_registry import ToolsRegistry
11
 
12
+ DEFAULT_NUM_CTX = 16384
13
 
14
 
15
  class OllamaModel(ApiModel):