Skip to main content

objectiveai_sdk/functions/
response.rs

1//! Function listing and usage response types.
2
3use crate::functions;
4use schemars::JsonSchema;
5use serde::{Deserialize, Serialize};
6
7/// Response from listing functions.
8#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
9#[schemars(rename = "functions.ListFunctionResponse")]
10pub struct ListFunctionResponse {
11    /// List of available functions.
12    pub data: Vec<ListFunctionItem>,
13}
14
15/// A function in a list response.
16pub type ListFunctionItem = crate::RemotePath;
17
18#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
19#[schemars(rename = "functions.GetFunctionResponse")]
20pub struct GetFunctionResponse {
21    #[serde(flatten)]
22    #[schemars(schema_with = "crate::flatten_schema::<crate::RemotePath>")]
23    pub path: crate::RemotePath,
24    #[serde(flatten)]
25    #[schemars(
26        schema_with = "crate::flatten_schema::<functions::FullRemoteFunction>"
27    )]
28    pub inner: functions::FullRemoteFunction,
29}
30
31/// Usage statistics for a function.
32#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
33#[schemars(rename = "functions.UsageFunctionResponse")]
34pub struct UsageFunctionResponse {
35    /// Total number of requests made with this function.
36    pub requests: u64,
37    /// Total completion tokens used.
38    pub completion_tokens: u64,
39    /// Total prompt tokens used.
40    pub prompt_tokens: u64,
41    /// Total cost incurred.
42    #[serde(deserialize_with = "crate::serde_util::decimal")]
43    #[schemars(with = "f64")]
44    pub total_cost: rust_decimal::Decimal,
45}
46
47/// Response from listing function-profile pairs.
48#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
49#[schemars(rename = "functions.ListFunctionProfilePairResponse")]
50pub struct ListFunctionProfilePairResponse {
51    /// List of available function-profile pairs.
52    pub data: Vec<ListFunctionProfilePairItem>,
53}
54
55/// A function-profile pair in a list response.
56#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
57#[schemars(rename = "functions.ListFunctionProfilePairItem")]
58pub struct ListFunctionProfilePairItem {
59    /// The function.
60    pub function: ListFunctionItem,
61    /// The profile.
62    pub profile: functions::profiles::response::ListProfileItem,
63}
64
65/// Response from getting a function-profile pair.
66#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
67#[schemars(rename = "functions.GetFunctionProfilePairResponse")]
68pub struct GetFunctionProfilePairResponse {
69    /// The function.
70    pub function: GetFunctionResponse,
71    /// The profile.
72    pub profile: functions::profiles::response::GetProfileResponse,
73}
74
75/// Usage statistics for a function-profile pair.
76#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
77#[schemars(rename = "functions.UsageFunctionProfilePairResponse")]
78pub struct UsageFunctionProfilePairResponse {
79    /// Total number of requests made with this function-profile pair.
80    pub requests: u64,
81    /// Total completion tokens used.
82    pub completion_tokens: u64,
83    /// Total prompt tokens used.
84    pub prompt_tokens: u64,
85    /// Total cost incurred.
86    #[serde(deserialize_with = "crate::serde_util::decimal")]
87    #[schemars(with = "f64")]
88    pub total_cost: rust_decimal::Decimal,
89}