use crate::functions::expression::ToStarlarkValue;
use serde::{Deserialize, Serialize};
use starlark::values::dict::AllocDict as StarlarkAllocDict;
use starlark::values::{Heap as StarlarkHeap, Value as StarlarkValue};
use schemars::JsonSchema;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, arbitrary::Arbitrary)]
#[schemars(rename = "vector.completions.response.Vote")]
pub struct Vote {
pub agent: String,
#[arbitrary(with = crate::arbitrary_util::arbitrary_u64)]
pub swarm_index: u64,
#[arbitrary(with = crate::arbitrary_util::arbitrary_u64)]
pub flat_swarm_index: u64,
pub prompt_id: String,
pub responses_ids: Vec<String>,
#[serde(deserialize_with = "crate::serde_util::vec_decimal")]
#[schemars(with = "Vec<f64>")]
#[arbitrary(with = crate::arbitrary_util::arbitrary_vec_rust_decimal)]
pub vote: Vec<rust_decimal::Decimal>,
#[serde(deserialize_with = "crate::serde_util::decimal")]
#[schemars(with = "f64")]
#[arbitrary(with = crate::arbitrary_util::arbitrary_rust_decimal)]
pub weight: rust_decimal::Decimal,
#[serde(skip_serializing_if = "Option::is_none")]
#[schemars(extend("omitempty" = true))]
pub retry: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
#[schemars(extend("omitempty" = true))]
pub from_cache: Option<bool>,
#[serde(skip)]
#[arbitrary(with = crate::arbitrary_util::arbitrary_option_u64)]
pub completion_index: Option<u64>,
}
impl ToStarlarkValue for Vote {
fn to_starlark_value<'v>(&self, heap: &'v StarlarkHeap) -> StarlarkValue<'v> {
heap.alloc(StarlarkAllocDict([
("agent", self.agent.to_starlark_value(heap)),
("swarm_index", self.swarm_index.to_starlark_value(heap)),
("flat_swarm_index", self.flat_swarm_index.to_starlark_value(heap)),
("prompt_id", self.prompt_id.to_starlark_value(heap)),
("responses_ids", self.responses_ids.to_starlark_value(heap)),
("vote", self.vote.to_starlark_value(heap)),
("weight", self.weight.to_starlark_value(heap)),
("retry", self.retry.to_starlark_value(heap)),
("from_cache", self.from_cache.to_starlark_value(heap)),
]))
}
}