Skip to content

Commit 231c347

Browse files
authored
Use new websockets API (#196)
- Use new websockets API introduced in version 14
1 parent dbd36ae commit 231c347

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# <img src="https://raw.githubusercontent.com/vsakkas/sydney.py/master/images/logo.svg" width="28px" /> Sydney.py
22

3-
[![Latest Release](https://img.shields.io/github/v/release/vsakkas/sydney.py.svg?color=blue)](https://github.com/vsakkas/sydney.py/releases/tag/v0.23.0)
3+
[![Latest Release](https://img.shields.io/github/v/release/vsakkas/sydney.py.svg?color=blue)](https://github.com/vsakkas/sydney.py/releases/tag/v0.23.1)
44
[![Python](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
55
[![Managed](https://img.shields.io/badge/managed-poetry-bluegreen.svg?color=blue)](https://github.com/python-poetry/poetry)
66
[![MIT License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/vsakkas/sydney.py/blob/master/LICENSE)

poetry.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "sydney-py"
3-
version = "0.23.0"
3+
version = "0.23.1"
44
description = "Python Client for Copilot (formerly named Bing Chat), also known as Sydney."
55
authors = ["vsakkas <[email protected]>"]
66
license = "MIT"

sydney/sydney.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
from typing import AsyncGenerator
88
from urllib import parse
99

10-
import websockets.legacy.client as websockets
10+
import websockets.asyncio.client as websockets
1111
from aiohttp import ClientSession, FormData, TCPConnector
12-
from websockets.legacy.client import WebSocketClientProtocol
12+
from websockets.asyncio.client import ClientConnection
1313

1414
from sydney.constants import (
1515
BING_BLOB_URL,
@@ -94,7 +94,7 @@ def __init__(
9494
self.invocation_id: int | None = None
9595
self.number_of_messages: int | None = None
9696
self.max_messages: int | None = None
97-
self.wss_client: WebSocketClientProtocol | None = None
97+
self.wss_client: ClientConnection | None = None
9898
self.session: ClientSession | None = None
9999

100100
async def __aenter__(self) -> SydneyClient:
@@ -365,7 +365,7 @@ async def _ask(
365365
# Create a websocket connection with Copilot for sending and receiving messages.
366366
try:
367367
self.wss_client = await websockets.connect(
368-
bing_chathub_url, extra_headers=CHATHUB_HEADERS, max_size=None
368+
bing_chathub_url, additional_headers=CHATHUB_HEADERS, max_size=None
369369
)
370370
except TimeoutError:
371371
raise ConnectionTimeoutException(
@@ -786,7 +786,7 @@ async def close_conversation(self) -> None:
786786
"""
787787
Close all connections to Copilot. Clear conversation information.
788788
"""
789-
if self.wss_client and not self.wss_client.closed:
789+
if self.wss_client:
790790
await self.wss_client.close()
791791
self.wss_client = None
792792

0 commit comments

Comments
 (0)