AutoGen AttributeError: ‘str‘ object has no attribute ‘model‘

目录

一、错误

二、解决方法


一、错误

AutoGen 本地运行,运行时错误如下所示。

(autogen) D:\code\autogen>python main.py
[33muser_proxy[0m (to assistant):

Tell me a joke about NVDA and TESLA stock prices.

--------------------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\code\autogen\main.py", line 12, in <module>
    user_proxy.initiate_chat(
  File "D:\Software\python3.10.9\lib\site-packages\autogen\agentchat\conversable_agent.py", line 1018, in initiate_chat
    self.send(msg2send, recipient, silent=silent)
  File "D:\Software\python3.10.9\lib\site-packages\autogen\agentchat\conversable_agent.py", line 655, in send
    recipient.receive(message, self, request_reply, silent)
  File "D:\Software\python3.10.9\lib\site-packages\autogen\agentchat\conversable_agent.py", line 818, in receive
    reply = self.generate_reply(messages=self.chat_messages[sender], sender=sender)
  File "D:\Software\python3.10.9\lib\site-packages\autogen\agentchat\conversable_agent.py", line 1972, in generate_reply
    final, reply = reply_func(self, messages=messages, sender=sender, config=reply_func_tuple["config"])
  File "D:\Software\python3.10.9\lib\site-packages\autogen\agentchat\conversable_agent.py", line 1340, in generate_oai_reply
    extracted_response = self._generate_oai_reply_from_client(
  File "D:\Software\python3.10.9\lib\site-packages\autogen\agentchat\conversable_agent.py", line 1359, in _generate_oai_reply_from_client
    response = llm_client.create(
  File "D:\Software\python3.10.9\lib\site-packages\autogen\oai\client.py", line 755, in create
    response.cost = client.cost(response)
  File "D:\Software\python3.10.9\lib\site-packages\autogen\oai\client.py", line 326, in cost
    model = response.model
AttributeError: 'str' object has no attribute 'model'

二、解决方法

开始配置的 llm_config 如下所示。

llm_config = {"model": "moonshot-v1-8k", 
              "api_key": str_key,
              "base_url": "http://172.29.19.146:3001"}

修改 base_url 在端口后面加上 /v1 即可,如下所示。

llm_config = {"model": "moonshot-v1-8k", 
              "api_key": str_key,
              "base_url": "http://172.29.19.146:3001/v1"}

参考链接:

[1] [BUG] 添加openai模型报错,‘str’ object has no attribute ‘model_dump’ · Issue #63 · 1Panel-dev/MaxKB · GitHub

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-15 18:52:04       66 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-15 18:52:04       70 阅读
  3. 在Django里面运行非项目文件

    2024-07-15 18:52:04       57 阅读
  4. Python语言-面向对象

    2024-07-15 18:52:04       68 阅读

热门阅读

  1. 【ROS2】测试

    2024-07-15 18:52:04       21 阅读
  2. 「Conda」在Linux系统中安装Conda环境管理器

    2024-07-15 18:52:04       18 阅读
  3. Python学习的第一天7.15

    2024-07-15 18:52:04       24 阅读
  4. 动态内存管理(C)

    2024-07-15 18:52:04       23 阅读
  5. 算法的时间复杂度和空间复杂度-概念

    2024-07-15 18:52:04       19 阅读
  6. Matlab

    Matlab

    2024-07-15 18:52:04      20 阅读
  7. C/C++指针&智能指针二

    2024-07-15 18:52:04       15 阅读