Skip to main content

openkind_core/
response.rs

1//! Response body. Spec: <https://docs.typesafe.ai/api#response-body>
2//!
3//! > One answer per question, returned under the same ids you provided.
4
5use std::collections::HashMap;
6
7use schemars::JsonSchema;
8use serde::{Deserialize, Serialize};
9
10use crate::answer::Answer;
11use crate::request::WireHashState;
12
13/// Token usage accounting for the evaluation request.
14///
15/// **Required** per the Jev wire specification.
16#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
17pub struct Usage {
18    /// Number of tokens in the input state and question instructions.
19    pub input_tokens: u32,
20    /// Number of tokens accounted to generating the evaluated judgments.
21    pub output_tokens: u32,
22}
23
24/// Evaluation response payload containing answers to all submitted questions.
25///
26/// See <https://docs.typesafe.ai/api#response-body> for the canonical wire specification.
27#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
28pub struct SystemResponse {
29    /// The model backend that performed the evaluation. **Required.**
30    pub model: String,
31
32    /// One answer per question id. **Required.**
33    pub answers: HashMap<String, Answer, WireHashState>,
34
35    /// Required token usage.
36    pub usage: Usage,
37}