Skip to main content

objectiveai_sdk/functions/
response.rs

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