Hanah

Hanah

wow agent day12 metaGPT安装和配置

参考:Datawhale wow agent day12
适用于 python 3.9+
pip install metagpt==0.8.0

根据Metagpt教程。

步骤#

  1. 创建 python 3.9 的虚拟环境:conda create -n metagpt python=3.9 && conda activate metagpt

  2. pip install metagpt

  3. metagpt --init-config 生成 yaml 文件。在 config 的文件夹下的 config2.yaml 里填写 API 配置。
    我这里是本地配置 ollama:
    llm:
    api_type: 'ollama'
    base_url: 'http://192.168.0.70:11434/api'
    model: 'qwen2:7b'

    repair_llm_output: true
    代码中 192.168.0.70 就是部署了大模型的电脑的 IP,

请根据实际情况进行替换

检验#

from metagpt.config2 import Config  
def print_llm_config():  
    # 加载默认配置  
    config = Config.default()  

    # 获取LLM配置  
    llm_config = config.llm  
    # 打印LLM配置的详细信息  
    if llm_config:  
        print(f"API类型: {llm_config.api_type}")  
        print(f"API密钥: {llm_config.api_key}")  
        print(f"模型: {llm_config.model}")  
    else:  
        print("没有配置LLM")  

if __name__ == "__main__":  
    print_llm_config()  
加载中...
此文章数据所有权由区块链加密技术和智能合约保障仅归创作者所有。