Skip to content

Commit 2e034d9

Browse files
authored
Merge branch 'main' into tj-scripts
2 parents c9a7426 + 106a169 commit 2e034d9

19 files changed

+116
-63
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ You can run OWL agent with your own task by modifying the `examples/run.py` scri
386386

387387
```python
388388
# Define your own task
389-
question = "Task description here."
389+
task = "Task description here."
390390

391391
society = construct_society(question)
392392
answer, chat_history, token_count = run_society(society)
@@ -398,7 +398,7 @@ For uploading files, simply provide the file path along with your question:
398398

399399
```python
400400
# Task with a local file (e.g., file path: `tmp/example.docx`)
401-
question = "What is in the given DOCX file? Here is the file path: tmp/example.docx"
401+
task = "What is in the given DOCX file? Here is the file path: tmp/example.docx"
402402

403403
society = construct_society(question)
404404
answer, chat_history, token_count = run_society(society)

README_zh.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ python examples/run_ollama.py
379379

380380
```python
381381
# Define your own task
382-
question = "Task description here."
382+
task = "Task description here."
383383

384384
society = construct_society(question)
385385
answer, chat_history, token_count = run_society(society)
@@ -391,7 +391,7 @@ print(f"\033[94mAnswer: {answer}\033[0m")
391391

392392
```python
393393
# 处理本地文件(例如,文件路径为 `tmp/example.docx`)
394-
question = "给定的 DOCX 文件中有什么内容?文件路径如下:tmp/example.docx"
394+
task = "给定的 DOCX 文件中有什么内容?文件路径如下:tmp/example.docx"
395395

396396
society = construct_society(question)
397397
answer, chat_history, token_count = run_society(society)

examples/run.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
# See the License for the specific language governing permissions and
1212
# limitations under the License.
1313
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
14+
import sys
15+
import pathlib
1416
from dotenv import load_dotenv
1517
from camel.models import ModelFactory
1618
from camel.toolkits import (
@@ -29,8 +31,6 @@
2931

3032
from owl.utils import run_society, DocumentProcessingToolkit
3133

32-
import pathlib
33-
3434
base_dir = pathlib.Path(__file__).parent.parent
3535
env_path = base_dir / "owl" / ".env"
3636
load_dotenv(dotenv_path=str(env_path))
@@ -60,7 +60,7 @@ def construct_society(question: str) -> RolePlaying:
6060
model_type=ModelType.GPT_4O,
6161
model_config_dict={"temperature": 0},
6262
),
63-
"web": ModelFactory.create(
63+
"browsing": ModelFactory.create(
6464
model_platform=ModelPlatformType.OPENAI,
6565
model_type=ModelType.GPT_4O,
6666
model_config_dict={"temperature": 0},
@@ -91,7 +91,7 @@ def construct_society(question: str) -> RolePlaying:
9191
tools = [
9292
*BrowserToolkit(
9393
headless=False, # Set to True for headless mode (e.g., on remote servers)
94-
web_agent_model=models["web"],
94+
web_agent_model=models["browsing"],
9595
planning_agent_model=models["planning"],
9696
).get_tools(),
9797
*VideoAnalysisToolkit(model=models["video"]).get_tools(),
@@ -130,11 +130,14 @@ def construct_society(question: str) -> RolePlaying:
130130

131131
def main():
132132
r"""Main function to run the OWL system with an example question."""
133-
# Example research question
134-
question = "Navigate to Amazon.com and identify one product that is attractive to coders. Please provide me with the product name and price. No need to verify your answer."
133+
# Default research question
134+
default_task = "Navigate to Amazon.com and identify one product that is attractive to coders. Please provide me with the product name and price. No need to verify your answer."
135+
136+
# Override default task if command line argument is provided
137+
task = sys.argv[1] if len(sys.argv) > 1 else default_task
135138

136139
# Construct and run the society
137-
society = construct_society(question)
140+
society = construct_society(task)
138141
answer, chat_history, token_count = run_society(society)
139142

140143
# Output the result

examples/run_azure_openai.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# limitations under the License.
1313
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
1414
import os
15+
import sys
1516
from dotenv import load_dotenv
1617
from camel.configs import ChatGPTConfig
1718
from camel.models import ModelFactory
@@ -58,7 +59,7 @@ def construct_society(question: str) -> OwlRolePlaying:
5859
models = {
5960
"user": ModelFactory.create(**base_model_config),
6061
"assistant": ModelFactory.create(**base_model_config),
61-
"web": ModelFactory.create(**base_model_config),
62+
"browsing": ModelFactory.create(**base_model_config),
6263
"planning": ModelFactory.create(**base_model_config),
6364
"image": ModelFactory.create(**base_model_config),
6465
}
@@ -67,7 +68,7 @@ def construct_society(question: str) -> OwlRolePlaying:
6768
tools = [
6869
*BrowserToolkit(
6970
headless=False, # Set to True for headless mode (e.g., on remote servers)
70-
web_agent_model=models["web"],
71+
web_agent_model=models["browsing"],
7172
planning_agent_model=models["planning"],
7273
).get_tools(),
7374
*CodeExecutionToolkit(sandbox="subprocess", verbose=True).get_tools(),
@@ -104,10 +105,14 @@ def construct_society(question: str) -> OwlRolePlaying:
104105
def main():
105106
r"""Main function to run the OWL system with Azure OpenAI."""
106107
# Example question
107-
question = "Navigate to Amazon.com and identify one product that is attractive to coders. Please provide me with the product name and price. No need to verify your answer."
108+
default_task = "Navigate to Amazon.com and identify one product that is attractive to coders. Please provide me with the product name and price. No need to verify your answer."
109+
110+
# Override default task if command line argument is provided
111+
task = sys.argv[1] if len(sys.argv) > 1 else default_task
108112

109113
# Construct and run the society
110-
society = construct_society(question)
114+
society = construct_society(task)
115+
111116
answer, chat_history, token_count = run_society(society)
112117

113118
# Output the result

examples/run_cli.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def construct_society() -> RolePlaying:
110110
model_type=selected_model_type,
111111
model_config_dict={"temperature": 0},
112112
),
113-
"web": ModelFactory.create(
113+
"browsing": ModelFactory.create(
114114
model_platform=selected_model_platform,
115115
model_type=selected_model_type,
116116
model_config_dict={"temperature": 0},
@@ -141,9 +141,8 @@ def construct_society() -> RolePlaying:
141141
tools = [
142142
*BrowserToolkit(
143143
headless=False,
144-
web_agent_model=models["web"],
144+
web_agent_model=models["browsing"],
145145
planning_agent_model=models["planning"],
146-
output_language="Chinese",
147146
).get_tools(),
148147
*VideoAnalysisToolkit(model=models["video"]).get_tools(),
149148
*CodeExecutionToolkit(sandbox="subprocess", verbose=True).get_tools(),

examples/run_deepseek_zh.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# You can obtain your API key from DeepSeek platform: https://platform.deepseek.com/api_keys
1818
# Set it as DEEPSEEK_API_KEY="your-api-key" in your .env file or add it to your environment variables
1919

20-
20+
import sys
2121
from dotenv import load_dotenv
2222

2323
from camel.models import ModelFactory
@@ -102,10 +102,14 @@ def construct_society(question: str) -> RolePlaying:
102102
def main():
103103
r"""Main function to run the OWL system with an example question."""
104104
# Example research question
105-
question = "搜索OWL项目最近的新闻并生成一篇报告,最后保存到本地。"
105+
default_task = "搜索OWL项目最近的新闻并生成一篇报告,最后保存到本地。"
106+
107+
# Override default task if command line argument is provided
108+
task = sys.argv[1] if len(sys.argv) > 1 else default_task
106109

107110
# Construct and run the society
108-
society = construct_society(question)
111+
society = construct_society(task)
112+
109113
answer, chat_history, token_count = run_society(society)
110114

111115
# Output the result

examples/run_gaia_roleplaying.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def main():
7171
model_type=ModelType.GPT_4O,
7272
model_config_dict=ChatGPTConfig(temperature=0, top_p=1).as_dict(),
7373
),
74-
"web": ModelFactory.create(
74+
"browsing": ModelFactory.create(
7575
model_platform=ModelPlatformType.OPENAI,
7676
model_type=ModelType.GPT_4O,
7777
model_config_dict=ChatGPTConfig(temperature=0, top_p=1).as_dict(),
@@ -97,7 +97,7 @@ def main():
9797
tools = [
9898
*BrowserToolkit(
9999
headless=False, # Set to True for headless mode (e.g., on remote servers)
100-
web_agent_model=models["web"],
100+
web_agent_model=models["browsing"],
101101
planning_agent_model=models["planning"],
102102
).get_tools(),
103103
*VideoAnalysisToolkit(

examples/run_groq.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
3. Run with: python -m examples.run_groq
2727
"""
2828

29+
import sys
2930
from dotenv import load_dotenv
3031
from camel.models import ModelFactory
3132
from camel.toolkits import (
@@ -70,7 +71,7 @@ def construct_society(question: str) -> OwlRolePlaying:
7071
model_type=ModelType.GROQ_LLAMA_3_3_70B, # Main assistant needs tool capability
7172
model_config_dict={"temperature": 0},
7273
),
73-
"web": ModelFactory.create(
74+
"browsing": ModelFactory.create(
7475
model_platform=ModelPlatformType.GROQ,
7576
model_type=ModelType.GROQ_LLAMA_3_3_70B, # Web browsing requires tool usage
7677
model_config_dict={"temperature": 0},
@@ -101,7 +102,7 @@ def construct_society(question: str) -> OwlRolePlaying:
101102
tools = [
102103
*BrowserToolkit(
103104
headless=False, # Set to True for headless mode (e.g., on remote servers)
104-
web_agent_model=models["web"],
105+
web_agent_model=models["browsing"],
105106
planning_agent_model=models["planning"],
106107
).get_tools(),
107108
*VideoAnalysisToolkit(model=models["video"]).get_tools(),
@@ -141,13 +142,18 @@ def construct_society(question: str) -> OwlRolePlaying:
141142
def main():
142143
r"""Main function to run the OWL system with an example question."""
143144
# Example research question
144-
question = "Navigate to Amazon.com and identify one product that is attractive to coders. Please provide me with the product name and price. No need to verify your answer."
145+
default_task = "Navigate to Amazon.com and identify one product that is attractive to coders. Please provide me with the product name and price. No need to verify your answer."
145146

146147
# Construct and run the society
147148
# Note: This configuration uses GROQ_LLAMA_3_3_70B for tool-intensive roles (assistant, web, planning, video, image)
148149
# and GROQ_MIXTRAL_8_7B for document processing. GROQ_LLAMA_3_1_8B is used only for the user role
149150
# which doesn't require tool usage capabilities.
150-
society = construct_society(question)
151+
152+
# Override default task if command line argument is provided
153+
task = sys.argv[1] if len(sys.argv) > 1 else default_task
154+
155+
# Construct and run the society
156+
society = construct_society(task)
151157
answer, chat_history, token_count = run_society(society)
152158

153159
# Output the result

examples/run_mcp.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"""
7474

7575
import asyncio
76+
import sys
7677
from pathlib import Path
7778
from typing import List
7879

@@ -146,15 +147,19 @@ async def main():
146147
try:
147148
await mcp_toolkit.connect()
148149

149-
question = (
150+
# Default task
151+
default_task = (
150152
"I'd like a academic report about Andrew Ng, including "
151153
"his research direction, published papers (At least 3),"
152154
" institutions, etc. "
153155
)
154156

157+
# Override default task if command line argument is provided
158+
task = sys.argv[1] if len(sys.argv) > 1 else default_task
159+
155160
# Connect to all MCP toolkits
156161
tools = [*mcp_toolkit.get_tools()]
157-
society = await construct_society(question, tools)
162+
society = await construct_society(task, tools)
158163
answer, chat_history, token_count = await arun_society(society)
159164
print(f"\033[94mAnswer: {answer}\033[0m")
160165

examples/run_mini.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# See the License for the specific language governing permissions and
1212
# limitations under the License.
1313
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
14+
import sys
1415
from dotenv import load_dotenv
1516

1617
from camel.models import ModelFactory
@@ -58,7 +59,7 @@ def construct_society(question: str) -> RolePlaying:
5859
model_type=ModelType.GPT_4O,
5960
model_config_dict={"temperature": 0},
6061
),
61-
"web": ModelFactory.create(
62+
"browsing": ModelFactory.create(
6263
model_platform=ModelPlatformType.OPENAI,
6364
model_type=ModelType.GPT_4O,
6465
model_config_dict={"temperature": 0},
@@ -74,7 +75,7 @@ def construct_society(question: str) -> RolePlaying:
7475
tools = [
7576
*BrowserToolkit(
7677
headless=False, # Set to True for headless mode (e.g., on remote servers)
77-
web_agent_model=models["web"],
78+
web_agent_model=models["browsing"],
7879
planning_agent_model=models["planning"],
7980
).get_tools(),
8081
SearchToolkit().search_duckduckgo,
@@ -106,11 +107,14 @@ def construct_society(question: str) -> RolePlaying:
106107

107108
def main():
108109
r"""Main function to run the OWL system with an example question."""
109-
# Example research question
110-
question = "Navigate to Amazon.com and identify one product that is attractive to coders. Please provide me with the product name and price. No need to verify your answer."
110+
# Default research question
111+
default_task = "Navigate to Amazon.com and identify one product that is attractive to coders. Please provide me with the product name and price. No need to verify your answer."
112+
113+
# Override default task if command line argument is provided
114+
task = sys.argv[1] if len(sys.argv) > 1 else default_task
111115

112116
# Construct and run the society
113-
society = construct_society(question)
117+
society = construct_society(task)
114118
answer, chat_history, token_count = run_society(society)
115119

116120
# Output the result

0 commit comments

Comments
 (0)