声明:本公众号所有文章均仅限个人学习或技术研究使用,不可用作任何违法获利或任何不良诱导宣传。如有类似事情发生,与本频道无关。
一、背景知识介绍
1、什么是OWL?
借用官方团队的话来说,OWL 是一个前沿的多智能体协作框架,推动任务自动化的边界,构建在CAMEL-AI Framework(Github官方链接https://github.com/camel-ai/camel,该框架使多智能体系统能够通过生成数据和与环境交互来不断发展,具有强可扩展性,支持具有数百万代理的系统,确保大规模的有效协调,通信和资源管理。)。团队的愿景是彻底变革 AI 智能体协作解决现实任务的方式。通过利用动态智能体交互,OWL 实现了跨多领域更自然、高效且稳健的任务自动化。
2、OWL的核心功能
如下图所示,OWL结合多AI大模型协作以及各类工具包调用来解决真实世界的各种问题。参考官方文档,OWL的核心功能如下:
在线搜索:支持多种搜索引擎(包括维基百科、Google、DuckDuckGo、百度、博查等),实现实时信息检索与知识获取
多模态处理:支持互联网或本地视频、图片、语音
处理浏览器操作:借助Playwright框架开发浏览器模拟交互,支持页面滚动、点击、输入、下载、历史回退等功能
文件解析:word、excel、PDF、PowerPoint信息提取,内容转文本/Markdown
代码执行:编写python代码,并使用解释器运行
丰富工具包:提供丰富的工具包,包括ArxivToolkit(学术论文检索)、AudioAnalysisToolkit(音频分析)、CodeExecutionToolkit(代码执行)、DalleToolkit(图像生成)、DataCommonsToolkit(数据共享)、ExcelToolkit(Excel处理)、GitHubToolkit(GitHub交互)、GoogleMapsToolkit(地图服务)、GoogleScholarToolkit(学术搜索)、ImageAnalysisToolkit(图像分析)、MathToolkit(数学计算)、NetworkXToolkit(图形分析)、NotionToolkit(Notion交互)、OpenAPIToolkit(API操作)、RedditToolkit(Reddit交互)、SearchToolkit(搜索服务)、SemanticScholarToolkit(语义学术搜索)、SymPyToolkit(符号计算)、VideoAnalysisToolkit(视频分析)、WeatherToolkit(天气查询)、BrowserToolkit(网页交互)等多种专业工具,满足各类特定任务需求。
3、什么是playwright?
playwright-python(常被称作playwright)是微软开源的跨浏览器自动化测试工具,OWL有用到该工具来调用浏览器进行自动化工作,以下是关键信息:
核心功能
多浏览器支持:Chromium/Firefox/WebKit
自动化操作:页面导航、点击、表单填写、截图等
无头模式:可在无界面环境下运行
网络拦截:模拟API响应、处理请求
移动端模拟:支持设备型号模拟(如iPhone 13)
二、OWL环境搭建
OWL官方提供了多种方式的环境部署安装,包括uv、venv、conda、Docker等,上节【OpenManus部署】Manus平替OpenManus真的好用吗?手把手带你部署并运行OpenManus(不需要魔法)我们在部署OpenManus的时候python虚拟环境创建工具使用的是conda,这次我们沿用上次的方法来部署,不知道怎么安装conda的大家可以参考上节内容。
1、Python Conda环境创建
在自己想要部署OWL的目录,按照上节【OpenManus部署】Manus平替OpenManus真的好用吗?手把手带你部署并运行OpenManus(不需要魔法)文章中介绍的方法安装miniconda后,在PowerShell中运行如下命令创建并启动owl的python Conda环境
conda create -n owl python=3.10
conda activate owl
创建conda环境
激活conda环境
2、克隆OWL代码(听核心工程师说昨晚有更新哦,新版更稳定)
git clone https://github.com/camel-ai/owl.git
PowerShell切换到你要部署OWL的文件目录,运行如上代码后,等待代码下载完成,如下图所示:
然后运行如下命令,进入owl目录
#Windows CMD
cd .\owl
#Linux/Mac/Windows Powershell
cd ./owl
如下图所示为切换目录后在Powershell中执行ls命令后看到的代码目录结构:
3、依赖安装
官方推荐作为包安装,那我们就运行如下命令安装依赖包(时间大约5分钟,下载速度取决于网速,我这里指定了国内阿里源):
pip install -e . -i https://mirrors.aliyun.com/pypi/simple
安装完成后如下图所示:
4、大模型接口及API配置(硅基流动、QWEN)
大模型接口及API配置文件是一个叫.env的文件,大家可以在项目owl\owl目录下将.env_template复制一份,重命名为.env,如下图所示:
(1)硅基流动自定义接口配置:
“极智引擎”公众号在上期OpenManus部署过程中已经讲解过硅基流动及其接口的配置,不了解的同学可以访问:https://mp.weixin.qq.com/s?__biz=Mzk3NTUyNDUxOQ==&mid=2247483764&idx=1&sn=2c779b8573ae5a4c15b40940cda6b9c6&scene=21#wechat_redirect查看,调用硅基流动接口需要支付一定的费用,但官方给新注册的用户赠送了一部分金额,足够做几次小研究使用了,大家随时关注自己账户余额即可。
打开前文所述的.env文件,添加如下自定义配置后保存:
# SILICONFLOW
SILICONFLOW_API_KEY='这里需要替换成你自己硅基流动的Key'
SILICONFLOW_API_URL='https://api.siliconflow.cn/v1'
然后切换到项目的examples文件夹,这里创建一个自定义的支持硅基流动的脚本文件,我这里命名是run_SiliconFlow.py,文件内容大家可以直接复制我这里调整好的代码直接用。硅基流动我这里配置的语义模型为“Qwen/QwQ-32B”,图形识别模型为“Qwen/Qwen2-VL-72B-Instruct”,这里大家根据自己喜好修改即可。
# ========= 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()
这里我魔改了下官方代码,在结尾的main函数中做了调整,让脚本支持传参的形式获取用户prompt,也省去了大家来回在脚本中改提示词的烦恼。也和核心工程师反馈了该问题,工程师反馈会尽快在新版本中进行优化。
(2)QWEN大模型自定义接口配置:
千问的配置官方已写好脚本,就是在examples目录下的run_qwen_zh.py以及run_qwen_mini_zh.py。从工程师那里了解到,当前支持官方接口的效果比较好,这也就是为啥我要给大家讲解这一块的原因。像.env配置文件里所讲到的,大家可以直接访问https://help.aliyun.com/zh/model-studio/developer-reference/get-api-key去获取自己的API Key。同硅基流动一样,调用接口官方也需要收取费用,但当前新注册使用的用户官方赠送百万token供大家体验使用,大家自己关注token使用情况即可。
访问如上链接后,点击如下位置获取API Key
点击创建我的API-KEY
选择默认业务空间,添加点备注后点确定即可成功创建
创建成功后点击“查看”按钮查看指定的密钥
然后点击“复制”即可成功复制
在.env文件的如下图位置配置你自己的QWEN密钥即完成了QWEN大模型的配置,OWL将调用qwen的语义分析及图形识别大模型完成用户授予的工作。
然后切换到项目的examples文件夹,和先前一样魔改官方代码run_qwen_zh.py,其实就是添加支持脚本传参的代码,文件内容大家可以直接复制我这里调整好的代码直接用。
# ========= 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.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.QWEN,
model_type=ModelType.QWEN_MAX,
model_config_dict={"temperature": 0},
),
"assistant": ModelFactory.create(
model_platform=ModelPlatformType.QWEN,
model_type=ModelType.QWEN_MAX,
model_config_dict={"temperature": 0},
),
"web": ModelFactory.create(
model_platform=ModelPlatformType.QWEN,
model_type=ModelType.QWEN_VL_MAX,
model_config_dict={"temperature": 0},
),
"planning": ModelFactory.create(
model_platform=ModelPlatformType.QWEN,
model_type=ModelType.QWEN_MAX,
model_config_dict={"temperature": 0},
),
"video": ModelFactory.create(
model_platform=ModelPlatformType.QWEN,
model_type=ModelType.QWEN_VL_MAX,
model_config_dict={"temperature": 0},
),
"image": ModelFactory.create(
model_platform=ModelPlatformType.QWEN,
model_type=ModelType.QWEN_VL_MAX,
model_config_dict={"temperature": 0},
),
"document": ModelFactory.create(
model_platform=ModelPlatformType.QWEN,
model_type=ModelType.QWEN_VL_MAX,
model_config_dict={"temperature": 0},
),
}
# 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."""
if len(sys.argv) > 1:
question = str(sys.argv[1])
else:
# Example research question
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()
其实这里只改两处,大家也可以不复制,直接自己改。
第一处是引入sys,如下图所示:
第二处是修改main函数将用户输入的第一个脚本参数作为用户prompt,如下图所示:
至此所有配置就完成了。
三、OWL运行测试
1、硅基流动调用测试
PowerShell切换到owl\example目录,运行如下脚本测试硅基流动的接口调用情况,我这里随便举了个例子:
python run_SiliconFlow.py 浏览百度告诉我未来一周北京天气!并帮我制定北京的旅游计划!
就像团队所述目前支持硅基流动接口调用,但是效果最好的还是官方接口,下图可以看出,大模型回复它无法直接访问互联网或百度搜索功能,因此无法实时获取北京未来一周的天气预报。
然后按照大模型自己的经验给我回复了一个旅游计划
2、QWEN官方接口调用测试
PowerShell切换到owl\example目录,运行如下脚本测试硅基流动的接口调用情况,我这里随便举了个例子:
python run_qwen_zh.py 浏览百度查看未来一周北京天气并帮我制定北京的旅游计划,将结果以markdown格式保存到D盘下的“ 北京旅行.md”文件中
可以看到大模型开始思考并进行详细策划
然后大模型打开浏览器进行天气查询,如下图所示:
天气情况如下:
然后大模型进行行程规划
最终将行程规划结果保存到了“北京旅行.md”文件中,如下图所示:
使用QWEN的体验还是不错的,大家可以配置尝试一下,有问题可以留言或私信找我咨询,我看到后会抽时间第一时间给大家解答。
这里就不介绍ollama的对接了,因为毕竟通常本地算力的大模型目前我测试来看效果不太好。
四、思考
OWL作为又一个Manus的开源平替,配置运行下来感觉相对成熟,和OpenManus相比我感觉OWL更稳定好用一些。当然了,只是个人当前测试的一些看法,所有AI Agent都是为了解放双手,让AI来解决现实世界问题,提升效率。我个人就当前的体验来说更喜欢OWL一些,期待各家后续的持续更新迭代。后续我也会持续关注,尽可能参与其中,给大家提供更多的干活分享。毕竟都是开源产品,开源精神很可贵,大家狠狠支持起来。
今天的分享就暂时到此,如要关注更多前沿科技、网络安全及效能提升,请一键三连:关注、转发、点赞本频道及同名“极智引擎”微信公众号,我将持续学习,给大家分享更多科技干货,我是多多,多多学习的多多,拜了个拜。(一定要关注哦,这个频道很爱分享干货)