mirror of
https://github.com/hwchase17/langchain.git
synced 2025-05-18 13:31:36 +00:00
- **Description:** add deprecated warning for ErnieBotChat and ErnieEmbeddings. - These two classes **lack maintenance** and do not use the sdk provided by qianfan, which means hard to implement some key feature like streaming. - The alternative `langchain_community.chat_models.QianfanChatEndpoint` and `langchain_community.embeddings.QianfanEmbeddingsEndpoint` can completely replace these two classes, only need to change configuration items. - **Issue:** None, - **Dependencies:** None, - **Twitter handle:** None --------- Co-authored-by: Bagatur <baskaryan@gmail.com>
142 lines
3.6 KiB
Plaintext
142 lines
3.6 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "raw",
|
|
"metadata": {},
|
|
"source": [
|
|
"---\n",
|
|
"sidebar_label: Ernie Bot Chat\n",
|
|
"---"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# ErnieBotChat\n",
|
|
"\n",
|
|
"[ERNIE-Bot](https://cloud.baidu.com/doc/WENXINWORKSHOP/s/jlil56u11) is a large language model developed by Baidu, covering a huge amount of Chinese data.\n",
|
|
"This notebook covers how to get started with ErnieBot chat models."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"**Deprecated Warning**\n",
|
|
"\n",
|
|
"We recommend users using `langchain_community.chat_models.ErnieBotChat` \n",
|
|
"to use `langchain_community.chat_models.QianfanChatEndpoint` instead.\n",
|
|
"\n",
|
|
"documentation for `QianfanChatEndpoint` is [here](./baidu_qianfan_endpoint).\n",
|
|
"\n",
|
|
"they are 4 why we recommend users to use `QianfanChatEndpoint`:\n",
|
|
"\n",
|
|
"1. `QianfanChatEndpoint` support more LLM in the Qianfan platform.\n",
|
|
"2. `QianfanChatEndpoint` support streaming mode.\n",
|
|
"3. `QianfanChatEndpoint` support function calling usgage.\n",
|
|
"4. `ErnieBotChat` is lack of maintenance and deprecated."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Some tips for migration:\n",
|
|
"\n",
|
|
"- change `ernie_client_id` to `qianfan_ak`, also change `ernie_client_secret` to `qianfan_sk`.\n",
|
|
"- install `qianfan` package. like `pip install qianfan`\n",
|
|
"- change `ErnieBotChat` to `QianfanChatEndpoint`."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from langchain_community.chat_models.baidu_qianfan_endpoint import QianfanChatEndpoint\n",
|
|
"\n",
|
|
"chat = QianfanChatEndpoint(\n",
|
|
" qianfan_ak=\"your qianfan ak\",\n",
|
|
" qianfan_sk=\"your qianfan sk\",\n",
|
|
")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Usage"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 13,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from langchain.schema import HumanMessage\n",
|
|
"from langchain_community.chat_models import ErnieBotChat\n",
|
|
"\n",
|
|
"chat = ErnieBotChat(\n",
|
|
" ernie_client_id=\"YOUR_CLIENT_ID\", ernie_client_secret=\"YOUR_CLIENT_SECRET\"\n",
|
|
")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"or you can set `client_id` and `client_secret` in your environment variables\n",
|
|
"```bash\n",
|
|
"export ERNIE_CLIENT_ID=YOUR_CLIENT_ID\n",
|
|
"export ERNIE_CLIENT_SECRET=YOUR_CLIENT_SECRET\n",
|
|
"```"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 15,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"AIMessage(content='Hello, I am an artificial intelligence language model. My purpose is to help users answer questions or provide information. What can I do for you?', additional_kwargs={}, example=False)"
|
|
]
|
|
},
|
|
"execution_count": 15,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"chat([HumanMessage(content=\"hello there, who are you?\")])"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3 (ipykernel)",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.11.4"
|
|
},
|
|
"orig_nbformat": 4
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|