indoxrouter 0.1.18__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 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]],
@@ -602,6 +644,11 @@ class Client:
602
644
  # Format the model string
603
645
  formatted_model = self._format_model_string(model)
604
646
 
647
+ # Extract provider from model string if present
648
+ provider = "openai" # Default provider
649
+ if "/" in model:
650
+ provider, _ = model.split("/", 1)
651
+
605
652
  # Filter out problematic parameters
606
653
  filtered_kwargs = {}
607
654
  for key, value in kwargs.items():
@@ -617,8 +664,15 @@ class Client:
617
664
  # Add optional parameters only if they are explicitly provided
618
665
  if n is not None:
619
666
  data["n"] = n
667
+
668
+ # Handle size parameter with provider-specific formatting
620
669
  if size is not None:
621
- data["size"] = size
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
+
622
676
  if quality is not None:
623
677
  data["quality"] = quality
624
678
  if style is not None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: indoxrouter
3
- Version: 0.1.18
3
+ Version: 0.1.19
4
4
  Summary: A unified client for various AI providers
5
5
  Author-email: indoxRouter Team <ashkan.eskandari.dev@gmail.com>
6
6
  License: MIT
@@ -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=j1ESSti83R9_fDiYEop0FJqtho0e2FuYes92XY7iImI,35263
3
- indoxrouter/constants.py,sha256=GezZ9nuwK3A37xpWlcfXCrMsIIlCdP7xnvEkPBMyn5g,1383
4
- indoxrouter/exceptions.py,sha256=qs7f9AnJ7SkOyf9N5qRaZIKpECE8uBq1Pvcg19Jif-U,1718
5
- indoxrouter-0.1.18.dist-info/METADATA,sha256=2K3ms5FkCR1L_PkApVOwzF10AHZWh-nn6yi9GvqDlQE,6639
6
- indoxrouter-0.1.18.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- indoxrouter-0.1.18.dist-info/top_level.txt,sha256=v6FGWkw0QAnXhyYtnXLI1cxzna0iveNvZUotVzCWabM,12
8
- indoxrouter-0.1.18.dist-info/RECORD,,