无需邀请码,小白也能轻松使用Manus
1.先安装python环境,百度搜索安装conda(若已经有了就可以直接开始)
打开命令行窗口输入以下指令
sh
conda create -n open_manus python=3.12
conda activate open_manus
此时命令行前面,若带有(open_manus)则表示环境激活成功。
2.通过git 命令下载openManus代码
sh
git clone https://github.com/mannaandpoem/OpenManus.git
cd openManus
3.安装依赖环境
pip install -r requirements.txt
4.修改配置文件
4.1获取模型的app-key
若没有模型的app-key,可以注册硅基流动,通过下面链接进入可以免费获取api密钥,其中有赠送的余额,否则后面输入提示词后大模型api会返回402报错信息
http
https://cloud.siliconflow.cn/i/04IwSgIl
4.2修改config.toml配置文件
sh
cp config/config.example.toml config/config.toml
vim config/config.toml
sh
# Global LLM configuration
[llm]
model = "deepseek-chat" #我这里使用的deepseek模型,需要进行去充值token。
base_url = "https://api.deepseek.com/v1"
api_key = "sk-..." #替换为你模型的app-key
max_tokens = 4096
temperature = 0.0
# Optional configuration for specific LLM models
[llm.vision]
model = "deepseek-chat"
base_url = "https://api.deepseek.com/v1"
api_key = "sk-..." #替换为你模型的app-key
修改完毕后按 ESC, 输入:wq (冒号+wq+enter) 保存。
5.运行模型
python
python main.py
6.输入提示词
lua
编写HTHL5页面的贪吃蛇游戏可以正常玩,要求支持键盘操作。注意:处理相应的过程文件及结果文件都请放入当前目录 output/
若报错如下402,证明是app-key余额不足,则需前往4.1步骤重新获取
成功后
7.该项目默认采用google搜索,若无法科学上网,则需更换搜索引擎
7.1 更换百度搜索引擎
a.接着参考app/tool/google_search.py ,写一个baidu_search.py,我这里写好了直接复制到app/tool/下即可
python
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
b.修改app/agent/manus.py ,引入刚刚写好的baidu_search, 将原来的GoogleSearch() 替换为BaiduSearch(),
c.再而在控制台使用
pip
安装 python-baidusearch
:
bash
pip install baidusearch
7.2 更换为Bing搜索引擎,与上面百度类似
a.编写bing_search.py文件放入app/tool/目录下
python
import asyncio
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]
b.修改app/agent/manus.py ,引入刚刚写好的bing_search, 将原来的GoogleSearch() 替换为BingSearch(),
c.再而在控制台使用
pip
安装 aiohttp beautifulsoup4
:
sh
pip install aiohttp beautifulsoup4
以上三步就成功更换了搜索引擎,然后重新执行main.py即可验证。
tip:若出现更多问题可在下面链接寻求帮助
http
https://github.com/mannaandpoem/OpenManus/issues