Sun Tao commited on
Commit
84bfb5a
·
2 Parent(s): 2ffc766 194e16b

Merge branch 'camel-ai:main' into patch-7

Browse files
owl/app.py CHANGED
@@ -41,6 +41,7 @@ SCRIPTS = {
41
  "GAIA Roleplaying": "run_gaia_roleplaying.py",
42
  "OpenAI Compatible": "run_openai_compatiable_model.py",
43
  "Ollama": "run_ollama.py",
 
44
  }
45
 
46
  # 脚本描述
@@ -53,6 +54,7 @@ SCRIPT_DESCRIPTIONS = {
53
  "GAIA Roleplaying": "GAIA基准测试实现,用于评估模型能力",
54
  "OpenAI Compatible": "使用兼容OpenAI API的第三方模型,支持自定义API端点",
55
  "Ollama": "使用Ollama API",
 
56
  }
57
 
58
  # 环境变量分组
 
41
  "GAIA Roleplaying": "run_gaia_roleplaying.py",
42
  "OpenAI Compatible": "run_openai_compatiable_model.py",
43
  "Ollama": "run_ollama.py",
44
+ "Terminal": "run_terminal_zh.py",
45
  }
46
 
47
  # 脚本描述
 
54
  "GAIA Roleplaying": "GAIA基准测试实现,用于评估模型能力",
55
  "OpenAI Compatible": "使用兼容OpenAI API的第三方模型,支持自定义API端点",
56
  "Ollama": "使用Ollama API",
57
+ "Terminal": "使用本地终端执行python文件",
58
  }
59
 
60
  # 环境变量分组
owl/app_en.py CHANGED
@@ -41,6 +41,7 @@ SCRIPTS = {
41
  "GAIA Roleplaying": "run_gaia_roleplaying.py",
42
  "OpenAI Compatible": "run_openai_compatiable_model.py",
43
  "Ollama": "run_ollama.py",
 
44
  }
45
 
46
  # Script descriptions
@@ -53,6 +54,7 @@ SCRIPT_DESCRIPTIONS = {
53
  "GAIA Roleplaying": "GAIA benchmark implementation, used to evaluate model capabilities",
54
  "OpenAI Compatible": "Uses third-party models compatible with OpenAI API, supports custom API endpoints",
55
  "Ollama": "Uses Ollama API",
 
56
  }
57
 
58
  # Environment variable groups
 
41
  "GAIA Roleplaying": "run_gaia_roleplaying.py",
42
  "OpenAI Compatible": "run_openai_compatiable_model.py",
43
  "Ollama": "run_ollama.py",
44
+ "Terminal": "run_terminal.py",
45
  }
46
 
47
  # Script descriptions
 
54
  "GAIA Roleplaying": "GAIA benchmark implementation, used to evaluate model capabilities",
55
  "OpenAI Compatible": "Uses third-party models compatible with OpenAI API, supports custom API endpoints",
56
  "Ollama": "Uses Ollama API",
57
+ "Terminal": "Uses local terminal to execute python files",
58
  }
59
 
60
  # Environment variable groups
owl/run_gaia_roleplaying.py CHANGED
@@ -131,8 +131,8 @@ def main():
131
  )
132
 
133
  # Output results
134
- logger.success(f"Correct: {result['correct']}, Total: {result['total']}")
135
- logger.success(f"Accuracy: {result['accuracy']}")
136
 
137
 
138
  if __name__ == "__main__":
 
131
  )
132
 
133
  # Output results
134
+ logger.info(f"Correct: {result['correct']}, Total: {result['total']}")
135
+ logger.info(f"Accuracy: {result['accuracy']}")
136
 
137
 
138
  if __name__ == "__main__":
owl/run_terminal.py ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ import os
16
+ from camel.models import ModelFactory
17
+ from camel.toolkits import (
18
+ SearchToolkit,
19
+ WebToolkit,
20
+ FileWriteToolkit,
21
+ TerminalToolkit
22
+ )
23
+ from camel.types import ModelPlatformType, ModelType
24
+ from camel.logger import set_log_level
25
+
26
+ from utils import OwlRolePlaying, run_society
27
+
28
+ load_dotenv()
29
+ set_log_level(level="DEBUG")
30
+ # Get current script directory
31
+ base_dir = os.path.dirname(os.path.abspath(__file__))
32
+
33
+ def construct_society(question: str) -> OwlRolePlaying:
34
+ r"""Construct a society of agents based on the given question.
35
+
36
+ Args:
37
+ question (str): The task or question to be addressed by the society.
38
+
39
+ Returns:
40
+ OwlRolePlaying: A configured society of agents ready to address the
41
+ question.
42
+ """
43
+
44
+ # Create models for different components
45
+ models = {
46
+ "user": ModelFactory.create(
47
+ model_platform=ModelPlatformType.OPENAI,
48
+ model_type=ModelType.GPT_4O,
49
+ model_config_dict={"temperature": 0},
50
+ ),
51
+ "assistant": ModelFactory.create(
52
+ model_platform=ModelPlatformType.OPENAI,
53
+ model_type=ModelType.GPT_4O,
54
+ model_config_dict={"temperature": 0},
55
+ ),
56
+ "web": ModelFactory.create(
57
+ model_platform=ModelPlatformType.OPENAI,
58
+ model_type=ModelType.GPT_4O,
59
+ model_config_dict={"temperature": 0},
60
+ ),
61
+ "planning": ModelFactory.create(
62
+ model_platform=ModelPlatformType.OPENAI,
63
+ model_type=ModelType.GPT_4O,
64
+ model_config_dict={"temperature": 0},
65
+ ),
66
+ }
67
+
68
+ # Configure toolkits
69
+ tools = [
70
+ *WebToolkit(
71
+ headless=False, # Set to True for headless mode (e.g., on remote servers)
72
+ web_agent_model=models["web"],
73
+ planning_agent_model=models["planning"],
74
+ ).get_tools(),
75
+ SearchToolkit().search_duckduckgo,
76
+ SearchToolkit().search_wiki,
77
+ *FileWriteToolkit(output_dir="./").get_tools(),
78
+ *TerminalToolkit().get_tools(),
79
+ ]
80
+
81
+ # Configure agent roles and parameters
82
+ user_agent_kwargs = {"model": models["user"]}
83
+ assistant_agent_kwargs = {"model": models["assistant"], "tools": tools}
84
+
85
+ # Configure task parameters
86
+ task_kwargs = {
87
+ "task_prompt": question,
88
+ "with_task_specify": False,
89
+ }
90
+
91
+ # Create and return the society
92
+ society = OwlRolePlaying(
93
+ **task_kwargs,
94
+ user_role_name="user",
95
+ user_agent_kwargs=user_agent_kwargs,
96
+ assistant_role_name="assistant",
97
+ assistant_agent_kwargs=assistant_agent_kwargs,
98
+ )
99
+
100
+ return society
101
+
102
+
103
+ def main():
104
+ r"""Main function to run the OWL system with an example question."""
105
+ # Example research question
106
+ question = f"""Open Google Search, summarize the number of GitHub stars, forks, etc., of the camel framework of camel-ai,
107
+ and write the numbers into a Python file using the plot package,
108
+ save it to "+{os.path.join(base_dir, 'final_output')}+",
109
+ and execute the Python file with the local terminal to display the graph for me."""
110
+
111
+ # Construct and run the society
112
+ society = construct_society(question)
113
+ answer, chat_history, token_count = run_society(society)
114
+
115
+ # Output the result
116
+ print(f"\033[94mAnswer: {answer}\nChat History: {chat_history}\ntoken_count:{token_count}\033[0m")
117
+
118
+
119
+ if __name__ == "__main__":
120
+ main()
owl/run_terminal_zh.py ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
16
+ from camel.models import ModelFactory
17
+ from camel.toolkits import (
18
+ SearchToolkit,
19
+ WebToolkit,
20
+ FileWriteToolkit,
21
+ TerminalToolkit
22
+ )
23
+ from camel.types import ModelPlatformType, ModelType
24
+ from camel.logger import set_log_level
25
+
26
+ from utils import OwlRolePlaying, run_society
27
+
28
+ load_dotenv()
29
+ set_log_level(level="DEBUG")
30
+ import os
31
+ # Get current script directory
32
+ base_dir = os.path.dirname(os.path.abspath(__file__))
33
+
34
+ def construct_society(question: str) -> OwlRolePlaying:
35
+ r"""Construct a society of agents based on the given question.
36
+
37
+ Args:
38
+ question (str): The task or question to be addressed by the society.
39
+
40
+ Returns:
41
+ OwlRolePlaying: A configured society of agents ready to address the
42
+ question.
43
+ """
44
+
45
+ # Create models for different components
46
+ models = {
47
+ "user": ModelFactory.create(
48
+ model_platform=ModelPlatformType.OPENAI,
49
+ model_type=ModelType.GPT_4O,
50
+ model_config_dict={"temperature": 0},
51
+ ),
52
+ "assistant": ModelFactory.create(
53
+ model_platform=ModelPlatformType.OPENAI,
54
+ model_type=ModelType.GPT_4O,
55
+ model_config_dict={"temperature": 0},
56
+ ),
57
+ "web": ModelFactory.create(
58
+ model_platform=ModelPlatformType.OPENAI,
59
+ model_type=ModelType.GPT_4O,
60
+ model_config_dict={"temperature": 0},
61
+ ),
62
+ "planning": ModelFactory.create(
63
+ model_platform=ModelPlatformType.OPENAI,
64
+ model_type=ModelType.GPT_4O,
65
+ model_config_dict={"temperature": 0},
66
+ ),
67
+ }
68
+
69
+ # Configure toolkits
70
+ tools = [
71
+ *WebToolkit(
72
+ headless=False, # Set to True for headless mode (e.g., on remote servers)
73
+ web_agent_model=models["web"],
74
+ planning_agent_model=models["planning"],
75
+ ).get_tools(),
76
+ SearchToolkit().search_duckduckgo,
77
+ SearchToolkit().search_wiki,
78
+ *FileWriteToolkit(output_dir="./").get_tools(),
79
+ *TerminalToolkit().get_tools(),
80
+ ]
81
+
82
+ # Configure agent roles and parameters
83
+ user_agent_kwargs = {"model": models["user"]}
84
+ assistant_agent_kwargs = {"model": models["assistant"], "tools": tools}
85
+
86
+ # Configure task parameters
87
+ task_kwargs = {
88
+ "task_prompt": question,
89
+ "with_task_specify": False,
90
+ }
91
+
92
+ # Create and return the society
93
+ society = OwlRolePlaying(
94
+ **task_kwargs,
95
+ user_role_name="user",
96
+ user_agent_kwargs=user_agent_kwargs,
97
+ assistant_role_name="assistant",
98
+ assistant_agent_kwargs=assistant_agent_kwargs,
99
+ )
100
+
101
+ return society
102
+
103
+
104
+ def main():
105
+ r"""Main function to run the OWL system with an example question."""
106
+ # Example research question
107
+ question = f"""打开百度搜索,总结一下camel-ai的camel框架的github star、fork数目等,并把数字用plot包写成python文件保存到"+{os.path.join
108
+ (base_dir, 'final_output')}+",用本地终端执行python文件显示图出来给我"""
109
+
110
+ # Construct and run the society
111
+ society = construct_society(question)
112
+ answer, chat_history, token_count = run_society(society)
113
+
114
+ # Output the result
115
+ print(f"\033[94mAnswer: {answer}\nChat History: {chat_history}\ntoken_count:{token_count}\033[0m")
116
+
117
+
118
+ if __name__ == "__main__":
119
+ main()
owl/utils/gaia.py CHANGED
@@ -195,7 +195,7 @@ class GAIABenchmark(BaseBenchmark):
195
  # Process tasks
196
  for task in tqdm(datas, desc="Running"):
197
  if self._check_task_completed(task["task_id"]):
198
- logger.success(
199
  f"The following task is already completed:\n task id: {task['task_id']}, question: {task['Question']}"
200
  )
201
  continue
 
195
  # Process tasks
196
  for task in tqdm(datas, desc="Running"):
197
  if self._check_task_completed(task["task_id"]):
198
+ logger.info(
199
  f"The following task is already completed:\n task id: {task['task_id']}, question: {task['Question']}"
200
  )
201
  continue