Dkapsis commited on
Commit
7845350
·
1 Parent(s): 25a3b4b

test cargo

Browse files
Files changed (4) hide show
  1. agent.py +22 -22
  2. app.py +11 -8
  3. app_agents/manager_agent.py +5 -3
  4. app_agents/web_agent.py +2 -2
agent.py CHANGED
@@ -1,28 +1,28 @@
1
- import os
2
- from PIL import Image
3
- from smolagents import CodeAgent, HfApiModel, InferenceClientModel
4
 
5
- import tools.tools as tls
6
 
7
- # --- Basic Agent Definition ---
8
- # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
9
 
10
- class BasicAgent:
11
- def __init__(self):
12
- print("BasicAgent initialized.")
13
- def __call__(self, question: str) -> str:
14
- model = HfApiModel(model_id="https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud", provider="together", use_auth_token=True)
15
 
16
- agent = CodeAgent(
17
- tools=[tls.search_tool, tls.calculate_cargo_travel_time],
18
- model=InferenceClientModel(),
19
- additional_authorized_imports=["pandas"],
20
- max_steps=20,
21
- )
22
 
23
- fixed_answer = agent.run(question)
24
 
25
- print(f"Agent received question (first 50 chars): {question[:50]}...")
26
- # fixed_answer = "This is a default answer."
27
- print(f"Agent returning fixed answer: {fixed_answer}")
28
- return str(fixed_answer)
 
1
+ # import os
2
+ # from PIL import Image
3
+ # from smolagents import CodeAgent, HfApiModel, InferenceClientModel
4
 
5
+ # import tools.tools as tls
6
 
7
+ # # --- Basic Agent Definition ---
8
+ # # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
9
 
10
+ # class BasicAgent:
11
+ # def __init__(self):
12
+ # print("BasicAgent initialized.")
13
+ # def __call__(self, question: str) -> str:
14
+ # model = HfApiModel(model_id="https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud", provider="together", use_auth_token=True)
15
 
16
+ # agent = CodeAgent(
17
+ # tools=[tls.search_tool, tls.calculate_cargo_travel_time],
18
+ # model=InferenceClientModel(),
19
+ # additional_authorized_imports=["pandas"],
20
+ # max_steps=20,
21
+ # )
22
 
23
+ # fixed_answer = agent.run(question)
24
 
25
+ # print(f"Agent received question (first 50 chars): {question[:50]}...")
26
+ # # fixed_answer = "This is a default answer."
27
+ # print(f"Agent returning fixed answer: {fixed_answer}")
28
+ # return str(fixed_answer)
app.py CHANGED
@@ -7,7 +7,8 @@ from huggingface_hub import login
7
  from dotenv import load_dotenv
8
 
9
  import agent
10
- import app_agents
 
11
 
12
  # (Keep Constants as is)
13
  # --- Constants ---
@@ -34,7 +35,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
34
 
35
  # 1. Instantiate Agent ( modify this part to create your agent)
36
  try:
37
- agent = BasicAgent()
38
  except Exception as e:
39
  print(f"Error instantiating agent: {e}")
40
  return f"Error initializing agent: {e}", None
@@ -135,14 +136,16 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
135
 
136
  def test_init_agent_for_chat(text_input, history):
137
  # 1. Instantiate Agent ( modify this part to create your agent)
138
- try:
139
- managerAgent = agents.manager_agent
140
- # basicAgent = agent.BasicAgent()
141
- except Exception as e:
142
- print(f"Error instantiating agent: {e}")
143
- return f"Error initializing agent: {e}", None
144
 
145
  manager_agent.visualize()
 
 
146
  # submitted_answer = basicAgent(text_input)
147
 
148
  # return submitted_answer
 
7
  from dotenv import load_dotenv
8
 
9
  import agent
10
+ from app_agents.manager_agent import manager_agent
11
+ # import app_agents.manager_agent as manager_agent
12
 
13
  # (Keep Constants as is)
14
  # --- Constants ---
 
35
 
36
  # 1. Instantiate Agent ( modify this part to create your agent)
37
  try:
38
+ agent = app_agents.manager_agent
39
  except Exception as e:
40
  print(f"Error instantiating agent: {e}")
41
  return f"Error initializing agent: {e}", None
 
136
 
137
  def test_init_agent_for_chat(text_input, history):
138
  # 1. Instantiate Agent ( modify this part to create your agent)
139
+ # try:
140
+ # managerAgent = manager_agent.manager_agent
141
+ # # basicAgent = agent.BasicAgent()
142
+ # except Exception as e:
143
+ # print(f"Error instantiating agent: {e}")
144
+ # return f"Error initializing agent: {e}", None
145
 
146
  manager_agent.visualize()
147
+
148
+ manager_agent.run(text_input)
149
  # submitted_answer = basicAgent(text_input)
150
 
151
  # return submitted_answer
app_agents/manager_agent.py CHANGED
@@ -1,8 +1,10 @@
1
  import os
2
  from smolagents.utils import encode_image_base64, make_image_url
3
- from smolagents import OpenAIServerModel
4
 
5
  import app_agents.web_agent as web_agent
 
 
6
 
7
  def check_reasoning_and_plot(final_answer, agent_memory):
8
  multimodal_model = OpenAIServerModel("gpt-4o", max_tokens=8096)
@@ -39,8 +41,8 @@ def check_reasoning_and_plot(final_answer, agent_memory):
39
 
40
  manager_agent = CodeAgent(
41
  model=InferenceClientModel("deepseek-ai/DeepSeek-R1", provider="together", max_tokens=8096),
42
- tools=[calculate_cargo_travel_time],
43
- managed_agents=[web_agent.agent],
44
  additional_authorized_imports=[
45
  "geopandas",
46
  "plotly",
 
1
  import os
2
  from smolagents.utils import encode_image_base64, make_image_url
3
+ from smolagents import OpenAIServerModel, CodeAgent, InferenceClientModel
4
 
5
  import app_agents.web_agent as web_agent
6
+ from app_agents.web_agent import web_agent
7
+ import app_tools.tools as agent_tools
8
 
9
  def check_reasoning_and_plot(final_answer, agent_memory):
10
  multimodal_model = OpenAIServerModel("gpt-4o", max_tokens=8096)
 
41
 
42
  manager_agent = CodeAgent(
43
  model=InferenceClientModel("deepseek-ai/DeepSeek-R1", provider="together", max_tokens=8096),
44
+ tools=[agent_tools.calculate_cargo_travel_time],
45
+ managed_agents=[web_agent],
46
  additional_authorized_imports=[
47
  "geopandas",
48
  "plotly",
app_agents/web_agent.py CHANGED
@@ -2,9 +2,9 @@ from smolagents import CodeAgent, DuckDuckGoSearchTool, InferenceClientModel, Vi
2
 
3
  model = InferenceClientModel(model_id="Qwen/Qwen2.5-Coder-32B-Instruct", provider="together")
4
 
5
- agent = CodeAgent(
6
  model=model,
7
- tools=[GoogleSearchTool(), VisitWebpageTool()],
8
  additional_authorized_imports=["pandas"],
9
  name="web_agent",
10
  description="Browses the web to find information",
 
2
 
3
  model = InferenceClientModel(model_id="Qwen/Qwen2.5-Coder-32B-Instruct", provider="together")
4
 
5
+ web_agent = CodeAgent(
6
  model=model,
7
+ tools=[DuckDuckGoSearchTool(), VisitWebpageTool()],
8
  additional_authorized_imports=["pandas"],
9
  name="web_agent",
10
  description="Browses the web to find information",