async_llm/types/
image_url.rs

1use derive_builder::Builder;
2use serde::{Deserialize, Serialize};
3
4use crate::error::Error;
5
6#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]
7#[serde(rename_all = "snake_case")]
8pub enum ImageDetail {
9    #[default]
10    Auto,
11    Low,
12    High,
13}
14
15#[derive(Debug, Clone, Builder, Default, Serialize, Deserialize, PartialEq)]
16#[builder(setter(into, strip_option), default)]
17#[builder(derive(Debug))]
18#[builder(build_fn(error = Error))]
19pub struct ImageUrl {
20    /// Either a URL of the image or the base64 encoded image data.
21    pub url: String,
22    /// Specifies the detail level of the image. Learn more in the [Vision guide](https://platform.openai.com/docs/guides/vision#low-or-high-fidelity-image-understanding).
23    #[serde(skip_serializing_if = "Option::is_none")]
24    pub detail: Option<ImageDetail>,
25}
26
27impl From<&str> for ImageUrl {
28    fn from(value: &str) -> Self {
29        Self {
30            url: value.to_string(),
31            detail: None,
32        }
33    }
34}