mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-15 14:51:19 -08:00
feat: enhance audio model handling and improve image URL resolution
- Updated `PollinationsAI` to exclude "gemini" model from `audio_models` - Added logic in `PollinationsAI` to expand `audio_models` with voices from `default_audio_model` - Appended voice names to `text_models` list in `PollinationsAI` if present in `default_audio_model` - Modified `PollinationsAI._generate_text` to inject `audio` parameters when a voice model is used - Updated `save_response_media` call to include voice name in model list - Changed `OpenaiChat.get_generated_image` to support both `file-service://` and `sediment://` URLs using `conversation_id` - Modified `OpenaiChat.create_messages` to optionally pass `prompt` - Adjusted `OpenaiChat.run` to determine `prompt` explicitly and set messages accordingly - Updated `OpenaiChat.iter_messages_line` to handle `None` in `fields.p` safely - Passed `prompt` and `conversation_id` to `OpenaiChat.get_generated_image` inside image parsing loop - Fixed redirect logic in `backend_api.py` to safely handle missing `skip` query param - Enhanced `render` function in `website.py` to support live file serving with `live` query param - Added new route `/dist/<path:name>` to serve static files from `DIST_DIR` in `website.py` - Adjusted `render` to include `.live` suffix in cache filename when applicable - Modified HTML replacements in `render` to preserve local `dist/` path if `add_origion` is True
This commit is contained in:
parent
02384a616a
commit
8c3764dfeb
4 changed files with 56 additions and 19 deletions
|
|
@ -105,9 +105,12 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
|
|||
cls.audio_models = {
|
||||
model.get("name"): model.get("voices")
|
||||
for model in models
|
||||
if "output_modalities" in model and "audio" in model["output_modalities"]
|
||||
if "output_modalities" in model and "audio" in model["output_modalities"] and model.get("name") != "gemini"
|
||||
}
|
||||
|
||||
if cls.default_audio_model in cls.audio_models:
|
||||
cls.audio_models = {**cls.audio_models, **{voice: {} for voice in cls.audio_models[cls.default_audio_model]}}
|
||||
|
||||
# Create a set of unique text models starting with default model
|
||||
unique_text_models = cls.text_models.copy()
|
||||
|
||||
|
|
@ -120,6 +123,9 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
|
|||
if model_name and "input_modalities" in model and "text" in model["input_modalities"]:
|
||||
unique_text_models.append(model_name)
|
||||
|
||||
if cls.default_audio_model in cls.audio_models:
|
||||
unique_text_models.extend([voice for voice in cls.audio_models[cls.default_audio_model]])
|
||||
|
||||
# Convert to list and update text_models
|
||||
cls.text_models = list(dict.fromkeys(unique_text_models))
|
||||
|
||||
|
|
@ -207,6 +213,11 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
|
|||
"role": "user",
|
||||
"content": prompt
|
||||
}]
|
||||
if model and model in cls.audio_models[cls.default_audio_model]:
|
||||
kwargs["audio"] = {
|
||||
"voice": model,
|
||||
}
|
||||
model = cls.default_audio_model
|
||||
async for result in cls._generate_text(
|
||||
model=model,
|
||||
messages=messages,
|
||||
|
|
@ -359,6 +370,6 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
|
|||
if finish_reason:
|
||||
yield FinishReason(finish_reason)
|
||||
else:
|
||||
async for chunk in save_response_media(response, format_image_prompt(messages), [model]):
|
||||
async for chunk in save_response_media(response, format_image_prompt(messages), [model, extra_parameters.get("audio", {}).get("voice")]):
|
||||
yield chunk
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue