Move PersonGeneration parameter to enum
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
use std::{error::Error, io::Cursor};
|
use std::{error::Error, io::Cursor};
|
||||||
|
|
||||||
use gemini_rs::prelude::{
|
use gemini_rs::prelude::{
|
||||||
GeminiClient, PredictImageRequest, PredictImageRequestParameters,
|
GeminiClient, PersonGeneration, PredictImageRequest, PredictImageRequestParameters,
|
||||||
PredictImageRequestParametersOutputOptions, PredictImageRequestPrompt,
|
PredictImageRequestParametersOutputOptions, PredictImageRequestPrompt,
|
||||||
};
|
};
|
||||||
use image::{ImageFormat, ImageReader};
|
use image::{ImageFormat, ImageReader};
|
||||||
@@ -34,9 +34,13 @@ pub async fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
mime_type: Some("image/jpeg".to_string()),
|
mime_type: Some("image/jpeg".to_string()),
|
||||||
compression_quality: Some(75),
|
compression_quality: Some(75),
|
||||||
}),
|
}),
|
||||||
|
person_generation: Some(PersonGeneration::AllowAll),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
println!("Request: {:#?}", serde_json::to_string(&request).unwrap());
|
||||||
|
|
||||||
let mut result = gemini
|
let mut result = gemini
|
||||||
.predict_image(&request, "imagen-3.0-fast-generate-001")
|
.predict_image(&request, "imagen-3.0-fast-generate-001")
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ pub struct PredictImageRequestParameters {
|
|||||||
/// Supported by the models `imagen-3.0-generate-001`, `imagen-3.0-fast-generate-001`, and
|
/// Supported by the models `imagen-3.0-generate-001`, `imagen-3.0-fast-generate-001`, and
|
||||||
/// `imagegeneration@006` only.
|
/// `imagegeneration@006` only.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub person_generation: Option<String>,
|
pub person_generation: Option<PersonGeneration>,
|
||||||
|
|
||||||
/// Optional. The language code that corresponds to your text prompt language.
|
/// Optional. The language code that corresponds to your text prompt language.
|
||||||
/// The following values are supported:
|
/// The following values are supported:
|
||||||
@@ -111,14 +111,17 @@ pub struct PredictImageRequestParameters {
|
|||||||
pub language: Option<String>,
|
pub language: Option<String>,
|
||||||
|
|
||||||
/// Adds a filter level to safety filtering. The following values are supported:
|
/// Adds a filter level to safety filtering. The following values are supported:
|
||||||
/// - `"block_most"`: Strongest filtering level, most strict blocking.
|
|
||||||
/// - `"block_some"`: Block some problematic prompts and responses.
|
|
||||||
/// - `"block_few"`: Reduces the number of requests blocked due to safety filters. May
|
|
||||||
/// increase objectionable content generated by Imagen.
|
|
||||||
/// - `"block_fewest"`: Block very few problematic prompts and responses. Access to this
|
|
||||||
/// feature is restricted.
|
|
||||||
///
|
///
|
||||||
/// The default value is `"block_some"`.
|
/// - "block_low_and_above": Strongest filtering level, most strict blocking.
|
||||||
|
/// Deprecated value: "block_most".
|
||||||
|
/// - "block_medium_and_above": Block some problematic prompts and responses.
|
||||||
|
/// Deprecated value: "block_some".
|
||||||
|
/// - "block_only_high": Reduces the number of requests blocked due to safety filters. May
|
||||||
|
/// increase objectionable content generated by Imagen. Deprecated value: "block_few".
|
||||||
|
/// - "block_none": Block very few problematic prompts and responses. Access to this feature
|
||||||
|
/// is restricted. Previous field value: "block_fewest".
|
||||||
|
///
|
||||||
|
/// The default value is "block_medium_and_above".
|
||||||
///
|
///
|
||||||
/// Supported by the models `imagen-3.0-generate-001`, `imagen-3.0-fast-generate-001`, and
|
/// Supported by the models `imagen-3.0-generate-001`, `imagen-3.0-fast-generate-001`, and
|
||||||
/// `imagegeneration@006` only.
|
/// `imagegeneration@006` only.
|
||||||
@@ -165,3 +168,11 @@ pub struct PredictImageResponsePrediction {
|
|||||||
pub bytes_base64_encoded: Vec<u8>,
|
pub bytes_base64_encoded: Vec<u8>,
|
||||||
pub mime_type: String,
|
pub mime_type: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub enum PersonGeneration {
|
||||||
|
DontAllow,
|
||||||
|
AllowAdult,
|
||||||
|
AllowAll,
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user