Skip to content

Commit

Permalink
bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
Qewertyy committed Mar 3, 2024
1 parent 6e1d7ac commit 0a40c3b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lexica/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"languageModels"
]

__version__ = "1.5.6"
__version__ = "1.5.7"
__author__ = "Qewertyy <[email protected]>"
14 changes: 11 additions & 3 deletions lexica/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def ChatCompletion(self : "Client", prompt: str,model : dict = languageModels.pa
)
return resp

def upscale(self : "Client", image: bytes, extras:dict=None) -> bytes:
def upscale(self : "Client", image: bytes= None, image_url: str= None,format: str = "binary") -> bytes:
"""
Upscale an image
Example:
Expand All @@ -99,11 +99,19 @@ def upscale(self : "Client", image: bytes, extras:dict=None) -> bytes:
Returns:
bytes: Upscaled image in bytes.
"""
b = base64.b64encode(image).decode('utf-8')
payload = {
"format": format,
}
if image and not image_url:
payload.setdefault('image_data',base64.b64encode(image).decode('utf-8'))
elif not image and not image_url:
raise Exception("Either image or image_url is required")
else:
payload.setdefault('image_url',image_url)
content = self._request(
url=f'{self.url}/upscale',
method = 'POST',
json={'image_data': b,**(extras or {})}
json=payload
)
return content

Expand Down
18 changes: 13 additions & 5 deletions lexica/core_async.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2024 Qewertyy, MIT License

import base64
from typing import Union, Dict
from typing import Union, Dict,Optional
from httpx import AsyncClient as AsyncHttpxClient
from lexica.constants import *
from lexica.utils import *
Expand Down Expand Up @@ -95,7 +95,7 @@ async def ChatCompletion(self : "AsyncClient", prompt: str,model : dict = langua
)
return resp

async def upscale(self : "AsyncClient", image: bytes, extras:dict=None) -> bytes:
async def upscale(self : "AsyncClient", image: bytes= None, image_url: str= None,format: str = "binary") -> bytes:
"""
Upscale an image
Example:
Expand All @@ -109,11 +109,19 @@ async def upscale(self : "AsyncClient", image: bytes, extras:dict=None) -> bytes
Returns:
bytes: Upscaled image in bytes.
"""
b = base64.b64encode(image).decode('utf-8')
payload = {
"format": format,
}
if image and not image_url:
payload.setdefault('image_data',base64.b64encode(image).decode('utf-8'))
elif not image and not image_url:
raise Exception("No image or image_url provided")
else:
payload.setdefault('image_url',image_url)
content = await self._request(
url=f'{self.url}/upscale',
method='POST',
json={'image_data': b, **(extras or {})},
method = 'POST',
json=payload
)
return content

Expand Down

0 comments on commit 0a40c3b

Please sign in to comment.