New version. Fixed package.
This commit is contained in:
parent
66e0e8aa4c
commit
e94292cf6f
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
||||
.venv
|
||||
__*
|
||||
__pycache__
|
||||
.pypirc
|
||||
.history
|
||||
|
18
Makefile
Normal file
18
Makefile
Normal 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
0
dist/yura-14.3.7/src/yura/__init__.py
vendored
Normal file
0
dist/yura-14.3.7/src/yura/__main__.py
vendored
Normal file
0
dist/yura-14.3.7/src/yura/__main__.py
vendored
Normal file
BIN
dist/yura-14.3.9-py3-none-any.whl
vendored
BIN
dist/yura-14.3.9-py3-none-any.whl
vendored
Binary file not shown.
BIN
dist/yura-14.3.9.tar.gz
vendored
BIN
dist/yura-14.3.9.tar.gz
vendored
Binary file not shown.
BIN
dist/yura-14.4.0-py3-none-any.whl
vendored
Normal file
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
BIN
dist/yura-14.4.0.tar.gz
vendored
Normal file
Binary file not shown.
@ -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
|
||||
|
@ -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())
|
||||
```
|
||||
|
@ -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
|
||||
|
@ -1 +1 @@
|
||||
|
||||
yura
|
||||
|
0
src/yura/__init__.py
Normal file
0
src/yura/__init__.py
Normal file
0
src/yura/__main__.py
Normal file
0
src/yura/__main__.py
Normal file
@ -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"):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user