mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-06 02:30:41 -08:00
refactor: streamline image param handling and fix media URL extraction
- Removed extension of `vision_models` into `text_models` in `PollinationsAI.get_models` - Unified image parameter handling in `PollinationsAI.create_payload`, removing special case for `"gptimage"` model - Added conditional inclusion of `"transparent"` and `"image"` params based on `transparent` flag and media content - Replaced `quote_plus` with `quote` for URL encoding in query string construction - In `OpenaiTemplate.create_payload`, wrapped media URL extraction in `iter()` to fix `next()` usage with list comprehension
This commit is contained in:
parent
571a2ac37b
commit
dc9f1156ec
2 changed files with 9 additions and 16 deletions
|
|
@ -94,7 +94,7 @@ class OpenaiTemplate(AsyncGeneratorProvider, ProviderModelMixin, RaiseErrorMixin
|
|||
}
|
||||
# Handle media if provided
|
||||
if media is not None:
|
||||
data["image_url"] = next([data for data, _ in media if data and isinstance(data, str) and data.startswith("http://") or data.startswith("https://")], None)
|
||||
data["image_url"] = next(iter([data for data, _ in media if data and isinstance(data, str) and data.startswith("http://") or data.startswith("https://")]), None)
|
||||
async with session.post(f"{api_base.rstrip('/')}/images/generations", json=data, ssl=cls.ssl) as response:
|
||||
data = await response.json()
|
||||
cls.raise_error(data, response.status)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue