New version. Fixed package.
This commit is contained in:
parent
66e0e8aa4c
commit
e94292cf6f
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
|||||||
.venv
|
.venv
|
||||||
__*
|
__pycache__
|
||||||
.pypirc
|
.pypirc
|
||||||
.history
|
.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]
|
[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
|
||||||
|
@ -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())
|
||||||
```
|
```
|
||||||
|
@ -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
|
||||||
|
@ -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):
|
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
|
||||||
await ws.send(
|
response = None
|
||||||
json.dumps(
|
while True:
|
||||||
{"method": name, "args": args, "kwargs": kwargs}, default=str
|
try:
|
||||||
)
|
await ws.send(
|
||||||
)
|
json.dumps(
|
||||||
response = await ws.recv()
|
{"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 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"):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user