-
Notifications
You must be signed in to change notification settings - Fork 2.2k
添加硅基流动配置及调用脚本,使OWL支持硅基流动接口调用。另外,修改example目录下的脚本执行方式为可传参动态提问。 #339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
240ef57
43984bf
155c41a
1ba91ea
499e888
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename the file with english |
||
|
|
||
| # ✨️ 核心功能 | ||
|
|
||
| - **在线搜索**:支持多种搜索引擎(包括维基百科、Google、DuckDuckGo、百度、博查等),实现实时信息检索与知识获取 | ||
|
|
@@ -327,7 +329,7 @@ npx -y @wonderwhy-er/desktop-commander setup --force-file-protocol | |
| # 🚀 快速开始 | ||
|
|
||
| ## 基本用法 | ||
|
|
||
| 运行以下示例: | ||
|
|
||
| ```bash | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. ========= | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. file name should in lowercase. |
||
| # 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", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for the assistant it's better not using qwq since it's reasoning model, may not suitable for our case, same for the user agent, some other models have great tool calling capability would be suggested |
||
| model_config_dict=SiliconFlowConfig(temperature=0.2).as_dict(), | ||
| ), | ||
| "web": ModelFactory.create( | ||
| model_platform=ModelPlatformType.SILICONFLOW, | ||
| model_type="Qwen/Qwen2-VL-72B-Instruct", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about Qwen2.5-VL-72-Instruct, the price is the same. |
||
| 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() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename the file with english