2025-05-10 09:18:01 +03:00
|
|
|
use mxlink::mime;
|
|
|
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
|
pub struct ImageGenerationParams {
|
|
|
|
|
pub size_override: Option<String>,
|
|
|
|
|
|
|
|
|
|
pub cheaper_model_switching_allowed: bool,
|
|
|
|
|
|
|
|
|
|
pub cheaper_quality_switching_allowed: bool,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl ImageGenerationParams {
|
|
|
|
|
pub fn with_size_override(mut self, value: Option<String>) -> Self {
|
|
|
|
|
self.size_override = value;
|
|
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn with_cheaper_model_switching_allowed(mut self, value: bool) -> Self {
|
|
|
|
|
self.cheaper_model_switching_allowed = value;
|
|
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn with_cheaper_quality_switching_allowed(mut self, value: bool) -> Self {
|
|
|
|
|
self.cheaper_quality_switching_allowed = value;
|
|
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub struct ImageGenerationResult {
|
|
|
|
|
pub bytes: Vec<u8>,
|
|
|
|
|
pub mime_type: mime::Mime,
|
|
|
|
|
pub revised_prompt: Option<String>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Default)]
|
2025-05-10 11:47:50 +03:00
|
|
|
pub struct ImageEditParams {}
|
2025-05-10 09:18:01 +03:00
|
|
|
|
|
|
|
|
pub struct ImageEditResult {
|
|
|
|
|
pub bytes: Vec<u8>,
|
|
|
|
|
pub mime_type: mime::Mime,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub struct ImageSource {
|
|
|
|
|
pub filename: String,
|
|
|
|
|
pub bytes: Vec<u8>,
|
|
|
|
|
pub mime_type: mime::Mime,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl ImageSource {
|
|
|
|
|
pub fn new(filename: String, bytes: Vec<u8>, mime_type: mime::Mime) -> Self {
|
2025-05-10 11:47:50 +03:00
|
|
|
Self {
|
|
|
|
|
filename,
|
|
|
|
|
bytes,
|
|
|
|
|
mime_type,
|
|
|
|
|
}
|
2025-05-10 09:18:01 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-30 10:31:06 +02:00
|
|
|
impl From<ImageSource> for async_openai::types::images::ImageInput {
|
2025-05-10 09:33:44 +03:00
|
|
|
fn from(value: ImageSource) -> Self {
|
2025-11-30 10:31:06 +02:00
|
|
|
async_openai::types::images::ImageInput::from_vec_u8(value.filename, value.bytes)
|
2025-05-10 09:18:01 +03:00
|
|
|
}
|
|
|
|
|
}
|