New version. Fixed package.

This commit is contained in:
retoor 2024-12-02 12:02:33 +01:00
parent 66e0e8aa4c
commit e94292cf6f
15 changed files with 58 additions and 12 deletions

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
.venv .venv
__* __pycache__
.pypirc .pypirc
.history .history

18
Makefile Normal file
View File

@ -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

0
dist/yura-14.3.7/src/yura/__init__.py vendored Normal file
View File

0
dist/yura-14.3.7/src/yura/__main__.py vendored Normal file
View File

Binary file not shown.

Binary file not shown.

BIN
dist/yura-14.4.0-py3-none-any.whl vendored Normal file

Binary file not shown.

BIN
dist/yura-14.4.0.tar.gz vendored Normal file

Binary file not shown.

View File

@ -1,6 +1,6 @@
[metadata] [metadata]
name = yura name = yura
version = 14.3.9 version = 14.4.0
description = Yura async AI client description = Yura async AI client
author = retoor author = retoor
author_email = retoor@retoor.io author_email = retoor@retoor.io

View File

@ -1,6 +1,6 @@
Metadata-Version: 2.1 Metadata-Version: 2.1
Name: yura Name: yura
Version: 14.3.9 Version: 14.4.0
Summary: Yura async AI client Summary: Yura async AI client
Author: retoor Author: retoor
Author-email: retoor@retoor.io Author-email: retoor@retoor.io
@ -31,12 +31,15 @@ yura ws://[host]:[port]/[path]/
## Python ## Python
```python ```python
import asyncio import asyncio
from yura.client import AsyncClient from yura.client import AsyncClient
async def communicate(): async def communicate():
client = AsyncClient("ws://[host]:[port]/[path]/") client = AsyncClient("ws://[host]:[port]/[path]/")
async for response in client.chat("Your prompt"): async for response in client.chat("Your prompt"):
print(response) print(response)
asyncio.run(communicate()) asyncio.run(communicate())
``` ```

View File

@ -1,8 +1,12 @@
README.md README.md
pyproject.toml pyproject.toml
setup.cfg setup.cfg
src/yura/__init__.py
src/yura/__main__.py
src/yura/cli.py src/yura/cli.py
src/yura/client.py src/yura/client.py
src/yura/model.py
src/yura/server.py
src/yura.egg-info/PKG-INFO src/yura.egg-info/PKG-INFO
src/yura.egg-info/SOURCES.txt src/yura.egg-info/SOURCES.txt
src/yura.egg-info/dependency_links.txt src/yura.egg-info/dependency_links.txt

View File

@ -1 +1 @@
yura

0
src/yura/__init__.py Normal file
View File

0
src/yura/__main__.py Normal file
View File

View File

@ -15,7 +15,6 @@ class AsyncRPCClient:
async def ws(self): async def ws(self):
if not self._ws: if not self._ws:
print("HIER")
self._ws = await websockets.connect(self.url) self._ws = await websockets.connect(self.url)
return self._ws return self._ws
@ -34,16 +33,35 @@ class AsyncRPCClient:
def __getattr__(self, name): def __getattr__(self, name):
async def call(*args, **kwargs): async def call(*args, **kwargs):
ws = await self.ws ws = await self.ws
response = None
while True:
try:
await ws.send( await ws.send(
json.dumps( json.dumps(
{"method": name, "args": args, "kwargs": kwargs}, default=str {"method": name, "args": args, "kwargs": kwargs}, default=str
) )
) )
response = await ws.recv() 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 json.loads(response)
return call return call
async def close():
if self._ws:
self._ws.close()
self._ws = None
def __del__(self):
self.close()
class AsyncClient: class AsyncClient:
@ -75,6 +93,9 @@ class AsyncClient:
async def connect(self, name): async def connect(self, name):
return await self.client.connect(name) return await self.client.connect(name)
def __del__(self):
sefl.client = None
async def cli_client(url="ws://127.0.0.1:8470"): async def cli_client(url="ws://127.0.0.1:8470"):