|
|
|
@ -14,6 +14,7 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"id": "b895d98989d4de01",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"## Basic use"
|
|
|
|
@ -21,13 +22,25 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"execution_count": 10,
|
|
|
|
|
"id": "43daa39972d4c533",
|
|
|
|
|
"metadata": {
|
|
|
|
|
"collapsed": false,
|
|
|
|
|
"is_executing": true
|
|
|
|
|
"ExecuteTime": {
|
|
|
|
|
"end_time": "2024-02-17T07:55:44.526904Z",
|
|
|
|
|
"start_time": "2024-02-17T07:55:43.166698Z"
|
|
|
|
|
},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"collapsed": false
|
|
|
|
|
},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"text/plain": "AIMessage(content='Hello! How can I help you today?')"
|
|
|
|
|
},
|
|
|
|
|
"execution_count": 10,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "execute_result"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"\"\"\"For basic init and call\"\"\"\n",
|
|
|
|
|
"from langchain_community.chat_models import ChatSparkLLM\n",
|
|
|
|
@ -62,14 +75,27 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"execution_count": 13,
|
|
|
|
|
"id": "7dc162bd65fec08f",
|
|
|
|
|
"metadata": {
|
|
|
|
|
"collapsed": false
|
|
|
|
|
},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"name": "stdout",
|
|
|
|
|
"output_type": "stream",
|
|
|
|
|
"text": [
|
|
|
|
|
"Hello! How can I help you today?"
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"chat = ChatSparkLLM(streaming=True)\n",
|
|
|
|
|
"chat = ChatSparkLLM(\n",
|
|
|
|
|
" spark_app_id=\"<app_id>\",\n",
|
|
|
|
|
" spark_api_key=\"<api_key>\",\n",
|
|
|
|
|
" spark_api_secret=\"<api_secret>\",\n",
|
|
|
|
|
" streaming=True,\n",
|
|
|
|
|
")\n",
|
|
|
|
|
"for chunk in chat.stream(\"Hello!\"):\n",
|
|
|
|
|
" print(chunk.content, end=\"\")"
|
|
|
|
|
]
|
|
|
|
|