Skip to content

Commit

Permalink
docs[patch]: Adds ChatOpenAI streamUsage docs on disabling stream usa…
Browse files Browse the repository at this point in the history
…ge (#6534)

* Adds ChatOpenAI streamUsage docs on disabling stream usage

* Fix notebook
  • Loading branch information
jacoblee93 authored Aug 15, 2024
1 parent d1d91a0 commit a93505f
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions docs/core_docs/docs/integrations/chat/openai.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,36 @@
"await llmWithCustomHeaders.invoke(\"Hi there!\");"
]
},
{
"cell_type": "markdown",
"id": "7af61d1d",
"metadata": {},
"source": [
"## Disabling streaming usage metadata\n",
"\n",
"Some proxies or third-party providers present largely the same API interface as OpenAI, but don't support the more recently added `stream_options` parameter to return streaming usage. You can use `ChatOpenAI` to access these providers by disabling streaming usage like this:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0ff40bd7",
"metadata": {},
"outputs": [],
"source": [
"import { ChatOpenAI } from \"@langchain/openai\";\n",
"\n",
"const llmWithoutStreamUsage = new ChatOpenAI({\n",
" temperature: 0.9,\n",
" streamUsage: false,\n",
" configuration: {\n",
" baseURL: \"https://proxy.com\",\n",
" },\n",
"});\n",
"\n",
"await llmWithoutStreamUsage.invoke(\"Hi there!\");"
]
},
{
"cell_type": "markdown",
"id": "013b6300",
Expand Down

0 comments on commit a93505f

Please sign in to comment.