use serde::{Deserialize, Serialize};
use super::super::JsonObject;
use super::{ImageBlock, TextBlock};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
#[non_exhaustive]
pub enum ImageSource {
Base64(Base64ImageSource),
Url(UrlImageSource),
File(FileImageSource),
Raw(serde_json::Value),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
#[non_exhaustive]
pub enum DocumentSource {
Base64(Base64PdfSource),
Text(PlainTextSource),
Content(ContentSource),
Url(UrlDocumentSource),
File(FileDocumentSource),
Raw(serde_json::Value),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
pub struct Base64ImageSource {
pub data: String,
pub media_type: ImageMediaType,
#[serde(rename = "type")]
pub type_: Base64SourceType,
#[serde(default, flatten, skip_serializing_if = "JsonObject::is_empty")]
pub rest: serde_json::Map<String, serde_json::Value>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
pub struct Base64PdfSource {
pub data: String,
pub media_type: PdfMediaType,
#[serde(rename = "type")]
pub type_: Base64SourceType,
#[serde(default, flatten, skip_serializing_if = "JsonObject::is_empty")]
pub rest: serde_json::Map<String, serde_json::Value>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Base64SourceType {
#[serde(rename = "base64")]
Base64,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ImageMediaType {
#[serde(rename = "image/jpeg")]
Jpeg,
#[serde(rename = "image/png")]
Png,
#[serde(rename = "image/gif")]
Gif,
#[serde(rename = "image/webp")]
Webp,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum PdfMediaType {
#[serde(rename = "application/pdf")]
ApplicationPdf,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
pub struct UrlImageSource {
#[serde(rename = "type")]
pub type_: UrlSourceType,
pub url: String,
#[serde(default, flatten, skip_serializing_if = "JsonObject::is_empty")]
pub rest: serde_json::Map<String, serde_json::Value>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
pub struct UrlDocumentSource {
#[serde(rename = "type")]
pub type_: UrlSourceType,
pub url: String,
#[serde(default, flatten, skip_serializing_if = "JsonObject::is_empty")]
pub rest: serde_json::Map<String, serde_json::Value>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum UrlSourceType {
#[serde(rename = "url")]
Url,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
pub struct FileImageSource {
pub file_id: String,
#[serde(rename = "type")]
pub type_: FileSourceType,
#[serde(default, flatten, skip_serializing_if = "JsonObject::is_empty")]
pub rest: serde_json::Map<String, serde_json::Value>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
pub struct FileDocumentSource {
pub file_id: String,
#[serde(rename = "type")]
pub type_: FileSourceType,
#[serde(default, flatten, skip_serializing_if = "JsonObject::is_empty")]
pub rest: serde_json::Map<String, serde_json::Value>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum FileSourceType {
#[serde(rename = "file")]
File,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
pub struct PlainTextSource {
pub data: String,
pub media_type: PlainTextMediaType,
#[serde(rename = "type")]
pub type_: TextSourceType,
#[serde(default, flatten, skip_serializing_if = "JsonObject::is_empty")]
pub rest: serde_json::Map<String, serde_json::Value>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum PlainTextMediaType {
#[serde(rename = "text/plain")]
TextPlain,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum TextSourceType {
#[serde(rename = "text")]
Text,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
pub struct ContentSource {
pub content: ContentSourceContent,
#[serde(rename = "type")]
pub type_: ContentSourceType,
#[serde(default, flatten, skip_serializing_if = "JsonObject::is_empty")]
pub rest: serde_json::Map<String, serde_json::Value>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ContentSourceType {
#[serde(rename = "content")]
Content,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
#[non_exhaustive]
pub enum ContentSourceContent {
Text(String),
Blocks(Vec<ContentSourceBlock>),
Raw(serde_json::Value),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
#[non_exhaustive]
pub enum ContentSourceBlock {
Text(TextBlock),
Image(ImageBlock),
Raw(serde_json::Value),
}