pygeai 0.6.0b10__py3-none-any.whl → 0.6.0b11__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pygeai/chat/clients.py +46 -1
- pygeai/chat/endpoints.py +1 -0
- pygeai/cli/commands/chat.py +95 -0
- {pygeai-0.6.0b10.dist-info → pygeai-0.6.0b11.dist-info}/METADATA +1 -1
- {pygeai-0.6.0b10.dist-info → pygeai-0.6.0b11.dist-info}/RECORD +9 -9
- {pygeai-0.6.0b10.dist-info → pygeai-0.6.0b11.dist-info}/WHEEL +0 -0
- {pygeai-0.6.0b10.dist-info → pygeai-0.6.0b11.dist-info}/entry_points.txt +0 -0
- {pygeai-0.6.0b10.dist-info → pygeai-0.6.0b11.dist-info}/licenses/LICENSE +0 -0
- {pygeai-0.6.0b10.dist-info → pygeai-0.6.0b11.dist-info}/top_level.txt +0 -0
pygeai/chat/clients.py
CHANGED
|
@@ -4,7 +4,7 @@ from pathlib import Path
|
|
|
4
4
|
from typing import List, Dict, Optional, Union, Generator
|
|
5
5
|
|
|
6
6
|
from pygeai import logger
|
|
7
|
-
from pygeai.chat.endpoints import CHAT_V1, GENERATE_IMAGE_V1, RESPONSES_V1
|
|
7
|
+
from pygeai.chat.endpoints import CHAT_V1, GENERATE_IMAGE_V1, EDIT_IMAGE_V1, RESPONSES_V1
|
|
8
8
|
from pygeai.core.base.clients import BaseClient
|
|
9
9
|
from pygeai.core.common.exceptions import InvalidAPIResponseException
|
|
10
10
|
from pygeai.core.utils.validators import validate_status_code
|
|
@@ -275,6 +275,51 @@ class ChatClient(BaseClient):
|
|
|
275
275
|
logger.debug(f"Image generation result: {result}")
|
|
276
276
|
return result
|
|
277
277
|
|
|
278
|
+
def edit_image(
|
|
279
|
+
self,
|
|
280
|
+
model: str,
|
|
281
|
+
prompt: str,
|
|
282
|
+
image: str,
|
|
283
|
+
size: str,
|
|
284
|
+
n: int = 1,
|
|
285
|
+
quality: Optional[str] = None
|
|
286
|
+
) -> dict:
|
|
287
|
+
"""
|
|
288
|
+
Edits an existing image based on the provided parameters.
|
|
289
|
+
|
|
290
|
+
:param model: str - The model specification for image editing, e.g., "openai/gpt-image-1". (Required)
|
|
291
|
+
:param prompt: str - Description of the desired edit, e.g., "remove background people". (Required)
|
|
292
|
+
:param image: str - URL of the image to be edited, e.g., "https://example.com/image.jpg". (Required)
|
|
293
|
+
:param size: str - Desired dimensions of the output image in pixels, e.g., "1024x1024". (Required)
|
|
294
|
+
:param n: int - Number of edited images to generate (1-10, depending on the model). Default is 1. (Optional)
|
|
295
|
+
:param quality: Optional[str] - Rendering quality, e.g., "high", "medium", "low". (Optional)
|
|
296
|
+
:return: dict - The API response containing the edited image data.
|
|
297
|
+
:raises InvalidAPIResponseException: If the API response cannot be processed.
|
|
298
|
+
"""
|
|
299
|
+
data = {
|
|
300
|
+
'model': model,
|
|
301
|
+
'prompt': prompt,
|
|
302
|
+
'image': image,
|
|
303
|
+
'size': size,
|
|
304
|
+
'n': n
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if quality:
|
|
308
|
+
data['quality'] = quality
|
|
309
|
+
|
|
310
|
+
logger.debug(f"Editing image with data: {data}")
|
|
311
|
+
|
|
312
|
+
response = self.api_service.post(
|
|
313
|
+
endpoint=EDIT_IMAGE_V1,
|
|
314
|
+
data=data
|
|
315
|
+
)
|
|
316
|
+
|
|
317
|
+
validate_status_code(response)
|
|
318
|
+
|
|
319
|
+
result = parse_json_response(response, "edit image")
|
|
320
|
+
logger.debug(f"Image editing result: {result}")
|
|
321
|
+
return result
|
|
322
|
+
|
|
278
323
|
def get_response(
|
|
279
324
|
self,
|
|
280
325
|
model: str,
|
pygeai/chat/endpoints.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
CHAT_V1 = "/chat" # POST Chat endpoint
|
|
2
2
|
CHAT_COMPLETION_V1 = "/chat/completion" # POST Chat completion endpoint
|
|
3
3
|
GENERATE_IMAGE_V1 = "/images" # POST Generate image
|
|
4
|
+
EDIT_IMAGE_V1 = "/images/edits" # POST Edit image
|
|
4
5
|
RESPONSES_V1 = "/responses" # POST Responses API endpoint
|
pygeai/cli/commands/chat.py
CHANGED
|
@@ -661,6 +661,92 @@ generate_image_options = [
|
|
|
661
661
|
]
|
|
662
662
|
|
|
663
663
|
|
|
664
|
+
def get_edit_image(option_list: list):
|
|
665
|
+
model = None
|
|
666
|
+
prompt = None
|
|
667
|
+
image = None
|
|
668
|
+
size = None
|
|
669
|
+
n = 1
|
|
670
|
+
quality = None
|
|
671
|
+
|
|
672
|
+
for option_flag, option_arg in option_list:
|
|
673
|
+
if option_flag.name == "model":
|
|
674
|
+
model = option_arg
|
|
675
|
+
if option_flag.name == "prompt":
|
|
676
|
+
prompt = option_arg
|
|
677
|
+
if option_flag.name == "image":
|
|
678
|
+
image = option_arg
|
|
679
|
+
if option_flag.name == "size":
|
|
680
|
+
size = option_arg
|
|
681
|
+
if option_flag.name == "n":
|
|
682
|
+
try:
|
|
683
|
+
n = int(option_arg)
|
|
684
|
+
if n < 1 or n > 10:
|
|
685
|
+
raise WrongArgumentError("n must be an integer between 1 and 10.")
|
|
686
|
+
except ValueError:
|
|
687
|
+
raise WrongArgumentError("n must be a valid integer.")
|
|
688
|
+
if option_flag.name == "quality":
|
|
689
|
+
quality = option_arg
|
|
690
|
+
|
|
691
|
+
if not (model and prompt and image and size):
|
|
692
|
+
raise MissingRequirementException("Cannot edit image without specifying model, prompt, image, and size.")
|
|
693
|
+
|
|
694
|
+
client = ChatClient()
|
|
695
|
+
try:
|
|
696
|
+
result = client.edit_image(
|
|
697
|
+
model=model,
|
|
698
|
+
prompt=prompt,
|
|
699
|
+
image=image,
|
|
700
|
+
size=size,
|
|
701
|
+
n=n,
|
|
702
|
+
quality=quality
|
|
703
|
+
)
|
|
704
|
+
Console.write_stdout(f"Image editing result: \n{result}\n")
|
|
705
|
+
except Exception as e:
|
|
706
|
+
logger.error(f"Error editing image: {e}")
|
|
707
|
+
Console.write_stderr(f"Failed to edit image: {e}")
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
edit_image_options = [
|
|
711
|
+
Option(
|
|
712
|
+
"model",
|
|
713
|
+
["--model", "-m"],
|
|
714
|
+
"The model specification for image editing, e.g., 'openai/gpt-image-1'.",
|
|
715
|
+
True
|
|
716
|
+
),
|
|
717
|
+
Option(
|
|
718
|
+
"prompt",
|
|
719
|
+
["--prompt", "-p"],
|
|
720
|
+
"Description of the desired edit, e.g., 'remove the ball'.",
|
|
721
|
+
True
|
|
722
|
+
),
|
|
723
|
+
Option(
|
|
724
|
+
"image",
|
|
725
|
+
["--image", "-img"],
|
|
726
|
+
"URL of the image to be edited, e.g., 'https://example.com/image.jpg'.",
|
|
727
|
+
True
|
|
728
|
+
),
|
|
729
|
+
Option(
|
|
730
|
+
"size",
|
|
731
|
+
["--size", "-s"],
|
|
732
|
+
"Desired dimensions of the output image in pixels, e.g., '1024x1024'.",
|
|
733
|
+
True
|
|
734
|
+
),
|
|
735
|
+
Option(
|
|
736
|
+
"n",
|
|
737
|
+
["--n"],
|
|
738
|
+
"Number of edited images to generate (1-10, depending on the model). Default is 1.",
|
|
739
|
+
True
|
|
740
|
+
),
|
|
741
|
+
Option(
|
|
742
|
+
"quality",
|
|
743
|
+
["--quality", "-q"],
|
|
744
|
+
"Rendering quality, e.g., 'high', 'medium', 'low'.",
|
|
745
|
+
True
|
|
746
|
+
),
|
|
747
|
+
]
|
|
748
|
+
|
|
749
|
+
|
|
664
750
|
def get_response(option_list: list):
|
|
665
751
|
model = None
|
|
666
752
|
input_text = None
|
|
@@ -912,6 +998,15 @@ chat_commands = [
|
|
|
912
998
|
[],
|
|
913
999
|
generate_image_options
|
|
914
1000
|
),
|
|
1001
|
+
Command(
|
|
1002
|
+
"edit_image",
|
|
1003
|
+
["edit-image", "edit-img"],
|
|
1004
|
+
"Edit an existing image using the specified model and parameters",
|
|
1005
|
+
get_edit_image,
|
|
1006
|
+
ArgumentsEnum.REQUIRED,
|
|
1007
|
+
[],
|
|
1008
|
+
edit_image_options
|
|
1009
|
+
),
|
|
915
1010
|
Command(
|
|
916
1011
|
"response",
|
|
917
1012
|
["response", "resp"],
|
|
@@ -184,8 +184,8 @@ pygeai/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
184
184
|
pygeai/auth/clients.py,sha256=3Eg9d9XJlPCIXz2N90LalchahV2gPaD0DWj8iBcw41Y,5422
|
|
185
185
|
pygeai/auth/endpoints.py,sha256=KOZ5gS8I8MIamlfbj4bN8w6kMmIdAKr6puKJrw0cEtw,589
|
|
186
186
|
pygeai/chat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
187
|
-
pygeai/chat/clients.py,sha256
|
|
188
|
-
pygeai/chat/endpoints.py,sha256=
|
|
187
|
+
pygeai/chat/clients.py,sha256=-PovdRQnwpsHtqoH0UNyAvx8XhDm8xLcZyvTBmsqhNc,19829
|
|
188
|
+
pygeai/chat/endpoints.py,sha256=r_zvsL5UIqnqhz9I0CG0eQSKV-egwx6EKdaZXj-HndA,343
|
|
189
189
|
pygeai/chat/iris.py,sha256=-9pDHQpWhR_PvbZ6rD8eMPFk46PI9sCdPQ9aAyvSexs,413
|
|
190
190
|
pygeai/chat/managers.py,sha256=f0BGfu9EF0G8rUyARslZi0pyDTL2yQadav0taCljI_I,3114
|
|
191
191
|
pygeai/chat/session.py,sha256=k7Y6rr9x7CfAGDI-Vt3c6eGLQX57YZ74lEVJGzwwdzw,1193
|
|
@@ -204,7 +204,7 @@ pygeai/cli/commands/assistant.py,sha256=fQ_El6_BmFDpFjm_gPxzWk7bOzhimhiTwG8K0Upc
|
|
|
204
204
|
pygeai/cli/commands/auth.py,sha256=w1XIcTYh7SQ4keOhQiJiUJ2NFMY349K53P2BoGe2Rgc,8318
|
|
205
205
|
pygeai/cli/commands/base.py,sha256=OKlYNpQvTCxOOLDSR-KkmoUvKs4OGYerwo_escQaDwY,7406
|
|
206
206
|
pygeai/cli/commands/builders.py,sha256=xXk1F4phSQxHN3NiQltl_KEZdCwwJiKLmVqQsft2OC4,1130
|
|
207
|
-
pygeai/cli/commands/chat.py,sha256=
|
|
207
|
+
pygeai/cli/commands/chat.py,sha256=i70GQA21RVMjMf5dsWXthUvLFjjXPb8G54AYGB_pz-s,35202
|
|
208
208
|
pygeai/cli/commands/common.py,sha256=zL1cWKMTqzqMsHBDFfVzbZe0i2l0hgJNpzjSRgvloY8,16568
|
|
209
209
|
pygeai/cli/commands/configuration.py,sha256=J1Y8AH1xYWvcY4bzqKvF-_ggEDJ22Dv4iEcCBi2pq_8,4140
|
|
210
210
|
pygeai/cli/commands/docs.py,sha256=8JEgKAHFL19g1rmgQzFwdzqLBP8ySvnpQogXwJPWfS4,3444
|
|
@@ -777,9 +777,9 @@ pygeai/vendor/a2a/utils/helpers.py,sha256=6Tbd8SVfXvdNEk6WYmLOjrAxkzFf1aIg8dkFfB
|
|
|
777
777
|
pygeai/vendor/a2a/utils/message.py,sha256=gc_EKO69CJ4HkR76IFgsy-kENJz1dn7CfSgWJWvt-gs,2197
|
|
778
778
|
pygeai/vendor/a2a/utils/task.py,sha256=BYRA_L1HpoUGJAVlyHML0lCM9Awhf2Ovjj7oPFXKbh0,1647
|
|
779
779
|
pygeai/vendor/a2a/utils/telemetry.py,sha256=VvSp1Ztqaobkmq9-3sNhhPEilJS32-JTSfKzegkj6FU,10861
|
|
780
|
-
pygeai-0.6.
|
|
781
|
-
pygeai-0.6.
|
|
782
|
-
pygeai-0.6.
|
|
783
|
-
pygeai-0.6.
|
|
784
|
-
pygeai-0.6.
|
|
785
|
-
pygeai-0.6.
|
|
780
|
+
pygeai-0.6.0b11.dist-info/licenses/LICENSE,sha256=eHfqo7-AWS8cMq0cg03lq7owsLeCmZA-xS5L0kuHnl8,1474
|
|
781
|
+
pygeai-0.6.0b11.dist-info/METADATA,sha256=HX6wRMsmyVkQxxEI7ykag0wIgJ9aiBWkZoEFR1DFjCI,7978
|
|
782
|
+
pygeai-0.6.0b11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
783
|
+
pygeai-0.6.0b11.dist-info/entry_points.txt,sha256=OAmwuXVCQBTCE3HeVegVd37hbhCcp9TPahvdrCuMYWw,178
|
|
784
|
+
pygeai-0.6.0b11.dist-info/top_level.txt,sha256=bJFwp2tURmCfB94yXDF7ylvdSJXFDDJsyUOb-7PJgwc,7
|
|
785
|
+
pygeai-0.6.0b11.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|