Fix sticker generation for newer GPT image models
Sticker generation was failing when using newer GPT image models (gpt-image-1, gpt-image-1-mini, gpt-image-1.5). The issue occurred because stickers requested 256x256 size, but these models only support 1024x1024, 1536x1024, 1024x1536, and auto. To reproduce, send `!bai sticker Something` to an agent configured with a GPT image model. The error was: invalid_request_error: Invalid value: '256x256'. Supported values are: '1024x1024', '1024x1536', '1536x1024', and 'auto'. (param: size) (code: invalid_value) The fix replaces the hardcoded 256x256 size override with a `smallest_size_possible` flag, letting each provider determine the appropriate sticker size based on the model being used. The `openai_compat` provider still defaults to requesting 256x256 in all cases (regardless of model name).
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
use async_openai::types::{
|
||||
responses::{
|
||||
EasyInputContent, EasyInputMessage, ImageDetail, InputContent, InputImageContent,
|
||||
InputItem, InputParam, MessageType, Role,
|
||||
},
|
||||
use async_openai::types::responses::{
|
||||
EasyInputContent, EasyInputMessage, ImageDetail, InputContent, InputImageContent, InputItem,
|
||||
InputParam, MessageType, Role,
|
||||
};
|
||||
|
||||
use crate::conversation::llm::{
|
||||
@@ -48,19 +46,3 @@ pub fn convert_llm_messages_to_openai_response_input(
|
||||
|
||||
InputParam::Items(items)
|
||||
}
|
||||
|
||||
pub(super) fn convert_string_to_enum<T>(value: &str) -> Result<T, String>
|
||||
where
|
||||
T: serde::de::DeserializeOwned,
|
||||
{
|
||||
// This is a hacky way to construct an enum from the string we have.
|
||||
let enum_result: serde_json::Result<T> = serde_json::from_str(&format!("\"{}\"", value));
|
||||
match enum_result {
|
||||
Ok(enum_result) => Ok(enum_result),
|
||||
Err(err) => {
|
||||
tracing::debug!(?err, "Failed to parse into enum");
|
||||
|
||||
Err(format!("The value ({}) is not supported.", value))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user