refactor: improve image response handling, adjust aspect ratio defaults, and fix filename construction

- In PollinationsAI.py, modified get_image method to initialize responses set and manage concurrent image fetches with asyncio tasks, adding a while loop to yield responses as they complete
- Changed response index in get_image from 1 to 0 to align with zero-based indexing
- Introduced 'responses' set and 'finished' counter outside inner get_image function for proper progress tracking
- Updated gather() usage to run all get_image tasks concurrently after loop
- In __init__.py, enhanced use_aspect_ratio function: added checks if width and height are None before assigning aspect ratio-based defaults
- Assigned default width and height values for aspect ratios "1:1", "16:9", and "9:16" if not already specified in extra_body
- In copy_images.py, corrected get_filename function to convert tags to strings before joining with '+', ensuring proper filename formatting
- In response.py, refined is_content function to exclude Reasoning objects where is_thinking and token are both None
- Removed __eq__ method from Reasoning class to prevent comparison issues
- In web_search.py, simplified import by removing unused datetime and date modules
This commit is contained in:
hlohaus 2025-05-18 04:51:46 +02:00
parent 57cbd55d74
commit 362c2f0f1a
6 changed files with 46 additions and 33 deletions

View file

@ -61,6 +61,8 @@ PARAMETER_EXAMPLES = {
"conversation": {"conversation_id": "550e8400-e29b-11d4-a716-...", "message_id": "550e8400-e29b-11d4-a716-..."},
"seed": 42,
"tools": [],
"width": 1024,
"height": 1024,
}
class AbstractProvider(BaseProvider):