From d98b00797b60b8a30406b3e2154be83fe9ae9e78 Mon Sep 17 00:00:00 2001 From: jmansdorfer Date: Thu, 27 Jun 2024 14:23:55 -0400 Subject: [PATCH] fixing broken streaming examples --- fern/docs/pages/reference/chat_sse.mdx | 24 +++++++++++------------- fern/docs/pages/usingllms/streaming.mdx | 4 ++-- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/fern/docs/pages/reference/chat_sse.mdx b/fern/docs/pages/reference/chat_sse.mdx index 224360b..781856f 100644 --- a/fern/docs/pages/reference/chat_sse.mdx +++ b/fern/docs/pages/reference/chat_sse.mdx @@ -45,19 +45,17 @@ method for your application. } ] - result = client.chat.completions.create( - model="Neural-Chat-7B", - messages=messages, - max_tokens=500, - stream=true, - ) - - print(json.dumps( - result, - sort_keys=True, - indent=4, - separators=(',', ': ') - )) +for res in client.chat.completions.create( + model="Neural-Chat-7B", + messages=messages, + max_tokens=500, + temperature=0.1, + stream=True +): + + # Use 'end' parameter in print function to avoid new lines. + print(res["data"]["choices"][0]["delta"]["content"], end='') +``` ``` diff --git a/fern/docs/pages/usingllms/streaming.mdx b/fern/docs/pages/usingllms/streaming.mdx index b307621..de845be 100644 --- a/fern/docs/pages/usingllms/streaming.mdx +++ b/fern/docs/pages/usingllms/streaming.mdx @@ -71,8 +71,8 @@ for res in client.chat.completions.create( stream=True ): -# Use 'end' parameter in print function to avoid new lines. -print(res["data"]["choices"][0]["delta"]["content"], end='') + # Use 'end' parameter in print function to avoid new lines. + print(res["data"]["choices"][0]["delta"]["content"], end='') ``` ![Retrieval augmented generation](streaming.gif)