Skip to content

Commit

Permalink
fixing broken streaming examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jmansdorfer committed Jun 27, 2024
1 parent 58fcc8d commit d98b007
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
24 changes: 11 additions & 13 deletions fern/docs/pages/reference/chat_sse.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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='')
```
```
</CodeBlock>
Expand Down
4 changes: 2 additions & 2 deletions fern/docs/pages/usingllms/streaming.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d98b007

Please sign in to comment.