community: Correct Input API Key Name in Notebook and Enhance Readability of Comments for ZhipuAI Chat Model (#15529)

- **Description:** This update rectifies an error in the notebook by
changing the input variable from `zhipu_api_key` to `api_key`. It also
includes revisions to comments to improve program readability.
- **Issue:** The input variable in the notebook example should be
`api_key` instead of `zhipu_api_key`.
- **Dependencies:** No additional dependencies are required for this
change.

To ensure quality and standards, we have performed extensive linting and
testing. Commands such as make format, make lint, and make test have
been run from the root of the modified package to ensure compliance with
LangChain's coding standards.
pull/15658/head
Nan LI 9 months ago committed by GitHub
parent 9ea28ee464
commit 0b393315ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,7 +17,7 @@
"\n",
"This notebook shows how to use [ZHIPU AI API](https://open.bigmodel.cn/dev/api) in LangChain with the langchain.chat_models.ChatZhipuAI.\n",
"\n",
">[*ZHIPU AI*](https://open.bigmodel.cn/) is a multi-lingual large language model aligned with human intent, featuring capabilities in Q&A, multi-turn dialogue, and code generation, developed on the foundation of the [ChatGLM - Turbo model](https://open.bigmodel.cn/pricing). \n",
">[*ZHIPU AI*](https://open.bigmodel.cn/) is a multi-lingual large language model aligned with human intent, featuring capabilities in Q&A, multi-turn dialogue, and code generation, developed on the foundation of the ChatGLM3. \n",
"\n",
">It's co-developed with Tsinghua University's KEG Laboratory under the ChatGLM3 project, signifying a new era in dialogue pre-training models. The open-source [ChatGLM3](https://github.com/THUDM/ChatGLM3) variant boasts a robust foundation, comprehensive functional support, and widespread availability for both academic and commercial uses. \n",
"\n",
@ -43,15 +43,6 @@
"After installation, import the necessary modules to your Python script:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import zhipuai"
]
},
{
"cell_type": "code",
"execution_count": 3,
@ -95,7 +86,7 @@
"source": [
"chat = ChatZhipuAI(\n",
" temperature=0.5,\n",
" zhipuai_api_key=zhipuai_api_key,\n",
" api_key=zhipuai_api_key,\n",
" model=\"chatglm_turbo\",\n",
")"
]
@ -168,7 +159,7 @@
"source": [
"streaming_chat = ChatZhipuAI(\n",
" temperature=0.5,\n",
" zhipuai_api_key=zhipuai_api_key,\n",
" api_key=zhipuai_api_key,\n",
" model=\"chatglm_turbo\",\n",
" streaming=True,\n",
" callback_manager=CallbackManager([StreamingStdOutCallbackHandler()]),\n",
@ -221,7 +212,7 @@
"source": [
"async_chat = ChatZhipuAI(\n",
" temperature=0.5,\n",
" zhipuai_api_key=zhipuai_api_key,\n",
" api_key=zhipuai_api_key,\n",
" model=\"chatglm_turbo\",\n",
")"
]
@ -297,7 +288,7 @@
"outputs": [],
"source": [
"character_chat = ChatZhipuAI(\n",
" zhipuai_api_key=zhipuai_api_key,\n",
" api_key=zhipuai_api_key,\n",
" meta=meta,\n",
" model=\"characterglm\",\n",
" streaming=True,\n",
@ -355,3 +346,4 @@
"nbformat": 4,
"nbformat_minor": 4
}

@ -35,17 +35,19 @@ class ChatZhipuAI(BaseChatModel):
"""
`ZHIPU AI` large language chat models API.
To use, you should have the ``zhipuai`` python package installed, and the
environment variable ``ZHIPUAI_API_KEY`` set with your API key.
Any parameters that are valid to be passed to the zhipuai.create call can be passed
in, even if not explicitly saved on this class.
To use, you should have the ``zhipuai`` python package installed.
Example:
.. code-block:: python
from langchain_community.chat_models import ChatZhipuAI
zhipuai = ChatZhipuAI()
zhipuai_chat = ChatZhipuAI(
temperature=0.5,
api_key="your-api-key",
model="chatglm_turbo",
)
"""
zhipuai: Any

Loading…
Cancel
Save