什么原因导致“对象没有字段 xyz”错误?

问题描述 投票:0回答:1

我的类定义导致异常:

ValueError:“WithDataLLM”对象没有字段“url”

关于 self.url = 赋值。为什么?

class WithDataLLM(LLM):
    __slots__ = ("url", "headers", "data_sources")
    def __init__(self, openAIServiceName, deploymentName, openAIServiceKey, searchServiceName, searchApiKey, indexName, indexRoleDescription, **kwargs):
        super().__init__(**kwargs)
        self.url = f"{openAIServiceName}/openai/..."
python
1个回答
0
投票

您使用的老虎机

允许我们显式声明数据成员(如属性)并拒绝创建 dict

这样做后,我们不能像使用

__dict__
时那样添加属性,使用
self.url = ...

尝试做什么
© www.soinside.com 2019 - 2024. All rights reserved.