1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
* OpenAI API
*
* The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.
*
* The version of the OpenAPI document: 2.3.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// AssistantObject : Represents an `assistant` that can call the model and use tools.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct AssistantObject {
/// The identifier, which can be referenced in API endpoints.
#[serde(rename = "id")]
pub id: String,
/// The object type, which is always `assistant`.
#[serde(rename = "object")]
pub object: Object,
/// The Unix timestamp (in seconds) for when the assistant was created.
#[serde(rename = "created_at")]
pub created_at: i32,
/// The name of the assistant. The maximum length is 256 characters.
#[serde(rename = "name", deserialize_with = "Option::deserialize")]
pub name: Option<String>,
/// The description of the assistant. The maximum length is 512 characters.
#[serde(rename = "description", deserialize_with = "Option::deserialize")]
pub description: Option<String>,
/// ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them.
#[serde(rename = "model")]
pub model: String,
/// The system instructions that the assistant uses. The maximum length is 256,000 characters.
#[serde(rename = "instructions", deserialize_with = "Option::deserialize")]
pub instructions: Option<String>,
/// A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`.
#[serde(rename = "tools")]
pub tools: Vec<models::AssistantObjectToolsInner>,
#[serde(
rename = "tool_resources",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub tool_resources: Option<Option<Box<models::Object0>>>,
/// Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
#[serde(rename = "metadata", deserialize_with = "Option::deserialize")]
pub metadata: Option<std::collections::HashMap<String, String>>,
/// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
#[serde(
rename = "temperature",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub temperature: Option<Option<f64>>,
/// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both.
#[serde(
rename = "top_p",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub top_p: Option<Option<f64>>,
#[serde(
rename = "response_format",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub response_format: Option<Option<Box<models::AssistantsApiResponseFormatOption>>>,
}
impl AssistantObject {
/// Represents an `assistant` that can call the model and use tools.
pub fn new(
id: String,
object: Object,
created_at: i32,
name: Option<String>,
description: Option<String>,
model: String,
instructions: Option<String>,
tools: Vec<models::AssistantObjectToolsInner>,
metadata: Option<std::collections::HashMap<String, String>>,
) -> AssistantObject {
AssistantObject {
id,
object,
created_at,
name,
description,
model,
instructions,
tools,
tool_resources: None,
metadata,
temperature: None,
top_p: None,
response_format: None,
}
}
}
/// The object type, which is always `assistant`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
#[serde(rename = "assistant")]
Assistant,
}
impl Default for Object {
fn default() -> Object {
Self::Assistant
}
}
impl std::fmt::Display for AssistantObject {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match serde_json::to_string(self) {
Ok(s) => write!(f, "{}", s),
Err(_) => Err(std::fmt::Error),
}
}
}