// Code generated by oagen. DO NOT EDIT.

#[allow(unused_imports)]
use super::*;
#[allow(unused_imports)]
use crate::enums::*;
use serde::{Deserialize, Serialize};
/// Request to run a structured extraction on a single document.
/// Extends the base extraction request with the `document` to process (either
/// inline content or a reference to a previously uploaded file) and a `stream`
/// flag that controls whether results are returned incrementally.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ExtractionRequest {
    pub document: MimeData,
    /// JSON schema describing the structured output
    pub json_schema: std::collections::HashMap<String, serde_json::Value>,
    /// The model to use for the extraction
    ///
    /// Defaults to `retab-small`.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub model: Option<String>,
    /// Free-form instructions appended to the system prompt to steer the extraction.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub instructions: Option<String>,
    /// Number of consensus extraction runs to perform. Uses deterministic single-pass when set to 1.
    ///
    /// Defaults to `1`.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub n_consensus: Option<i64>,
    /// User-defined metadata to associate with this extraction
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub metadata: Option<std::collections::HashMap<String, String>>,
    /// Additional chat messages forwarded to the extraction model.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub additional_messages: Option<Vec<std::collections::HashMap<String, serde_json::Value>>>,
    /// If true, skip the LLM cache and force a fresh completion
    ///
    /// Defaults to `false`.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub bust_cache: Option<bool>,
    /// Defaults to `false`.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub stream: Option<bool>,
    /// If true, run asynchronously: returns immediately with status 'queued' and an empty output. Poll GET /v1/<primitive>/{id} until status is terminal. Mutually exclusive with stream.
    ///
    /// Defaults to `false`.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub background: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub chunking_keys: Option<std::collections::HashMap<String, String>>,
}
impl ExtractionRequest {
    /// Construct a new `ExtractionRequest` with the required fields set.
    #[allow(deprecated)]
    pub fn new<D: Into<crate::MimeData>>(
        document: D,
        json_schema: std::collections::HashMap<String, serde_json::Value>,
    ) -> Self {
        Self {
            document: document.into(),
            json_schema,
            model: Default::default(),
            instructions: Default::default(),
            n_consensus: Default::default(),
            metadata: Default::default(),
            additional_messages: Default::default(),
            bust_cache: Default::default(),
            stream: Default::default(),
            background: Default::default(),
            chunking_keys: Default::default(),
        }
    }
}
