前言
前几天Manus刷屏了,可惜没有邀请码,只能看着公开的资料分析了一通。
后来,忽然看到开源社区搞了个OpenManus
,嗯,这不得赶紧试试。
OpenManus
首先,简单介绍下。
OpenManus 是 MetaGPT 社区的5个人花了3个小时,参考Manus搭建的一套替代方案。
它是一个通用型 AI 助手,能够执行各种任务,包括编程、信息检索、文件处理和网页浏览等。
底层使用了 anthropic-computer-use
和 browser-use
开源项目。
由于开发时间在这儿放着呢,所以,优先实现了命令行交互,后续会推出WebUI。
本地安装
理论少谈,我们在本地安装试试。
下载代码
OpenManus是开源的,可以直接下载代码,zip/git什么方式都行。
代码地址:github.com/mannaandpoe...
安装环境
使用Cursor打开下载的项目。
键盘输入快捷键"Shift+Ctrl+P"打开命令面板,选择"Python:Create Environment"创建Python环境。
选择"Conda"方式。
选择"Python 3.12"。
等待Python虚拟环境初始化完成。
安装依赖。
pip install -r requirements.txt
修改配置
复制/config/config.example.toml
到/config/config.toml
。
我使用的"硅基流动"的API,如下设置即可,api_key设置为硅基流动密钥。
"硅基流动"密钥申请、使用可参考:《》。
ini
# Global LLM configuration
[llm]
model = "deepseek-ai/DeepSeek-V3"
base_url = "https://api.siliconflow.cn/v1"
api_key = "sk-..."
max_tokens = 4096
temperature = 0.0
# [llm] #AZURE OPENAI:
# api_type= 'azure'
# model = "YOUR_MODEL_NAME" #"gpt-4o-mini"
# base_url = "{YOUR_AZURE_ENDPOINT.rstrip('/')}/openai/deployments/{AZURE_DEPOLYMENT_ID}"
# api_key = "AZURE API KEY"
# max_tokens = 8096
# temperature = 0.0
# api_version="AZURE API VERSION" #"2024-08-01-preview"
# Optional configuration for specific LLM models
[llm.vision]
model = "deepseek-ai/DeepSeek-V3"
base_url = "https://api.siliconflow.cn/v1"
api_key = "sk-..."
此处一定要使用有Function Call
功能的模型。
运行
"Ctrl+`",打开 Cursor 的终端界面,输入启动命令。
css
python .\main.py
等待提示词输入界面。
接下来输入目标就行了。
实例验证
我们开始验证,提示词如下:
帮我收集10条AI新闻,并整理好格式。
结果截图:
启动任务
第二次思考就已经找到所需内容。
第三次、第四次思考已经完成任务。
之后应该可以结束任务了,但是,OpenManus 好像没有处理好结束的情况,一直到我设置的10次思考完成后才结束。
可以看到上面打开的内容就是整理好的资料。
错误处理
中间碰到了一些问题,记录如下。
更换默认搜索工具为百度
修改app/tool/google_search.py
内容如下。
python
import asyncio
from typing import List
from baidusearch.baidusearch import search
from app.tool.base import BaseTool
class GoogleSearch(BaseTool):
name: str = "baidu_search"
description: str = """Perform a Google search and return a list of relevant links.
Use this tool when you need to find information on the web, get up-to-date data, or research specific topics.
The tool returns a list of URLs that match the search query.
"""
parameters: dict = {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "(required) The search query to submit to Google.",
},
"num_results": {
"type": "integer",
"description": "(optional) The number of search results to return. Default is 10.",
"default": 10,
},
},
"required": ["query"],
}
async def execute(self, query: str, num_results: int = 10) -> List[str]:
"""
Execute a Google search and return a list of URLs.
Args:
query (str): The search query to submit to Google.
num_results (int, optional): The number of search results to return. Default is 10.
Returns:
List[str]: A list of URLs matching the search query.
"""
# Run the search in a thread pool to prevent blocking
loop = asyncio.get_event_loop()
links = await loop.run_in_executor(
None, lambda: list(search(query, num_results=num_results))
)
return links
安装所需依赖。
pip install baidusearch
按照上述处理后,重新运行即可。
更改思考次数
我尝试的时候,如果使用默认的思考次数max_steps=30,很容易触发硅基流动API的访问限制(RPM 或 TPM),我观察到大概12次左右触发,就给调整为10了。
修改/app.py
。
ini
agent = Manus(
name="Manus",
description="A versatile agent that can solve various tasks using multiple tools",
max_steps=10 # 在这里指定为 10
)
修改app/agent/toolcall.py
。
ini
max_steps: int = 10
修改app/agent/swe.py
。
ini
max_steps: int = 10
修改app/agent/planning.py
。
ini
max_steps: int = 10
这点来看,赶出来的代码,工程化确实不大好。
总结
整体验证下来,该有的架子已经出来了,能力也是有的,但还比较初步,有很大的优化空间。比如:
- 默认的google搜索不适合国内使用。
- 有些API兼容有问题,当然也有可能是API提供方不是很标准。
- 默认每次提问都是30次思考,有些浪费token,并且出现重复思考情况。
等等。
大家如果碰到问题,可以去Github的Issues进行查看,应该有很多同仁已经碰到了。
不过即使有这样那样的问题,OpenManus 还是为我们提供了一种尝试 AGI 的可能,并且自由度很大,非常值得大家试试。
后续,我也会鼓捣一些功能出来,如果有所成果,再给大家分享。