openmanus是一款开源的agent应用,agent定义是通过执行器完成指定环境以实现特定目标的实体代理。openmanus是内部多环节反复与智能大模型(AI LLM)进行交互,针对特定目标完成一系列的操作,代替人工实际操作。 openmanus的安装是基于anaconda环境的,运行在python平台,因为是python代码实现的主函数。
代码如下:
import asyncio from app.agent.manus import Manus from app.logger import logger
async def main(): agent = Manus() while True: try: prompt = input("Enter your prompt (or 'exit' to quit): ") if prompt.lower() == "exit": logger.info("Goodbye!") break if prompt.strip().isspace(): logger.warning("Skipping empty prompt.") continue logger.warning("Processing your request...") await agent.run(prompt) except KeyboardInterrupt: logger.warning("Goodbye!") break
if name == "main": asyncio.run(main())
基于anaconda是因为它可以作为工具集的入口。 可以修改openmanus的config文件夹下config.example文件,另存为config文件,在openmanus的main文件运行时使用。
config文件配置如下:
Global LLM configuration
[llm]
model = "qwen-plus"
base_url = "dashscope.aliyuncs.com/compatible-…"
api_key = "sk-fyb###"
max_tokens = 4096
temperature = 0.0
[llm] #AZURE OPENAI:
[llm.vision]
model = "qwen-plus"
base_url = "dashscope.aliyuncs.com/compatible-…"
api_key = "sk-fyb###"
这里大模型llm可以使用互联网的大模型api,也可以使用ollama的本地大模型,但是本地大模型的性能会影响openmanus的运行效率与运行结果。 如果使用本地的ollama模型,就将base_url设置如下:
base_url = "http://http://localhost:11434/"
model = "填写ollama运行的模型名字"
api_key = "sk-123"
ollama大模型的选择,可以根据自己任务选择对应的模型。 大模型有擅长文生图的,有擅长语音转文字的,有擅长推理的,各有所长,选择对应的模型很重要。