ERNIE-SDK icon indicating copy to clipboard operation
ERNIE-SDK copied to clipboard

按教程写代码。报错

Open D-Cyans opened this issue 1 year ago • 5 comments

chat_completion = erniebot.ChatCompletion.create(model="ernie-bot-3.5", messages=[{"role": "user", "content": "你好,请介绍下你自己"}])

print(chat_completion.result)

19 # Create a chat completion ---> 20 chat_completion = erniebot.ChatCompletion.create(model="ernie-bot-3.5", messages=[{"role": "user", "content": "你好,请介绍下你自己"}]) 22 print(chat_completion.result)

File /opt/conda/lib/python3.9/site-packages/erniebot/resources/abc/creatable.py:39, in Creatable.create(cls, **create_kwargs) 28 @classmethod 29 def create(cls, 30 **create_kwargs: Any) -> Union[EBResponse, Iterator[EBResponse]]: 31 """Create a new resource. 32 33 Args: (...) 37 Response from the server. 38 """ ---> 39 resource = cls.new_object() 40 return resource.create_resource(**create_kwargs)

File /opt/conda/lib/python3.9/site-packages/erniebot/resources/resource.py:68, in EBResource.new_object(cls, **kwargs) 66 @classmethod 67 def new_object(cls, **kwargs: Any) -> Self: ---> 68 return cls(**kwargs)

File /opt/conda/lib/python3.9/site-packages/erniebot/resources/resource.py:55, in EBResource.init(self, **kwargs) 54 def init(self, **kwargs: Any) -> None: ---> 55 super().init() 57 self._cfg = self._create_config_dict(**kwargs) 59 self.api_type = self._cfg['api_type']

File /opt/conda/lib/python3.9/typing.py:1083, in _no_init(self, *args, **kwargs) 1082 def _no_init(self, *args, **kwargs): -> 1083 raise TypeError('Protocols cannot be instantiated')

TypeError: Protocols cannot be instantiated

D-Cyans avatar Sep 04 '23 06:09 D-Cyans