Thanh Vinh Vo
commited on
Commit
·
90b22e9
1
Parent(s):
9440a2b
update
Browse files
app.py
CHANGED
|
@@ -60,10 +60,6 @@ def get_image_content(file_name: str) -> Image.Image | None:
|
|
| 60 |
class BasicAgent:
|
| 61 |
def __init__(self):
|
| 62 |
print("BasicAgent initialized.")
|
| 63 |
-
model = InferenceClientModel(
|
| 64 |
-
model_id="meta-llama/Llama-3.2-11B-Vision-Instruct",
|
| 65 |
-
)
|
| 66 |
-
|
| 67 |
self.multimodal_agent = CodeAgent(
|
| 68 |
tools=[VisitWebpageTool(), DuckDuckGoSearchTool(), get_image_content],
|
| 69 |
model=InferenceClientModel(
|
|
@@ -85,12 +81,34 @@ class BasicAgent:
|
|
| 85 |
max_steps=10,
|
| 86 |
)
|
| 87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
self.manager_agent = CodeAgent(
|
| 89 |
model=InferenceClientModel(
|
| 90 |
-
"deepseek-ai/DeepSeek-R1",
|
|
|
|
| 91 |
),
|
| 92 |
tools=[get_image_content],
|
| 93 |
-
managed_agents=[self.multimodal_agent],
|
| 94 |
additional_authorized_imports=[
|
| 95 |
"requests",
|
| 96 |
"bs4",
|
|
@@ -102,7 +120,6 @@ class BasicAgent:
|
|
| 102 |
"chess",
|
| 103 |
],
|
| 104 |
planning_interval=5,
|
| 105 |
-
verbosity_level=2,
|
| 106 |
max_steps=15,
|
| 107 |
)
|
| 108 |
|
|
@@ -110,12 +127,13 @@ class BasicAgent:
|
|
| 110 |
print(f"Agent received question: {question}")
|
| 111 |
prompt = f"""
|
| 112 |
Answer the following question:
|
| 113 |
-
"{question} {"
|
| 114 |
|
| 115 |
Please follow hints below:
|
| 116 |
1. `wikipedia` Python package is provided to interact with Wikipedia.
|
| 117 |
2. `pandas` Python package is provided. Please use it when there is need to extract structured data (such as tables) from HTML content.
|
| 118 |
-
3.
|
|
|
|
| 119 |
"""
|
| 120 |
result = self.manager_agent.run(prompt)
|
| 121 |
print(f"Agent responded with: {result}")
|
|
|
|
| 60 |
class BasicAgent:
|
| 61 |
def __init__(self):
|
| 62 |
print("BasicAgent initialized.")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
self.multimodal_agent = CodeAgent(
|
| 64 |
tools=[VisitWebpageTool(), DuckDuckGoSearchTool(), get_image_content],
|
| 65 |
model=InferenceClientModel(
|
|
|
|
| 81 |
max_steps=10,
|
| 82 |
)
|
| 83 |
|
| 84 |
+
self.code_agent = CodeAgent(
|
| 85 |
+
tools=[VisitWebpageTool(), DuckDuckGoSearchTool(), get_image_content],
|
| 86 |
+
model=InferenceClientModel(
|
| 87 |
+
model_id="Qwen/Qwen2.5-Coder-32B-Instruct",
|
| 88 |
+
),
|
| 89 |
+
additional_authorized_imports=[
|
| 90 |
+
"requests",
|
| 91 |
+
"bs4",
|
| 92 |
+
"markdownify",
|
| 93 |
+
"wikipedia",
|
| 94 |
+
"pandas",
|
| 95 |
+
"io",
|
| 96 |
+
"PIL",
|
| 97 |
+
"chess",
|
| 98 |
+
],
|
| 99 |
+
name="code_agent",
|
| 100 |
+
description="I am strong at writing code.",
|
| 101 |
+
verbosity_level=0,
|
| 102 |
+
max_steps=10,
|
| 103 |
+
)
|
| 104 |
+
|
| 105 |
self.manager_agent = CodeAgent(
|
| 106 |
model=InferenceClientModel(
|
| 107 |
+
"deepseek-ai/DeepSeek-R1",
|
| 108 |
+
provider="together"
|
| 109 |
),
|
| 110 |
tools=[get_image_content],
|
| 111 |
+
managed_agents=[self.multimodal_agent, self.code_agent],
|
| 112 |
additional_authorized_imports=[
|
| 113 |
"requests",
|
| 114 |
"bs4",
|
|
|
|
| 120 |
"chess",
|
| 121 |
],
|
| 122 |
planning_interval=5,
|
|
|
|
| 123 |
max_steps=15,
|
| 124 |
)
|
| 125 |
|
|
|
|
| 127 |
print(f"Agent received question: {question}")
|
| 128 |
prompt = f"""
|
| 129 |
Answer the following question:
|
| 130 |
+
"{question} {"The file name is: " if file_name else ""} {file_name}"
|
| 131 |
|
| 132 |
Please follow hints below:
|
| 133 |
1. `wikipedia` Python package is provided to interact with Wikipedia.
|
| 134 |
2. `pandas` Python package is provided. Please use it when there is need to extract structured data (such as tables) from HTML content.
|
| 135 |
+
3. `chess` Python package is provided. Please use it when there is need to solve chess problems.
|
| 136 |
+
4. Please take the question literally! Do not add any additional information or assumptions.
|
| 137 |
"""
|
| 138 |
result = self.manager_agent.run(prompt)
|
| 139 |
print(f"Agent responded with: {result}")
|