diff --git a/.gitignore b/.gitignore index 1fb9556..bea6411 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ .venv -__* +__pycache__ .pypirc .history diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0f9389c --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +PYTHON=.venv/bin/python +PIP=.venv/bin/pip + +all: build + +ensure_env: + -@python3 -m venv .venv + +build: ensure_env + $(PIP) install -e . + $(PIP) install build + $(PIP) install shed + $(PYTHON) -m shed + $(PYTHON) -m build + + + + diff --git a/dist/yura-14.3.7/src/yura/__init__.py b/dist/yura-14.3.7/src/yura/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dist/yura-14.3.7/src/yura/__main__.py b/dist/yura-14.3.7/src/yura/__main__.py new file mode 100644 index 0000000..e69de29 diff --git a/dist/yura-14.3.9-py3-none-any.whl b/dist/yura-14.3.9-py3-none-any.whl index b57e982..16ac913 100644 Binary files a/dist/yura-14.3.9-py3-none-any.whl and b/dist/yura-14.3.9-py3-none-any.whl differ diff --git a/dist/yura-14.3.9.tar.gz b/dist/yura-14.3.9.tar.gz index a5b437b..2f60545 100644 Binary files a/dist/yura-14.3.9.tar.gz and b/dist/yura-14.3.9.tar.gz differ diff --git a/dist/yura-14.4.0-py3-none-any.whl b/dist/yura-14.4.0-py3-none-any.whl new file mode 100644 index 0000000..d02987e Binary files /dev/null and b/dist/yura-14.4.0-py3-none-any.whl differ diff --git a/dist/yura-14.4.0.tar.gz b/dist/yura-14.4.0.tar.gz new file mode 100644 index 0000000..0ba14be Binary files /dev/null and b/dist/yura-14.4.0.tar.gz differ diff --git a/setup.cfg b/setup.cfg index f65956c..806f1bb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = yura -version = 14.3.9 +version = 14.4.0 description = Yura async AI client author = retoor author_email = retoor@retoor.io diff --git a/src/yura.egg-info/PKG-INFO b/src/yura.egg-info/PKG-INFO index bee3e6f..4dbfa7b 100644 --- a/src/yura.egg-info/PKG-INFO +++ b/src/yura.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: yura -Version: 14.3.9 +Version: 14.4.0 Summary: Yura async AI client Author: retoor Author-email: retoor@retoor.io @@ -31,12 +31,15 @@ yura ws://[host]:[port]/[path]/ ## Python ```python import asyncio + from yura.client import AsyncClient + async def communicate(): client = AsyncClient("ws://[host]:[port]/[path]/") async for response in client.chat("Your prompt"): - print(response) + print(response) + asyncio.run(communicate()) ``` diff --git a/src/yura.egg-info/SOURCES.txt b/src/yura.egg-info/SOURCES.txt index 4e52371..350f83c 100644 --- a/src/yura.egg-info/SOURCES.txt +++ b/src/yura.egg-info/SOURCES.txt @@ -1,8 +1,12 @@ README.md pyproject.toml setup.cfg +src/yura/__init__.py +src/yura/__main__.py src/yura/cli.py src/yura/client.py +src/yura/model.py +src/yura/server.py src/yura.egg-info/PKG-INFO src/yura.egg-info/SOURCES.txt src/yura.egg-info/dependency_links.txt diff --git a/src/yura.egg-info/top_level.txt b/src/yura.egg-info/top_level.txt index 8b13789..6951fbf 100644 --- a/src/yura.egg-info/top_level.txt +++ b/src/yura.egg-info/top_level.txt @@ -1 +1 @@ - +yura diff --git a/src/yura/__init__.py b/src/yura/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/yura/__main__.py b/src/yura/__main__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/yura/client.py b/src/yura/client.py index 92e2d23..9359697 100644 --- a/src/yura/client.py +++ b/src/yura/client.py @@ -15,7 +15,6 @@ class AsyncRPCClient: async def ws(self): if not self._ws: - print("HIER") self._ws = await websockets.connect(self.url) return self._ws @@ -34,16 +33,35 @@ class AsyncRPCClient: def __getattr__(self, name): async def call(*args, **kwargs): ws = await self.ws - await ws.send( - json.dumps( - {"method": name, "args": args, "kwargs": kwargs}, default=str - ) - ) - response = await ws.recv() + response = None + while True: + try: + await ws.send( + json.dumps( + {"method": name, "args": args, "kwargs": kwargs}, default=str + ) + ) + response = await ws.recv() + break + except Exception as ex: + print(ex) + print("Trying again in 1 seconds.") + self.close() + await asyncio.sleep(1) + finally: + return json.loads(response) return call + async def close(): + if self._ws: + self._ws.close() + self._ws = None + + def __del__(self): + self.close() + class AsyncClient: @@ -75,6 +93,9 @@ class AsyncClient: async def connect(self, name): return await self.client.connect(name) + def __del__(self): + sefl.client = None + async def cli_client(url="ws://127.0.0.1:8470"):