diff --git "a/OWL\344\271\213Excel\346\226\207\344\273\266\345\244\204\347\220\206.mp4" "b/OWL\344\271\213Excel\346\226\207\344\273\266\345\244\204\347\220\206.mp4" new file mode 100644 index 000000000..70812544b Binary files /dev/null and "b/OWL\344\271\213Excel\346\226\207\344\273\266\345\244\204\347\220\206.mp4" differ diff --git a/README.md b/README.md index ef9644228..d1cfc574f 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,8 @@ https://github.com/user-attachments/assets/2a2a825d-39ea-45c5-9ba1-f9d58efbc372 https://private-user-images.githubusercontent.com/55657767/420212194-e813fc05-136a-485f-8df3-f10d9b4e63ec.mp4 +https://github.com/camel-ai/owl/blob/43984bfc968d62e7174b0c1e6283fefe08c44b45/OWL之Excel文件处理.mp4 + # ✨️ Core Features - **Online Search**: Support for multiple search engines (including Wikipedia, Google, DuckDuckGo, Baidu, Bocha, etc.) for real-time information retrieval and knowledge acquisition. diff --git a/README_zh.md b/README_zh.md index d9aa55071..f324d1990 100644 --- a/README_zh.md +++ b/README_zh.md @@ -125,6 +125,8 @@ https://private-user-images.githubusercontent.com/55657767/420211368-f29f477d-7e https://private-user-images.githubusercontent.com/55657767/420212194-e813fc05-136a-485f-8df3-f10d9b4e63ec.mp4 +https://github.com/camel-ai/owl/blob/43984bfc968d62e7174b0c1e6283fefe08c44b45/OWL之Excel文件处理.mp4 + # ✨️ 核心功能 - **在线搜索**:支持多种搜索引擎(包括维基百科、Google、DuckDuckGo、百度、博查等),实现实时信息检索与知识获取 @@ -327,7 +329,7 @@ npx -y @wonderwhy-er/desktop-commander setup --force-file-protocol # 🚀 快速开始 ## 基本用法 - + 运行以下示例: ```bash diff --git a/examples/run.py b/examples/run.py index 60a118cb8..faba62a31 100644 --- a/examples/run.py +++ b/examples/run.py @@ -29,7 +29,7 @@ from owl.utils import run_society, DocumentProcessingToolkit -import pathlib +import pathlib, sys base_dir = pathlib.Path(__file__).parent.parent env_path = base_dir / "owl" / ".env" @@ -131,7 +131,12 @@ def construct_society(question: str) -> RolePlaying: def main(): r"""Main function to run the OWL system with an example question.""" # Example research question - 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." + if len(sys.argv) > 1: + question = str(sys.argv[1]) + + else: + # Example research question + 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." # Construct and run the society society = construct_society(question) diff --git a/examples/run_SiliconFlow.py b/examples/run_SiliconFlow.py new file mode 100644 index 000000000..1fb1b7e34 --- /dev/null +++ b/examples/run_SiliconFlow.py @@ -0,0 +1,159 @@ +# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. ========= +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. ========= + +# To run this file, you need to configure the Qwen API key +# You can obtain your API key from Bailian platform: bailian.console.aliyun.com +# Set it as QWEN_API_KEY="your-api-key" in your .env file or add it to your environment variables + +from dotenv import load_dotenv +from camel.models import ModelFactory +from camel.configs import SiliconFlowConfig +from camel.toolkits import ( + CodeExecutionToolkit, + ExcelToolkit, + ImageAnalysisToolkit, + SearchToolkit, + VideoAnalysisToolkit, + BrowserToolkit, + FileWriteToolkit, +) +from camel.types import ModelPlatformType, ModelType +from camel.societies import RolePlaying + +from owl.utils import run_society, DocumentProcessingToolkit + +from camel.logger import set_log_level + + +import pathlib, sys + +base_dir = pathlib.Path(__file__).parent.parent +env_path = base_dir / "owl" / ".env" +load_dotenv(dotenv_path=str(env_path)) + +set_log_level(level="DEBUG") + + +def construct_society(question: str) -> RolePlaying: + """ + Construct a society of agents based on the given question. + + Args: + question (str): The task or question to be addressed by the society. + + Returns: + RolePlaying: A configured society of agents ready to address the question. + """ + + # Create models for different components + models = { + "user": ModelFactory.create( + model_platform=ModelPlatformType.SILICONFLOW, + model_type="Qwen/QwQ-32B", + model_config_dict=SiliconFlowConfig(temperature=0.2).as_dict(), + ), + "assistant": ModelFactory.create( + model_platform=ModelPlatformType.SILICONFLOW, + model_type="Qwen/QwQ-32B", + model_config_dict=SiliconFlowConfig(temperature=0.2).as_dict(), + ), + "web": ModelFactory.create( + model_platform=ModelPlatformType.SILICONFLOW, + model_type="Qwen/Qwen2-VL-72B-Instruct", + model_config_dict=SiliconFlowConfig(temperature=0.2).as_dict(), + ), + "planning": ModelFactory.create( + model_platform=ModelPlatformType.SILICONFLOW, + model_type="Qwen/QwQ-32B", + model_config_dict=SiliconFlowConfig(temperature=0.2).as_dict(), + ), + "video": ModelFactory.create( + model_platform=ModelPlatformType.SILICONFLOW, + model_type="Qwen/Qwen2-VL-72B-Instruct", + model_config_dict=SiliconFlowConfig(temperature=0.2).as_dict(), + ), + "image": ModelFactory.create( + model_platform=ModelPlatformType.SILICONFLOW, + model_type="Qwen/Qwen2-VL-72B-Instruct", + model_config_dict=SiliconFlowConfig(temperature=0.2).as_dict(), + ), + "document": ModelFactory.create( + model_platform=ModelPlatformType.SILICONFLOW, + model_type="Qwen/Qwen2-VL-72B-Instruct", + model_config_dict=SiliconFlowConfig(temperature=0.2).as_dict(), + ), + } + + # Configure toolkits + tools = [ + *BrowserToolkit( + headless=False, # Set to True for headless mode (e.g., on remote servers) + web_agent_model=models["web"], + planning_agent_model=models["planning"], + output_language="Chinese", + ).get_tools(), + *VideoAnalysisToolkit(model=models["video"]).get_tools(), + *CodeExecutionToolkit(sandbox="subprocess", verbose=True).get_tools(), + *ImageAnalysisToolkit(model=models["image"]).get_tools(), + SearchToolkit().search_duckduckgo, + SearchToolkit().search_google, # Comment this out if you don't have google search + SearchToolkit().search_wiki, + SearchToolkit().search_baidu, + *ExcelToolkit().get_tools(), + *DocumentProcessingToolkit(model=models["document"]).get_tools(), + *FileWriteToolkit(output_dir="./").get_tools(), + ] + + # Configure agent roles and parameters + user_agent_kwargs = {"model": models["user"]} + assistant_agent_kwargs = {"model": models["assistant"], "tools": tools} + + # Configure task parameters + task_kwargs = { + "task_prompt": question, + "with_task_specify": False, + } + + # Create and return the society + society = RolePlaying( + **task_kwargs, + user_role_name="user", + user_agent_kwargs=user_agent_kwargs, + assistant_role_name="assistant", + assistant_agent_kwargs=assistant_agent_kwargs, + output_language="Chinese", + ) + + return society + + +def main(): + r"""Main function to run the OWL system with an example question.""" + # Example research question + if len(sys.argv) > 1: + question = str(sys.argv[1]) + + else: + question = "浏览百度告诉我未来一周北京天气!并帮我制定北京的旅游计划!" + # Construct and run the society + society = construct_society(question) + answer, chat_history, token_count = run_society(society) + + # Output the result + print(f"\033[94mAnswer: {answer}\033[0m") + + + +if __name__ == "__main__": + main() diff --git a/examples/run_azure_openai.py b/examples/run_azure_openai.py index 4c11f8f2a..c7c9ce452 100644 --- a/examples/run_azure_openai.py +++ b/examples/run_azure_openai.py @@ -29,7 +29,7 @@ from camel.logger import set_log_level -import pathlib +import pathlib, sys base_dir = pathlib.Path(__file__).parent.parent env_path = base_dir / "owl" / ".env" @@ -104,7 +104,12 @@ def construct_society(question: str) -> OwlRolePlaying: def main(): r"""Main function to run the OWL system with Azure OpenAI.""" # Example question - 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." + if len(sys.argv) > 1: + question = str(sys.argv[1]) + + else: + # Example research question + 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." # Construct and run the society society = construct_society(question) diff --git a/examples/run_deepseek_zh.py b/examples/run_deepseek_zh.py index aa7e12c45..a6ae3f203 100644 --- a/examples/run_deepseek_zh.py +++ b/examples/run_deepseek_zh.py @@ -33,7 +33,7 @@ from owl.utils import run_society -import pathlib +import pathlib, sys set_log_level(level="DEBUG") @@ -102,7 +102,12 @@ def construct_society(question: str) -> RolePlaying: def main(): r"""Main function to run the OWL system with an example question.""" # Example research question - question = "搜索OWL项目最近的新闻并生成一篇报告,最后保存到本地。" + if len(sys.argv) > 1: + question = str(sys.argv[1]) + + else: + # Example research question + question = "搜索OWL项目最近的新闻并生成一篇报告,最后保存到本地。" # Construct and run the society society = construct_society(question) diff --git a/examples/run_groq.py b/examples/run_groq.py index 9f3f3a612..60b00e6cd 100644 --- a/examples/run_groq.py +++ b/examples/run_groq.py @@ -43,6 +43,8 @@ from owl.utils import OwlRolePlaying, run_society, DocumentProcessingToolkit +import sys + load_dotenv() set_log_level(level="DEBUG") @@ -141,7 +143,12 @@ def construct_society(question: str) -> OwlRolePlaying: def main(): r"""Main function to run the OWL system with an example question.""" # Example research question - 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." + if len(sys.argv) > 1: + question = str(sys.argv[1]) + + else: + # Example research question + 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." # Construct and run the society # Note: This configuration uses GROQ_LLAMA_3_3_70B for tool-intensive roles (assistant, web, planning, video, image) diff --git a/examples/run_mini.py b/examples/run_mini.py index a2e4a84dc..9091fe4ee 100644 --- a/examples/run_mini.py +++ b/examples/run_mini.py @@ -26,7 +26,7 @@ from camel.societies import RolePlaying -import pathlib +import pathlib, sys base_dir = pathlib.Path(__file__).parent.parent env_path = base_dir / "owl" / ".env" @@ -107,7 +107,12 @@ def construct_society(question: str) -> RolePlaying: def main(): r"""Main function to run the OWL system with an example question.""" # Example research question - 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." + if len(sys.argv) > 1: + question = str(sys.argv[1]) + + else: + # Example research question + 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." # Construct and run the society society = construct_society(question) diff --git a/examples/run_ollama.py b/examples/run_ollama.py index e4efd37bc..e2fab493f 100644 --- a/examples/run_ollama.py +++ b/examples/run_ollama.py @@ -31,7 +31,7 @@ from camel.logger import set_log_level -import pathlib +import pathlib, sys base_dir = pathlib.Path(__file__).parent.parent env_path = base_dir / "owl" / ".env" @@ -125,7 +125,12 @@ def construct_society(question: str) -> RolePlaying: def main(): r"""Main function to run the OWL system with an example question.""" # Example research question - 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." + if len(sys.argv) > 1: + question = str(sys.argv[1]) + + else: + # Example research question + 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." # Construct and run the society society = construct_society(question) diff --git a/examples/run_openai_compatiable_model.py b/examples/run_openai_compatiable_model.py index a83248d88..58acaa3da 100644 --- a/examples/run_openai_compatiable_model.py +++ b/examples/run_openai_compatiable_model.py @@ -29,7 +29,7 @@ from camel.societies import RolePlaying from camel.logger import set_log_level -import pathlib +import pathlib, sys base_dir = pathlib.Path(__file__).parent.parent env_path = base_dir / "owl" / ".env" @@ -128,7 +128,12 @@ def construct_society(question: str) -> RolePlaying: def main(): r"""Main function to run the OWL system with an example question.""" # Example research question - 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." + if len(sys.argv) > 1: + question = str(sys.argv[1]) + + else: + # Example research question + 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." # Construct and run the society society = construct_society(question) diff --git a/examples/run_qwen_zh.py b/examples/run_qwen_zh.py index 2d2198e7b..267cc7348 100644 --- a/examples/run_qwen_zh.py +++ b/examples/run_qwen_zh.py @@ -35,7 +35,7 @@ from camel.logger import set_log_level -import pathlib +import pathlib, sys base_dir = pathlib.Path(__file__).parent.parent env_path = base_dir / "owl" / ".env" @@ -140,7 +140,12 @@ def construct_society(question: str) -> RolePlaying: def main(): r"""Main function to run the OWL system with an example question.""" # Example research question - question = "浏览亚马逊并找出一款对程序员有吸引力的产品。请提供产品名称和价格" + if len(sys.argv) > 1: + question = str(sys.argv[1]) + + else: + # Example research question + question = "浏览亚马逊并找出一款对程序员有吸引力的产品。请提供产品名称和价格" # Construct and run the society society = construct_society(question) diff --git a/examples/run_terminal.py b/examples/run_terminal.py index 00ce667cd..7af401f93 100644 --- a/examples/run_terminal.py +++ b/examples/run_terminal.py @@ -26,7 +26,7 @@ from owl.utils import run_society from camel.societies import RolePlaying -import pathlib +import pathlib, sys base_dir = pathlib.Path(__file__).parent.parent env_path = base_dir / "owl" / ".env" @@ -108,7 +108,12 @@ def construct_society(question: str) -> RolePlaying: def main(): r"""Main function to run the OWL system with an example question.""" # Example research question - question = f"""Open Google Search, summarize the number of GitHub stars, forks, etc., of the camel framework of camel-ai, + if len(sys.argv) > 1: + question = str(sys.argv[1]) + + else: + # Example research question + question = f"""Open Google Search, summarize the number of GitHub stars, forks, etc., of the camel framework of camel-ai, and write the numbers into a Python file using the plot package, save it to "+{os.path.join(base_dir, 'final_output')}+", and execute the Python file with the local terminal to display the graph for me.""" diff --git a/examples/run_terminal_zh.py b/examples/run_terminal_zh.py index 74c9dbf39..14e9f1616 100644 --- a/examples/run_terminal_zh.py +++ b/examples/run_terminal_zh.py @@ -26,7 +26,7 @@ from owl.utils import run_society from camel.societies import RolePlaying -import pathlib +import pathlib, sys base_dir = pathlib.Path(__file__).parent.parent env_path = base_dir / "owl" / ".env" @@ -108,7 +108,12 @@ def construct_society(question: str) -> RolePlaying: def main(): r"""Main function to run the OWL system with an example question.""" # Example research question - question = f"""打开百度搜索,总结一下camel-ai的camel框架的github star、fork数目等,并把数字用plot包写成python文件保存到"+{os.path.join + if len(sys.argv) > 1: + question = str(sys.argv[1]) + + else: + # Example research question + question = f"""打开百度搜索,总结一下camel-ai的camel框架的github star、fork数目等,并把数字用plot包写成python文件保存到"+{os.path.join (base_dir, 'final_output')}+",用本地终端执行python文件显示图出来给我""" # Construct and run the society diff --git a/owl/.env_template b/owl/.env_template index 0261124aa..63e750e49 100644 --- a/owl/.env_template +++ b/owl/.env_template @@ -24,6 +24,10 @@ QWEN_API_KEY='Your_Key' # DeepSeek API (https://platform.deepseek.com/api_keys) DEEPSEEK_API_KEY='Your_Key' +# SILICONFLOW https://cloud.siliconflow.cn/account/ak +SILICONFLOW_API_KEY='Your_Key' +SILICONFLOW_API_URL='https://api.siliconflow.cn/v1' + #=========================================== # Tools & Services API #===========================================