mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-29 07:19:59 +00:00
- **Description: fix hunyuan appid type - **Issue: https://github.com/langchain-ai/langchain/pull/12022#issuecomment-1815627855
169 lines
3.7 KiB
Plaintext
169 lines
3.7 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Tencent Hunyuan\n",
|
|
"\n",
|
|
"Hunyuan chat model API by Tencent. For more information, see [https://cloud.tencent.com/document/product/1729](https://cloud.tencent.com/document/product/1729)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {
|
|
"ExecuteTime": {
|
|
"end_time": "2023-10-19T10:20:38.718834Z",
|
|
"start_time": "2023-10-19T10:20:38.264050Z"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"from langchain.chat_models import ChatHunyuan\n",
|
|
"from langchain.schema import HumanMessage"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"metadata": {
|
|
"ExecuteTime": {
|
|
"end_time": "2023-10-19T10:19:53.529876Z",
|
|
"start_time": "2023-10-19T10:19:53.526210Z"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"chat = ChatHunyuan(\n",
|
|
" hunyuan_app_id=111111111,\n",
|
|
" hunyuan_secret_id=\"YOUR_SECRET_ID\",\n",
|
|
" hunyuan_secret_key=\"YOUR_SECRET_KEY\",\n",
|
|
")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {
|
|
"ExecuteTime": {
|
|
"end_time": "2023-10-19T10:19:56.054289Z",
|
|
"start_time": "2023-10-19T10:19:53.531078Z"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": "AIMessage(content=\"J'aime programmer.\")"
|
|
},
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"chat(\n",
|
|
" [\n",
|
|
" HumanMessage(\n",
|
|
" content=\"You are a helpful assistant that translates English to French.Translate this sentence from English to French. I love programming.\"\n",
|
|
" )\n",
|
|
" ]\n",
|
|
")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"source": [
|
|
"## For ChatHunyuan with Streaming"
|
|
],
|
|
"metadata": {
|
|
"collapsed": false
|
|
}
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"outputs": [],
|
|
"source": [
|
|
"chat = ChatHunyuan(\n",
|
|
" hunyuan_app_id=\"YOUR_APP_ID\",\n",
|
|
" hunyuan_secret_id=\"YOUR_SECRET_ID\",\n",
|
|
" hunyuan_secret_key=\"YOUR_SECRET_KEY\",\n",
|
|
" streaming=True,\n",
|
|
")"
|
|
],
|
|
"metadata": {
|
|
"collapsed": false,
|
|
"ExecuteTime": {
|
|
"end_time": "2023-10-19T10:20:41.507720Z",
|
|
"start_time": "2023-10-19T10:20:41.496456Z"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": "AIMessageChunk(content=\"J'aime programmer.\")"
|
|
},
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"chat(\n",
|
|
" [\n",
|
|
" HumanMessage(\n",
|
|
" content=\"You are a helpful assistant that translates English to French.Translate this sentence from English to French. I love programming.\"\n",
|
|
" )\n",
|
|
" ]\n",
|
|
")"
|
|
],
|
|
"metadata": {
|
|
"collapsed": false,
|
|
"ExecuteTime": {
|
|
"end_time": "2023-10-19T10:20:46.275673Z",
|
|
"start_time": "2023-10-19T10:20:44.241097Z"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"outputs": [],
|
|
"source": [],
|
|
"metadata": {
|
|
"collapsed": false,
|
|
"ExecuteTime": {
|
|
"start_time": "2023-10-19T10:19:56.233477Z"
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"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
|
|
}
|