-
Notifications
You must be signed in to change notification settings - Fork 13.4k
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
ChatZhipuAI invoke error #17863
Comments
🤖 Hey @yskgood! Great to see you diving into another challenge with LangChain. 👋 Let's crack this one together too! Thank you for providing detailed information about the issue you're facing. The error message you're seeing, "AttributeError: module 'zhipuai' has no attribute 'model_api'", suggests that the 'zhipuai' module does not have an attribute or method named 'model_api'. In the provided context, the 'zhipuai' module is used in the 'invoke', 'sse_invoke', 'async_invoke', and 'async_invoke_result' methods of the 'ChatZhipuAI' class. In each of these methods, 'model_api' is called as an attribute of the 'zhipuai' module: self.zhipuai.model_api.invoke(...)
self.zhipuai.model_api.sse_invoke(...)
self.zhipuai.model_api.async_invoke(...)
self.zhipuai.model_api.query_async_invoke_result(...) If the 'zhipuai' module does not have a 'model_api' attribute, these calls will fail with an AttributeError. To resolve this issue, you should check the following:
The 'zhipuai' module in the LangChain framework is a wrapper for the ZHIPU AI large language chat models API. It provides an interface to interact with the ZHIPU AI's language models, which can be used to complete a variety of language tasks based on the input of natural language instructions. The 'zhipuai' module provides the The The The Here is an example of how to use the from langchain_community.chat_models import ChatZhipuAI
zhipuai_chat = ChatZhipuAI(
temperature=0.5,
api_key="your-api-key",
model="chatglm_turbo",
) In this example, a Please let me know if this helps or if you need further assistance. Sources
|
Maybe you need upgrade zhipuai |
I just encountered the same problem, and I have also upgraded |
I have found the reason. The original official Python SDK of ZHIPUAI has transferred to zhipuai-sdk-python-v4. The new version |
Do you know how to fix it? I got the same problem. |
I‘ll handle it. |
I encountered the same issue, how to fix it?? |
1 similar comment
I encountered the same issue, how to fix it?? |
Check this #16695 |
Checked other resources
Example Code
When I was testing with the ChatZhipuAI provided by the official documentation, an AttributeError occurred: module 'zhipuai' has no attribute 'model_api'. The documentation URL is:https://python.langchain.com/docs/integrations/chat/zhipuai
Error Message and Stack Trace (if applicable)
Traceback (most recent call last):
File "/Users/ysk/Library/Mobile Documents/com
appleCloudDocs/langchain/zhipu/simple.py", line 17, inresponse = chat(messages)
File "/Users/ysk/anaconda3/envs/langchain/lib/python3.10/site-packages/langchain_core/_api/deprecation.py", line 145, in warning_emitting_wrapper
return wrapped(*args, **kwargs)
File "/Users/ysk/anaconda3/envs/langchain/lib/python3.10/site-packages/langchain_core/language_models/chat_models.py", line 691, in call
generation = self.generate(
File "/Users/ysk/anaconda3/envs/langchain/lib/python3.10/site-packages/langchain_core/language_models/chat_models.py", line 408, in generate
raise e
File "/Users/ysk/anaconda3/envs/langchain/lib/python3.10/site-packages/langchain_core/language_models/chat_models.py", line 398, in generate
self._generate_with_cache(
File "/Users/ysk/anaconda3/envs/langchain/lib/python3.10/site-packages/langchain_core/language_models/chat_models.py", line 577, in _generate_with_cache
return self._generate(
File "/Users/ysk/anaconda3/envs/langchain/lib/python3.10/site-packages/langchain_community/chat_models/zhipuai.py", line 265, in _generate
response = self.invoke(prompt)
File "/Users/ysk/anaconda3/envs/langchain/lib/python3.10/site-packages/langchain_community/chat_models/zhipuai.py", line 183, in invoke
return self.zhipuai.model_api.invoke(
AttributeError: module 'zhipuai' has no attribute 'model_api'
Description
I was testing with the ChatZhipuAI provided by the official documentation
System Info
langchain==0.1.8
langchain-community==0.0.21
langchain-core==0.1.24
langchain-openai==0.0.6
langchainhub==0.1.14
platform mac
python 3.10
The text was updated successfully, but these errors were encountered: