Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

按教程写代码。报错 #11

Open
D-Cyans opened this issue Sep 4, 2023 · 5 comments
Open

按教程写代码。报错 #11

D-Cyans opened this issue Sep 4, 2023 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@D-Cyans
Copy link

D-Cyans commented Sep 4, 2023

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

@ZeyuChen ZeyuChen added the question Further information is requested label Sep 4, 2023
@Bobholamovic
Copy link
Member

你好,我无法在新建的Python3.9环境中复现这个问题。请提供你使用的环境的Python版本以及erniebot版本~

@D-Cyans
Copy link
Author

D-Cyans commented Sep 5, 2023

你好,我无法在新建的Python3.9环境中复现这个问题。请提供你使用的环境的Python版本以及版本~erniebot

erniebot 0.1.0
Python 3.9.7

@Bobholamovic
Copy link
Member

image

看起来我使用相同的环境还是无法复现这个问题~ 请问你有对代码做修改吗?

@D-Cyans
Copy link
Author

D-Cyans commented Sep 7, 2023

image

看起来我使用相同的环境还是无法复现这个问题~ 请问你有对代码做修改吗?

没有

@Bobholamovic
Copy link
Member

因为我无法复现这个问题,所以不太容易定位原因。建议可以拉取develop分支的最新代码再次尝试~

qingzhong1 pushed a commit to qingzhong1/ERNIE-Bot-SDK that referenced this issue Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants