Skip to content

Commit

Permalink
Merge pull request #9 from cheshire-cat-ai/develop
Browse files Browse the repository at this point in the history
Bump to 1.4.1
  • Loading branch information
nicola-corbellini authored Dec 28, 2023
2 parents 64926c7 + 48acb21 commit 2902352
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cheshire_cat_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
""" # noqa: E501


__version__ = "1.4"
__version__ = "1.4.1"

from cheshire_cat_api.cat_client import CatClient
from cheshire_cat_api.config import Config
Expand Down
14 changes: 9 additions & 5 deletions cheshire_cat_api/cat_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def __init__(self,
self._conn_settings = config if config is not None else Config()
# TODO: user_id should be automatically passed from settings to http endpoints

self._ws = None
self.memory = None
self.plugins = None
self.rabbit_hole = None
Expand All @@ -44,6 +43,8 @@ def __init__(self,
self.settings = None
self.llm = None

self._ws = None

self._connect_api()

def _connect_api(self):
Expand Down Expand Up @@ -115,6 +116,7 @@ def on_ws_close(self, ws, status_code: int, msg: str):
if callable(self.on_close):
self.on_close(status_code, msg)


def send(self, message: str, **kwargs):
"""Send a message to WebSocket server using a separate thread"""

Expand All @@ -127,13 +129,15 @@ def send(self, message: str, **kwargs):
}))

def close(self):

if self._ws is None:
logging.warning("Websocket connection is already close")
return

# Close connection
self._ws.close()
self.conn.join()

@property
def is_ws_connected(self):
if self._ws is None:
return False

return self._ws.sock.connected
return self._ws and self._ws.sock and self._ws.sock.connected
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 = "cheshire_cat_api"
version = "1.4"
version = "1.4.1"
description = "😸 Cheshire-Cat API Client"
authors = ["Chesire Cat AI"]
maintainers = [
Expand Down

0 comments on commit 2902352

Please sign in to comment.