一.创建python运行环境
使用conda创建环境
(base) PS G:\> conda create -n open_manus python=3.12
Retrieving notices: done
Channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- defaults
Platform: win-64
Collecting package metadata (repodata.json): done
Solving environment: done
## Package Plan ##
environment location: D:\anaconda3\envs\open_manus
added / updated specs:
- python=3.12
The following NEW packages will be INSTALLED:
bzip2 anaconda/pkgs/main/win-64::bzip2-1.0.8-h2bbff1b_6
ca-certificates anaconda/pkgs/main/win-64::ca-certificates-2025.2.25-haa95532_0
expat anaconda/pkgs/main/win-64::expat-2.6.4-h8ddb27b_0
libffi anaconda/pkgs/main/win-64::libffi-3.4.4-hd77b12b_1
openssl anaconda/pkgs/main/win-64::openssl-3.0.16-h3f729d1_0
pip anaconda/pkgs/main/win-64::pip-25.0-py312haa95532_0
python anaconda/pkgs/main/win-64::python-3.12.9-h14ffc60_0
setuptools anaconda/pkgs/main/win-64::setuptools-75.8.0-py312haa95532_0
sqlite anaconda/pkgs/main/win-64::sqlite-3.45.3-h2bbff1b_0
tk anaconda/pkgs/main/win-64::tk-8.6.14-h0416ee5_0
tzdata anaconda/pkgs/main/noarch::tzdata-2025a-h04d1e81_0
vc anaconda/pkgs/main/win-64::vc-14.42-haa95532_4
vs2015_runtime anaconda/pkgs/main/win-64::vs2015_runtime-14.42.34433-he0abc0d_4
wheel anaconda/pkgs/main/win-64::wheel-0.45.1-py312haa95532_0
xz anaconda/pkgs/main/win-64::xz-5.6.4-h4754444_1
zlib anaconda/pkgs/main/win-64::zlib-1.2.13-h8cc25b3_1
Proceed ([y]/n)? y
Downloading and Extracting Packages:
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate open_manus
#
# To deactivate an active environment, use
#
# $ conda deactivate
激活环境
(base) PS G:\> conda activate open_manus
(open_manus) PS G:\>
二.下载OpenManus源码
下载源码webui分支
(base) PS G:\> conda activate open_manus
(open_manus) PS G:\> git clone -b front-end https://github.com/mannaandpoem/OpenManus.git
Cloning into 'OpenManus'...
remote: Enumerating objects: 2218, done.
remote: Counting objects: 100% (483/483), done.
remote: Compressing objects: 100% (188/188), done.
remote: Total 2218 (delta 390), reused 298 (delta 295), pack-reused 1735 (from 4)
Receiving objects: 100% (2218/2218), 3.38 MiB | 326.00 KiB/s, done.
Resolving deltas: 100% (1268/1268), done.
进入目录,安装依赖
(open_manus) PS G:\> cd .\OpenManus\
(open_manus) PS G:\OpenManus> pip install -r requirements.txt
安装其他插件
(open_manus) PS G:\OpenManus> pip install playwright
(open_manus) PS G:\OpenManus> playwright install
此处需要提前安装Microsoft Visual C++ Redistributable ,最好提前安装谷歌和火狐浏览器.
三.配置OpenManus
设置基本配置
生成配置文件,也可以直接跳过,web界面配置
(open_manus) PS G:\OpenManus> cp config/config.example.toml config/config.toml
编辑这个文件或之后从web界面配置
# Global LLM configuration
[llm]
#模型名
model = "claude-3-5-sonnet"
#模型链接
base_url = "https://api.openai.com/v1"
#api-key,使用本地ollama跳过,lm studio的填lm-studio
api_key = "sk-..."
#上下文长度,根据自己环境填
max_tokens = 4096
temperature = 0.0
# Optional configuration for specific LLM models
[llm.vision]
model = "claude-3-5-sonnet"
base_url = "https://api.openai.com/v1"
api_key = "sk-..."
# Server configuration
[server]
host = "localhost"
port = 5172
保存后试运行
(open_manus) PS G:\OpenManus> python app.py
INFO [browser_use] BrowserUse logging setup complete with level info
INFO [root] Anonymized telemetry enabled. See https://docs.browser-use.com/development/telemetry for more information.
INFO: Started server process [39468]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://localhost:5172 (Press CTRL+C to quit)
INFO: ::1:57893 - "GET / HTTP/1.1" 200 OK
INFO: ::1:57893 - "GET /static/style.css HTTP/1.1" 200 OK
INFO: ::1:57894 - "GET /static/main.js HTTP/1.1" 200 OK
INFO: ::1:57894 - "GET /config/status HTTP/1.1" 200 OK
INFO: ::1:57893 - "GET /tasks HTTP/1.1" 200 OK
INFO: ::1:57893 - "GET /favicon.ico HTTP/1.1" 404 Not Found
INFO: ::1:58084 - "GET /config/status HTTP/1.1" 200 OK
这会跳出浏览器,建议选择谷歌
在这也能设置模型链接配置
细化配置
模型本地建议使用QwQ-32b
远端模型需要支持工具调用类型的,选择标签有tools的模型
搜索插件本地化
默认用的是GoogleSearch,国内无法使用,所以我们需要小改一下,把GoogleSearch改成BaiduSearch或者BingSearch。
在OpenManus/app/tool文件夹下新建baidu_search.py和bing_search.py
baidu_search.py
import asyncio
from typing import List
from baidusearch.baidusearch import search
from app.tool.base import BaseTool
class BaiduSearch(BaseTool):
name: str = "baidu_search"
description: str = """Perform a Baidu 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 Baidu.",
},
"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 Baidu search and return a list of URLs.
Args:
query (str): The search query to submit to Baidu.
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: [result['url'] for result in search(query, num_results=num_results)]
)
return links
bing_search.py
import aiohttp
from bs4 import BeautifulSoup
from typing import List
from app.tool.base import BaseTool
class BingSearch(BaseTool):
name: str = "bing_search"
description: str = """使用必应搜索返回相关链接列表。
当需要查找网络信息、获取最新数据或研究特定主题时使用此工具。
该工具返回与搜索查询匹配的URL列表。
"""
parameters: dict = {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "(必填) 提交给必应的搜索查询。",
},
"num_results": {
"type": "integer",
"description": "(可选) 要返回的搜索结果数量。默认为10。",
"default": 10,
},
},
"required": ["query"],
}
async def execute(self, query: str, num_results: int = 10) -> List[str]:
"""
执行必应搜索并返回URL列表。
参数:
query (str): 要提交给必应的搜索查询。
num_results (int, optional): 要返回的搜索结果数量。默认为10。
返回:
List[str]: 与搜索查询匹配的URL列表。
"""
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
}
search_url = f"https://www.bing.com/search?q={query}"
async with aiohttp.ClientSession() as session:
try:
async with session.get(search_url, headers=headers) as response:
response.raise_for_status()
html = await response.text()
except Exception as e:
raise RuntimeError(f"必应搜索请求失败: {str(e)}")
soup = BeautifulSoup(html, 'html.parser')
links = []
# 必应搜索结果链接通常在类名为"b_algo"的div内,具体选择器可能需要根据实际页面结构调整
for result in soup.select('.b_algo'):
a_tag = result.select_one('a')
if a_tag and 'href' in a_tag.attrs:
link = a_tag['href']
links.append(link)
if len(links) >= num_results:
break
return links[:num_results]
并安装依赖
(open_manus) PS G:\OpenManus> pip install baidusearch
(open_manus) PS G:\OpenManus> pip install aiohttp beautifulsoup4
修改OpenManus/app/agent/manus.py文件,记得安装依赖,如下图所示(以baidu_search为例,bing_search同理):
文件开头
from pydantic import Field
from app.agent.toolcall import ToolCallAgent
from app.prompt.manus import NEXT_STEP_PROMPT, SYSTEM_PROMPT
from app.tool import Terminate, ToolCollection
from app.tool.browser_use_tool import BrowserUseTool
from app.tool.file_saver import FileSaver
#from app.tool.google_search import GoogleSearch
#使用百度就导入BaiduSearch,使用bing就导入bing_search
from app.tool.bing_search import BingSearch
from app.tool.python_execute import PythonExecute
文件末尾修改搜索方法为BaiduSearch
# Add general-purpose tools to the tool collection
available_tools: ToolCollection = Field(
default_factory=lambda: ToolCollection(
#PythonExecute(), GoogleSearch(), BrowserUseTool(), FileSaver(), Terminate()
PythonExecute(), BingSearch(), BrowserUseTool(), FileSaver(), Terminate()
)
然后运行
(open_manus) PS G:\OpenManus> python app.py
接下来就把电脑的活交给电脑去做把
运行步骤过多可以在manus.py 32行max_steps: int = 这修改