Commit
·
d557cc1
1
Parent(s):
0cc62b6
add FileWriteToolkit to example
Browse files- owl/run.py +2 -0
- owl/run_deepseek_zh.py +2 -0
- owl/run_gaia_roleplaying.py +2 -0
- owl/run_mini.py +2 -0
- owl/run_openai_compatiable_model.py +2 -0
- owl/run_qwen_mini_zh.py +2 -1
- owl/run_qwen_zh.py +2 -0
- owl/run_write_files.py +0 -144
owl/run.py
CHANGED
@@ -21,6 +21,7 @@ from camel.toolkits import (
|
|
21 |
SearchToolkit,
|
22 |
VideoAnalysisToolkit,
|
23 |
WebToolkit,
|
|
|
24 |
)
|
25 |
from camel.types import ModelPlatformType, ModelType
|
26 |
from camel.logger import set_log_level
|
@@ -97,6 +98,7 @@ def construct_society(question: str) -> OwlRolePlaying:
|
|
97 |
SearchToolkit().search_wiki,
|
98 |
*ExcelToolkit().get_tools(),
|
99 |
*DocumentProcessingToolkit(model=models["document"]).get_tools(),
|
|
|
100 |
]
|
101 |
|
102 |
# Configure agent roles and parameters
|
|
|
21 |
SearchToolkit,
|
22 |
VideoAnalysisToolkit,
|
23 |
WebToolkit,
|
24 |
+
FileWriteToolkit,
|
25 |
)
|
26 |
from camel.types import ModelPlatformType, ModelType
|
27 |
from camel.logger import set_log_level
|
|
|
98 |
SearchToolkit().search_wiki,
|
99 |
*ExcelToolkit().get_tools(),
|
100 |
*DocumentProcessingToolkit(model=models["document"]).get_tools(),
|
101 |
+
*FileWriteToolkit(output_dir="./").get_tools(),
|
102 |
]
|
103 |
|
104 |
# Configure agent roles and parameters
|
owl/run_deepseek_zh.py
CHANGED
@@ -26,6 +26,7 @@ from camel.toolkits import (
|
|
26 |
CodeExecutionToolkit,
|
27 |
ExcelToolkit,
|
28 |
SearchToolkit,
|
|
|
29 |
)
|
30 |
from camel.types import ModelPlatformType, ModelType
|
31 |
|
@@ -95,6 +96,7 @@ def construct_society(question: str) -> OwlRolePlaying:
|
|
95 |
SearchToolkit().search_wiki,
|
96 |
*ExcelToolkit().get_tools(),
|
97 |
*DocumentProcessingToolkit(model=models["document"]).get_tools(),
|
|
|
98 |
]
|
99 |
|
100 |
# Configure agent roles and parameters
|
|
|
26 |
CodeExecutionToolkit,
|
27 |
ExcelToolkit,
|
28 |
SearchToolkit,
|
29 |
+
FileWriteToolkit,
|
30 |
)
|
31 |
from camel.types import ModelPlatformType, ModelType
|
32 |
|
|
|
96 |
SearchToolkit().search_wiki,
|
97 |
*ExcelToolkit().get_tools(),
|
98 |
*DocumentProcessingToolkit(model=models["document"]).get_tools(),
|
99 |
+
*FileWriteToolkit(output_dir="./").get_tools(),
|
100 |
]
|
101 |
|
102 |
# Configure agent roles and parameters
|
owl/run_gaia_roleplaying.py
CHANGED
@@ -27,6 +27,7 @@ from camel.toolkits import (
|
|
27 |
SearchToolkit,
|
28 |
VideoAnalysisToolkit,
|
29 |
WebToolkit,
|
|
|
30 |
)
|
31 |
from camel.types import ModelPlatformType, ModelType
|
32 |
from camel.configs import ChatGPTConfig
|
@@ -101,6 +102,7 @@ def main():
|
|
101 |
*ImageAnalysisToolkit(model=models["image"]).get_tools(),
|
102 |
*SearchToolkit().get_tools(),
|
103 |
*ExcelToolkit().get_tools(),
|
|
|
104 |
]
|
105 |
|
106 |
# Configure agent roles and parameters
|
|
|
27 |
SearchToolkit,
|
28 |
VideoAnalysisToolkit,
|
29 |
WebToolkit,
|
30 |
+
FileWriteToolkit,
|
31 |
)
|
32 |
from camel.types import ModelPlatformType, ModelType
|
33 |
from camel.configs import ChatGPTConfig
|
|
|
102 |
*ImageAnalysisToolkit(model=models["image"]).get_tools(),
|
103 |
*SearchToolkit().get_tools(),
|
104 |
*ExcelToolkit().get_tools(),
|
105 |
+
*FileWriteToolkit(output_dir="./").get_tools(),
|
106 |
]
|
107 |
|
108 |
# Configure agent roles and parameters
|
owl/run_mini.py
CHANGED
@@ -17,6 +17,7 @@ from camel.models import ModelFactory
|
|
17 |
from camel.toolkits import (
|
18 |
SearchToolkit,
|
19 |
WebToolkit,
|
|
|
20 |
)
|
21 |
from camel.types import ModelPlatformType, ModelType
|
22 |
from camel.logger import set_log_level
|
@@ -71,6 +72,7 @@ def construct_society(question: str) -> OwlRolePlaying:
|
|
71 |
).get_tools(),
|
72 |
SearchToolkit().search_duckduckgo,
|
73 |
SearchToolkit().search_wiki,
|
|
|
74 |
]
|
75 |
|
76 |
# Configure agent roles and parameters
|
|
|
17 |
from camel.toolkits import (
|
18 |
SearchToolkit,
|
19 |
WebToolkit,
|
20 |
+
FileWriteToolkit,
|
21 |
)
|
22 |
from camel.types import ModelPlatformType, ModelType
|
23 |
from camel.logger import set_log_level
|
|
|
72 |
).get_tools(),
|
73 |
SearchToolkit().search_duckduckgo,
|
74 |
SearchToolkit().search_wiki,
|
75 |
+
*FileWriteToolkit(output_dir="./").get_tools(),
|
76 |
]
|
77 |
|
78 |
# Configure agent roles and parameters
|
owl/run_openai_compatiable_model.py
CHANGED
@@ -21,6 +21,7 @@ from camel.toolkits import (
|
|
21 |
ImageAnalysisToolkit,
|
22 |
SearchToolkit,
|
23 |
WebToolkit,
|
|
|
24 |
)
|
25 |
from camel.types import ModelPlatformType
|
26 |
|
@@ -95,6 +96,7 @@ def construct_society(question: str) -> OwlRolePlaying:
|
|
95 |
SearchToolkit().search_google, # Comment this out if you don't have google search
|
96 |
SearchToolkit().search_wiki,
|
97 |
*ExcelToolkit().get_tools(),
|
|
|
98 |
]
|
99 |
|
100 |
# Configure agent roles and parameters
|
|
|
21 |
ImageAnalysisToolkit,
|
22 |
SearchToolkit,
|
23 |
WebToolkit,
|
24 |
+
FileWriteToolkit,
|
25 |
)
|
26 |
from camel.types import ModelPlatformType
|
27 |
|
|
|
96 |
SearchToolkit().search_google, # Comment this out if you don't have google search
|
97 |
SearchToolkit().search_wiki,
|
98 |
*ExcelToolkit().get_tools(),
|
99 |
+
*FileWriteToolkit(output_dir="./").get_tools(),
|
100 |
]
|
101 |
|
102 |
# Configure agent roles and parameters
|
owl/run_qwen_mini_zh.py
CHANGED
@@ -19,7 +19,7 @@
|
|
19 |
from dotenv import load_dotenv
|
20 |
|
21 |
from camel.models import ModelFactory
|
22 |
-
from camel.toolkits import WebToolkit, SearchToolkit
|
23 |
from camel.types import ModelPlatformType, ModelType
|
24 |
|
25 |
from utils import OwlRolePlaying, run_society
|
@@ -69,6 +69,7 @@ def construct_society(question: str) -> OwlRolePlaying:
|
|
69 |
output_language="Chinese",
|
70 |
).get_tools(),
|
71 |
SearchToolkit().search_duckduckgo,
|
|
|
72 |
]
|
73 |
|
74 |
user_role_name = "user"
|
|
|
19 |
from dotenv import load_dotenv
|
20 |
|
21 |
from camel.models import ModelFactory
|
22 |
+
from camel.toolkits import WebToolkit, SearchToolkit, FileWriteToolkit
|
23 |
from camel.types import ModelPlatformType, ModelType
|
24 |
|
25 |
from utils import OwlRolePlaying, run_society
|
|
|
69 |
output_language="Chinese",
|
70 |
).get_tools(),
|
71 |
SearchToolkit().search_duckduckgo,
|
72 |
+
*FileWriteToolkit(output_dir="./").get_tools(),
|
73 |
]
|
74 |
|
75 |
user_role_name = "user"
|
owl/run_qwen_zh.py
CHANGED
@@ -25,6 +25,7 @@ from camel.toolkits import (
|
|
25 |
SearchToolkit,
|
26 |
VideoAnalysisToolkit,
|
27 |
WebToolkit,
|
|
|
28 |
)
|
29 |
from camel.types import ModelPlatformType, ModelType
|
30 |
|
@@ -103,6 +104,7 @@ def construct_society(question: str) -> OwlRolePlaying:
|
|
103 |
SearchToolkit().search_wiki,
|
104 |
*ExcelToolkit().get_tools(),
|
105 |
*DocumentProcessingToolkit(model=models["document"]).get_tools(),
|
|
|
106 |
]
|
107 |
|
108 |
# Configure agent roles and parameters
|
|
|
25 |
SearchToolkit,
|
26 |
VideoAnalysisToolkit,
|
27 |
WebToolkit,
|
28 |
+
FileWriteToolkit,
|
29 |
)
|
30 |
from camel.types import ModelPlatformType, ModelType
|
31 |
|
|
|
104 |
SearchToolkit().search_wiki,
|
105 |
*ExcelToolkit().get_tools(),
|
106 |
*DocumentProcessingToolkit(model=models["document"]).get_tools(),
|
107 |
+
*FileWriteToolkit(output_dir="./").get_tools(),
|
108 |
]
|
109 |
|
110 |
# Configure agent roles and parameters
|
owl/run_write_files.py
DELETED
@@ -1,144 +0,0 @@
|
|
1 |
-
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
2 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
3 |
-
# you may not use this file except in compliance with the License.
|
4 |
-
# You may obtain a copy of the License at
|
5 |
-
#
|
6 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
7 |
-
#
|
8 |
-
# Unless required by applicable law or agreed to in writing, software
|
9 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
10 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11 |
-
# See the License for the specific language governing permissions and
|
12 |
-
# limitations under the License.
|
13 |
-
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
14 |
-
from dotenv import load_dotenv
|
15 |
-
from camel.models import ModelFactory
|
16 |
-
import os
|
17 |
-
from camel.toolkits import (
|
18 |
-
AudioAnalysisToolkit,
|
19 |
-
CodeExecutionToolkit,
|
20 |
-
ExcelToolkit,
|
21 |
-
ImageAnalysisToolkit,
|
22 |
-
SearchToolkit,
|
23 |
-
VideoAnalysisToolkit,
|
24 |
-
FileWriteToolkit,
|
25 |
-
WebToolkit,
|
26 |
-
)
|
27 |
-
from camel.types import ModelPlatformType, ModelType
|
28 |
-
from camel.logger import set_log_level
|
29 |
-
|
30 |
-
from utils import OwlRolePlaying, run_society, DocumentProcessingToolkit
|
31 |
-
|
32 |
-
load_dotenv()
|
33 |
-
|
34 |
-
set_log_level(level="DEBUG")
|
35 |
-
|
36 |
-
|
37 |
-
def construct_society(question: str) -> OwlRolePlaying:
|
38 |
-
r"""Construct a society of agents based on the given question.
|
39 |
-
|
40 |
-
Args:
|
41 |
-
question (str): The task or question to be addressed by the society.
|
42 |
-
|
43 |
-
Returns:
|
44 |
-
OwlRolePlaying: A configured society of agents ready to address the question.
|
45 |
-
"""
|
46 |
-
|
47 |
-
# Create models for different components
|
48 |
-
models = {
|
49 |
-
"user": ModelFactory.create(
|
50 |
-
model_platform=ModelPlatformType.OPENAI,
|
51 |
-
model_type=ModelType.GPT_4O,
|
52 |
-
model_config_dict={"temperature": 0},
|
53 |
-
),
|
54 |
-
"assistant": ModelFactory.create(
|
55 |
-
model_platform=ModelPlatformType.OPENAI,
|
56 |
-
model_type=ModelType.GPT_4O,
|
57 |
-
model_config_dict={"temperature": 0},
|
58 |
-
),
|
59 |
-
"web": ModelFactory.create(
|
60 |
-
model_platform=ModelPlatformType.OPENAI,
|
61 |
-
model_type=ModelType.GPT_4O,
|
62 |
-
model_config_dict={"temperature": 0},
|
63 |
-
),
|
64 |
-
"planning": ModelFactory.create(
|
65 |
-
model_platform=ModelPlatformType.OPENAI,
|
66 |
-
model_type=ModelType.GPT_4O,
|
67 |
-
model_config_dict={"temperature": 0},
|
68 |
-
),
|
69 |
-
"video": ModelFactory.create(
|
70 |
-
model_platform=ModelPlatformType.OPENAI,
|
71 |
-
model_type=ModelType.GPT_4O,
|
72 |
-
model_config_dict={"temperature": 0},
|
73 |
-
),
|
74 |
-
"image": ModelFactory.create(
|
75 |
-
model_platform=ModelPlatformType.OPENAI,
|
76 |
-
model_type=ModelType.GPT_4O,
|
77 |
-
model_config_dict={"temperature": 0},
|
78 |
-
),
|
79 |
-
"document": ModelFactory.create(
|
80 |
-
model_platform=ModelPlatformType.OPENAI,
|
81 |
-
model_type=ModelType.GPT_4O,
|
82 |
-
model_config_dict={"temperature": 0},
|
83 |
-
),
|
84 |
-
}
|
85 |
-
output_dir = "./file_write_outputs"
|
86 |
-
os.makedirs(output_dir, exist_ok=True)
|
87 |
-
|
88 |
-
# Initialize the FileWriteToolkit with the output directory
|
89 |
-
file_toolkit = FileWriteToolkit(output_dir=output_dir)
|
90 |
-
|
91 |
-
# Configure toolkits
|
92 |
-
tools = [
|
93 |
-
*file_toolkit.get_tools(),
|
94 |
-
*WebToolkit(
|
95 |
-
headless=False, # Set to True for headless mode (e.g., on remote servers)
|
96 |
-
web_agent_model=models["web"],
|
97 |
-
planning_agent_model=models["planning"],
|
98 |
-
).get_tools(),
|
99 |
-
*VideoAnalysisToolkit(model=models["video"]).get_tools(),
|
100 |
-
*AudioAnalysisToolkit().get_tools(), # This requires OpenAI Key
|
101 |
-
*CodeExecutionToolkit(sandbox="subprocess", verbose=True).get_tools(),
|
102 |
-
*ImageAnalysisToolkit(model=models["image"]).get_tools(),
|
103 |
-
SearchToolkit().search_duckduckgo,
|
104 |
-
SearchToolkit().search_google, # Comment this out if you don't have google search
|
105 |
-
SearchToolkit().search_wiki,
|
106 |
-
*ExcelToolkit().get_tools(),
|
107 |
-
*DocumentProcessingToolkit(model=models["document"]).get_tools(),
|
108 |
-
]
|
109 |
-
|
110 |
-
# Configure agent roles and parameters
|
111 |
-
user_agent_kwargs = {"model": models["user"]}
|
112 |
-
assistant_agent_kwargs = {"model": models["assistant"], "tools": tools}
|
113 |
-
|
114 |
-
# Configure task parameters
|
115 |
-
task_kwargs = {
|
116 |
-
"task_prompt": question,
|
117 |
-
"with_task_specify": False,
|
118 |
-
}
|
119 |
-
|
120 |
-
# Create and return the society
|
121 |
-
society = OwlRolePlaying(
|
122 |
-
**task_kwargs,
|
123 |
-
user_role_name="user",
|
124 |
-
user_agent_kwargs=user_agent_kwargs,
|
125 |
-
assistant_role_name="assistant",
|
126 |
-
assistant_agent_kwargs=assistant_agent_kwargs,
|
127 |
-
)
|
128 |
-
|
129 |
-
return society
|
130 |
-
|
131 |
-
|
132 |
-
def main():
|
133 |
-
r"""Main function to run the OWL system with an example question."""
|
134 |
-
# Example research question
|
135 |
-
question ="""请使用文件写入工具生成一个Python脚本,创建一个简单的Flask网络服务器,并将其保存到file_write_outputs目录中的flask_server.py文件。脚本应该包含基本的路由和启动服务器的代码。"""
|
136 |
-
# Construct and run the society
|
137 |
-
society = construct_society(question)
|
138 |
-
answer, chat_history, token_count = run_society(society)
|
139 |
-
|
140 |
-
# Output the result
|
141 |
-
print(f"\033[94mAnswer: {answer}\033[0m")
|
142 |
-
|
143 |
-
if __name__ == "__main__":
|
144 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|