mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-25 16:13:25 +00:00
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.
This commit is contained in:
parent
9ea28ee464
commit
0b393315ce
@ -17,7 +17,7 @@
|
|||||||
"\n",
|
"\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",
|
"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",
|
"\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",
|
"\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",
|
">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",
|
"\n",
|
||||||
@ -43,15 +43,6 @@
|
|||||||
"After installation, import the necessary modules to your Python script:"
|
"After installation, import the necessary modules to your Python script:"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 2,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"import zhipuai"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 3,
|
"execution_count": 3,
|
||||||
@ -95,7 +86,7 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"chat = ChatZhipuAI(\n",
|
"chat = ChatZhipuAI(\n",
|
||||||
" temperature=0.5,\n",
|
" temperature=0.5,\n",
|
||||||
" zhipuai_api_key=zhipuai_api_key,\n",
|
" api_key=zhipuai_api_key,\n",
|
||||||
" model=\"chatglm_turbo\",\n",
|
" model=\"chatglm_turbo\",\n",
|
||||||
")"
|
")"
|
||||||
]
|
]
|
||||||
@ -168,7 +159,7 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"streaming_chat = ChatZhipuAI(\n",
|
"streaming_chat = ChatZhipuAI(\n",
|
||||||
" temperature=0.5,\n",
|
" temperature=0.5,\n",
|
||||||
" zhipuai_api_key=zhipuai_api_key,\n",
|
" api_key=zhipuai_api_key,\n",
|
||||||
" model=\"chatglm_turbo\",\n",
|
" model=\"chatglm_turbo\",\n",
|
||||||
" streaming=True,\n",
|
" streaming=True,\n",
|
||||||
" callback_manager=CallbackManager([StreamingStdOutCallbackHandler()]),\n",
|
" callback_manager=CallbackManager([StreamingStdOutCallbackHandler()]),\n",
|
||||||
@ -221,7 +212,7 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"async_chat = ChatZhipuAI(\n",
|
"async_chat = ChatZhipuAI(\n",
|
||||||
" temperature=0.5,\n",
|
" temperature=0.5,\n",
|
||||||
" zhipuai_api_key=zhipuai_api_key,\n",
|
" api_key=zhipuai_api_key,\n",
|
||||||
" model=\"chatglm_turbo\",\n",
|
" model=\"chatglm_turbo\",\n",
|
||||||
")"
|
")"
|
||||||
]
|
]
|
||||||
@ -297,7 +288,7 @@
|
|||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"character_chat = ChatZhipuAI(\n",
|
"character_chat = ChatZhipuAI(\n",
|
||||||
" zhipuai_api_key=zhipuai_api_key,\n",
|
" api_key=zhipuai_api_key,\n",
|
||||||
" meta=meta,\n",
|
" meta=meta,\n",
|
||||||
" model=\"characterglm\",\n",
|
" model=\"characterglm\",\n",
|
||||||
" streaming=True,\n",
|
" streaming=True,\n",
|
||||||
@ -354,4 +345,5 @@
|
|||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
"nbformat_minor": 4
|
"nbformat_minor": 4
|
||||||
}
|
}
|
||||||
|
|
@ -35,17 +35,19 @@ class ChatZhipuAI(BaseChatModel):
|
|||||||
"""
|
"""
|
||||||
`ZHIPU AI` large language chat models API.
|
`ZHIPU AI` large language chat models API.
|
||||||
|
|
||||||
To use, you should have the ``zhipuai`` python package installed, and the
|
To use, you should have the ``zhipuai`` python package installed.
|
||||||
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.
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
from langchain_community.chat_models import ChatZhipuAI
|
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
|
zhipuai: Any
|
||||||
|
Loading…
Reference in New Issue
Block a user