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

请问这个报错如何解决?Error: module 'zhipuai' has no attribute 'ZhipuAI' #166

Open
lisdoo opened this issue Sep 24, 2024 · 2 comments

Comments

@lisdoo
Copy link

lisdoo commented Sep 24, 2024

代码如下:

Import and Init Settings

import Agently
agent = Agently.create_agent()
agent.set_settings("current_model", "ZhipuAI").set_settings("model.ZhipuAI.auth", { "api_key": "" })

Interact with the agent instance like calling a function

result = agent
.input("Give me 3 words")
.output([("String", "one word")])
.start()
print(result)

异常如下:
PS E:\git\Agently> & C:/Users/Administrator/.virtualenvs/rasa-paddlenlp-ernie-878cdtQU/Scripts/python.exe e:/git/Agently/ii.py
[WARNING][2024-09-24 22:10:28.367] redis_rate_limiter.py:21 [t:24624]: no redis installed, RedisRateLimiter unavailable
Exception in thread Thread-1:
Traceback (most recent call last):
File "e:\git\Agently\Agently\Agent\Agent.py", line 210, in start_async
event_generator = await self.request.get_event_generator(request_type)
File "e:\git\Agently\Agently\Request\Request.py", line 117, in get_event_generator
response_generator = await request_plugin_export"request_model"
File "e:\git\Agently\Agently\plugins\request\ZhipuAI.py", line 192, in request_model
client = zhipuai.ZhipuAI(api_key = zhipuai.api_key)
AttributeError: module 'zhipuai' has no attribute 'ZhipuAI'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "e:\git\Agently\Agently\Agent\Agent.py", line 210, in start_async
event_generator = await self.request.get_event_generator(request_type)
File "e:\git\Agently\Agently\Request\Request.py", line 117, in get_event_generator
response_generator = await request_plugin_export"request_model"
File "e:\git\Agently\Agently\plugins\request\ZhipuAI.py", line 192, in request_model
client = zhipuai.ZhipuAI(api_key = zhipuai.api_key)
AttributeError: module 'zhipuai' has no attribute 'ZhipuAI'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "e:\git\Agently\Agently\Agent\Agent.py", line 298, in start_in_theard
reply = loop.run_until_complete(self.start_async(request_type))
File "asyncio\base_events.py", line 647, in run_until_complete
File "e:\git\Agently\Agently\Agent\Agent.py", line 285, in start_async
return await self.start_async(request_type, return_generator=return_generator)
File "e:\git\Agently\Agently\Agent\Agent.py", line 285, in start_async
return await self.start_async(request_type, return_generator=return_generator)
File "e:\git\Agently\Agently\Agent\Agent.py", line 279, in start_async
raise(e)
File "e:\git\Agently\Agently\Agent\Agent.py", line 210, in start_async
event_generator = await self.request.get_event_generator(request_type)
File "e:\git\Agently\Agently\Request\Request.py", line 117, in get_event_generator
response_generator = await request_plugin_export"request_model"
File "e:\git\Agently\Agently\plugins\request\ZhipuAI.py", line 192, in request_model
client = zhipuai.ZhipuAI(api_key = zhipuai.api_key)
AttributeError: module 'zhipuai' has no attribute 'ZhipuAI'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "threading.py", line 980, in _bootstrap_inner
File "threading.py", line 917, in run
File "e:\git\Agently\Agently\Agent\Agent.py", line 302, in start_in_theard
raise Exception(f"[Agent Request] Error: { str(e) }")
Exception: [Agent Request] Error: module 'zhipuai' has no attribute 'ZhipuAI'
None
PS E:\git\Agently>

@lisdoo
Copy link
Author

lisdoo commented Sep 24, 2024

我使用的的版本是Tags v3.3.4.8
智谱的版本是:
PS E:\git\Agently> pip show zhipuai
Name: zhipuai
Version: 1.0.7
Summary: A SDK library for accessing big model apis from ZhipuAI
Home-page: https://open.bigmodel.cn/
Author: Zhipu AI
Author-email:
License:
Location: c:\users\administrator.virtualenvs\rasa-paddlenlp-ernie-878cdtqu\lib\site-packages
Requires: cachetools, dataclasses, PyJWT, requests
Required-by: Agently
PS E:\git\Agently>

@Maplemx
Copy link
Owner

Maplemx commented Sep 25, 2024

智谱接口目前已经适配了OpenAI,可以使用OAIClient进行请求,框架目前适配的是旧版本的客户端,逐步弃用了(跟原来的Kimi适配一样)

可以参考OAIClient的使用方式进行使用:https://agently.tech/guides/model_settings/oaiclient.html

我后续会更新官网的文档进行提示

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants