indoxrouter 0.1.17__py3-none-any.whl → 0.1.19__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.
- indoxrouter/client.py +75 -12
- {indoxrouter-0.1.17.dist-info → indoxrouter-0.1.19.dist-info}/METADATA +1 -1
- indoxrouter-0.1.19.dist-info/RECORD +8 -0
- indoxrouter-0.1.17.dist-info/RECORD +0 -8
- {indoxrouter-0.1.17.dist-info → indoxrouter-0.1.19.dist-info}/WHEEL +0 -0
- {indoxrouter-0.1.17.dist-info → indoxrouter-0.1.19.dist-info}/top_level.txt +0 -0
indoxrouter/client.py
CHANGED
@@ -399,6 +399,48 @@ class Client:
|
|
399
399
|
# is having issues with JSON formatted model strings
|
400
400
|
return model
|
401
401
|
|
402
|
+
def _format_image_size_for_provider(
|
403
|
+
self, size: str, provider: str, model: str
|
404
|
+
) -> str:
|
405
|
+
"""
|
406
|
+
Format the image size parameter based on the provider's requirements.
|
407
|
+
|
408
|
+
Google requires aspect ratios like "1:1", "4:3", etc. while OpenAI uses pixel dimensions
|
409
|
+
like "1024x1024", "512x512", etc.
|
410
|
+
|
411
|
+
Args:
|
412
|
+
size: The size parameter (e.g., "1024x1024")
|
413
|
+
provider: The provider name (e.g., "google", "openai")
|
414
|
+
model: The model name
|
415
|
+
|
416
|
+
Returns:
|
417
|
+
Formatted size parameter appropriate for the provider
|
418
|
+
"""
|
419
|
+
if provider.lower() == "google":
|
420
|
+
# Google uses aspect ratios instead of pixel dimensions
|
421
|
+
# Convert common pixel dimensions to aspect ratios
|
422
|
+
size_to_aspect_ratio = {
|
423
|
+
"1024x1024": "1:1",
|
424
|
+
"512x512": "1:1",
|
425
|
+
"256x256": "1:1",
|
426
|
+
"1024x768": "4:3",
|
427
|
+
"768x1024": "3:4",
|
428
|
+
"1024x1536": "2:3",
|
429
|
+
"1536x1024": "3:2",
|
430
|
+
"1792x1024": "16:9",
|
431
|
+
"1024x1792": "9:16",
|
432
|
+
}
|
433
|
+
|
434
|
+
# Check if size is already in aspect ratio format (contains a colon)
|
435
|
+
if ":" in size:
|
436
|
+
return size
|
437
|
+
|
438
|
+
# Convert to aspect ratio if we have a mapping, otherwise use default 1:1
|
439
|
+
return size_to_aspect_ratio.get(size, "1:1")
|
440
|
+
|
441
|
+
# For other providers, return the original size
|
442
|
+
return size
|
443
|
+
|
402
444
|
def chat(
|
403
445
|
self,
|
404
446
|
messages: List[Dict[str, str]],
|
@@ -531,10 +573,10 @@ class Client:
|
|
531
573
|
self,
|
532
574
|
prompt: str,
|
533
575
|
model: str = DEFAULT_IMAGE_MODEL,
|
534
|
-
size: str =
|
535
|
-
n: int =
|
536
|
-
quality: str =
|
537
|
-
style: str =
|
576
|
+
size: Optional[str] = None,
|
577
|
+
n: Optional[int] = None,
|
578
|
+
quality: Optional[str] = None,
|
579
|
+
style: Optional[str] = None,
|
538
580
|
# Standard parameters
|
539
581
|
response_format: Optional[str] = None,
|
540
582
|
user: Optional[str] = None,
|
@@ -563,10 +605,13 @@ class Client:
|
|
563
605
|
Args:
|
564
606
|
prompt: Text prompt
|
565
607
|
model: Model to use in the format "provider/model" (e.g., "openai/dall-e-3", "google/imagen-3.0-generate-002")
|
566
|
-
|
608
|
+
|
609
|
+
# Provider-specific parameters - will only be included if explicitly provided
|
610
|
+
# Note: Different providers support different parameters
|
611
|
+
size: Image size - For OpenAI: "1024x1024", "512x512", etc. For Google: "1:1", "4:3", etc.
|
567
612
|
n: Number of images to generate
|
568
|
-
quality: Image quality (e.g., "standard", "hd")
|
569
|
-
style: Image style (e.g., "vivid", "natural")
|
613
|
+
quality: Image quality (e.g., "standard", "hd") - supported by some providers
|
614
|
+
style: Image style (e.g., "vivid", "natural") - supported by some providers
|
570
615
|
|
571
616
|
# Standard parameters
|
572
617
|
response_format: Format of the response - "url" or "b64_json"
|
@@ -599,22 +644,40 @@ class Client:
|
|
599
644
|
# Format the model string
|
600
645
|
formatted_model = self._format_model_string(model)
|
601
646
|
|
647
|
+
# Extract provider from model string if present
|
648
|
+
provider = "openai" # Default provider
|
649
|
+
if "/" in model:
|
650
|
+
provider, _ = model.split("/", 1)
|
651
|
+
|
602
652
|
# Filter out problematic parameters
|
603
653
|
filtered_kwargs = {}
|
604
654
|
for key, value in kwargs.items():
|
605
655
|
if key not in ["return_generator"]: # List of parameters to exclude
|
606
656
|
filtered_kwargs[key] = value
|
607
657
|
|
608
|
-
# Create the base request data
|
658
|
+
# Create the base request data with only the required parameters
|
609
659
|
data = {
|
610
660
|
"prompt": prompt,
|
611
661
|
"model": formatted_model,
|
612
|
-
"n": n,
|
613
|
-
"size": size,
|
614
|
-
"quality": quality,
|
615
|
-
"style": style,
|
616
662
|
}
|
617
663
|
|
664
|
+
# Add optional parameters only if they are explicitly provided
|
665
|
+
if n is not None:
|
666
|
+
data["n"] = n
|
667
|
+
|
668
|
+
# Handle size parameter with provider-specific formatting
|
669
|
+
if size is not None:
|
670
|
+
formatted_size = self._format_image_size_for_provider(size, provider, model)
|
671
|
+
data["size"] = formatted_size
|
672
|
+
elif provider.lower() == "google":
|
673
|
+
# Default size for Google if not provided
|
674
|
+
data["size"] = "1:1"
|
675
|
+
|
676
|
+
if quality is not None:
|
677
|
+
data["quality"] = quality
|
678
|
+
if style is not None:
|
679
|
+
data["style"] = style
|
680
|
+
|
618
681
|
# Add standard parameters if provided
|
619
682
|
if response_format is not None:
|
620
683
|
data["response_format"] = response_format
|
@@ -0,0 +1,8 @@
|
|
1
|
+
indoxrouter/__init__.py,sha256=kwGvH8F5oqm2O4kLs-UtPfcY0AYiy5ZDUg-Sh3iYJA4,1627
|
2
|
+
indoxrouter/client.py,sha256=5y2MFHYx-ge82K30yPYnDRUe4jS9aCF6n3D1JaB1Crw,37298
|
3
|
+
indoxrouter/constants.py,sha256=GezZ9nuwK3A37xpWlcfXCrMsIIlCdP7xnvEkPBMyn5g,1383
|
4
|
+
indoxrouter/exceptions.py,sha256=qs7f9AnJ7SkOyf9N5qRaZIKpECE8uBq1Pvcg19Jif-U,1718
|
5
|
+
indoxrouter-0.1.19.dist-info/METADATA,sha256=bYZiVHEyt-yKnngnshHSu4fMHuBl1MnJqeWbKByr0aU,6639
|
6
|
+
indoxrouter-0.1.19.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
7
|
+
indoxrouter-0.1.19.dist-info/top_level.txt,sha256=v6FGWkw0QAnXhyYtnXLI1cxzna0iveNvZUotVzCWabM,12
|
8
|
+
indoxrouter-0.1.19.dist-info/RECORD,,
|
@@ -1,8 +0,0 @@
|
|
1
|
-
indoxrouter/__init__.py,sha256=kwGvH8F5oqm2O4kLs-UtPfcY0AYiy5ZDUg-Sh3iYJA4,1627
|
2
|
-
indoxrouter/client.py,sha256=0FZ-7mgE_kxbRpmRwJrucpvHme4MQOToX2VqVw9PKQE,34706
|
3
|
-
indoxrouter/constants.py,sha256=GezZ9nuwK3A37xpWlcfXCrMsIIlCdP7xnvEkPBMyn5g,1383
|
4
|
-
indoxrouter/exceptions.py,sha256=qs7f9AnJ7SkOyf9N5qRaZIKpECE8uBq1Pvcg19Jif-U,1718
|
5
|
-
indoxrouter-0.1.17.dist-info/METADATA,sha256=XFpOPo3DdQQuiPzmAOTbQvVc0bJRxPgD6FkNLkEyMFA,6639
|
6
|
-
indoxrouter-0.1.17.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
7
|
-
indoxrouter-0.1.17.dist-info/top_level.txt,sha256=v6FGWkw0QAnXhyYtnXLI1cxzna0iveNvZUotVzCWabM,12
|
8
|
-
indoxrouter-0.1.17.dist-info/RECORD,,
|
File without changes
|
File without changes
|