Skip to content

Commit

Permalink
Fix duplicate streaming responses (#36)
Browse files Browse the repository at this point in the history
- Fix issue where multiple responses can be streamed, if `raw` or
`citations` are set to `True`.
  • Loading branch information
vsakkas authored Apr 21, 2023
1 parent feee4a0 commit 68a66d1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Sydney.py

[![Latest Release](https://img.shields.io/github/v/release/vsakkas/sydney.py.svg)](https://github.com/vsakkas/sydney.py/releases/tag/v0.11.3)
[![Latest Release](https://img.shields.io/github/v/release/vsakkas/sydney.py.svg)](https://github.com/vsakkas/sydney.py/releases/tag/v0.11.4)
[![Python](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
[![MIT License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/vsakkas/sydney.py/blob/master/LICENSE)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sydney-py"
version = "0.11.3"
version = "0.11.4"
description = "Python Client for Bing Chat, also known as Sydney."
authors = ["vsakkas <[email protected]>"]
license = "MIT"
Expand Down
8 changes: 5 additions & 3 deletions sydney/sydney.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,10 @@ async def _ask(
elif response.get("type") == 2:
if raw:
yield response
if citations:
elif citations:
yield response["item"]["messages"][1]["adaptiveCards"][0]["body"][0]["text"]
yield response["item"]["messages"][1]["text"]
else:
yield response["item"]["messages"][1]["text"]

# Exit, type 2 is the last message.
streaming = False
Expand Down Expand Up @@ -243,7 +244,8 @@ async def _compose(
elif response.get("type") == 2:
if raw:
yield response
yield response["item"]["messages"][1]["text"]
else:
yield response["item"]["messages"][1]["text"]

# Exit, type 2 is the last message.
streaming = False
Expand Down

0 comments on commit 68a66d1

Please sign in to comment.