use serde::{Deserialize, Serialize};
use schemars::JsonSchema;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default, JsonSchema, arbitrary::Arbitrary)]
#[schemars(rename = "agent.completions.response.Logprobs")]
pub struct Logprobs {
pub content: Option<Vec<Logprob>>,
pub refusal: Option<Vec<Logprob>>,
}
impl Logprobs {
pub fn push(&mut self, other: &Logprobs) {
match (&mut self.content, &other.content) {
(Some(self_content), Some(other_content)) => {
self_content.extend(other_content.clone());
}
(None, Some(other_content)) => {
self.content = Some(other_content.clone());
}
_ => {}
}
match (&mut self.refusal, &other.refusal) {
(Some(self_refusal), Some(other_refusal)) => {
self_refusal.extend(other_refusal.clone());
}
(None, Some(other_refusal)) => {
self.refusal = Some(other_refusal.clone());
}
_ => {}
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default, JsonSchema, arbitrary::Arbitrary)]
#[schemars(rename = "agent.completions.response.Logprob")]
pub struct Logprob {
pub token: String,
pub bytes: Option<Vec<u8>>,
#[serde(deserialize_with = "crate::serde_util::decimal")]
#[schemars(with = "f64")]
#[arbitrary(with = crate::arbitrary_util::arbitrary_rust_decimal)]
pub logprob: rust_decimal::Decimal,
pub top_logprobs: Vec<TopLogprob>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default, JsonSchema, arbitrary::Arbitrary)]
#[schemars(rename = "agent.completions.response.TopLogprob")]
pub struct TopLogprob {
pub token: String,
pub bytes: Option<Vec<u8>>,
#[serde(deserialize_with = "crate::serde_util::option_decimal")]
#[schemars(with = "Option<f64>")]
#[arbitrary(with = crate::arbitrary_util::arbitrary_option_rust_decimal)]
pub logprob: Option<rust_decimal::Decimal>,
}