openai_struct/models/assistant_object.rs
1/*
2 * OpenAI API
3 *
4 * The OpenAI REST API. Please see pub https://platform.openai.com/docs/api-reference for more details.
5 *
6 * OpenAPI spec pub version: 2.3.0
7 *
8 * Generated pub by: https://github.com/swagger-api/swagger-codegen.git
9 */
10
11/// pub AssistantObject : Represents an `assistant` that can call the model and use tools.
12
13#[allow(unused_imports)]
14use serde_json::Value;
15
16/// # on openapi.yaml
17///
18/// ```yaml
19/// AssistantObject:
20/// type: object
21/// title: Assistant
22/// description: Represents an `assistant` that can call the model and use tools.
23/// properties:
24/// id:
25/// description: The identifier, which can be referenced in API endpoints.
26/// type: string
27/// object:
28/// description: The object type, which is always `assistant`.
29/// type: string
30/// enum:
31/// - assistant
32/// x-stainless-const: true
33/// created_at:
34/// description: The Unix timestamp (in seconds) for when the assistant was created.
35/// type: integer
36/// name:
37/// description: |
38/// The name of the assistant. The maximum length is 256 characters.
39/// type: string
40/// maxLength: 256
41/// nullable: true
42/// description:
43/// description: >
44/// The description of the assistant. The maximum length is 512
45/// characters.
46/// type: string
47/// maxLength: 512
48/// nullable: true
49/// model:
50/// description: >
51/// ID of the model to use. You can use the [List
52/// models](/docs/api-reference/models/list) API to see all of your
53/// available models, or see our [Model overview](/docs/models) for
54/// descriptions of them.
55/// type: string
56/// instructions:
57/// description: >
58/// The system instructions that the assistant uses. The maximum length
59/// is 256,000 characters.
60/// type: string
61/// maxLength: 256000
62/// nullable: true
63/// tools:
64/// description: >
65/// A list of tool enabled on the assistant. There can be a maximum of
66/// 128 tools per assistant. Tools can be of types `code_interpreter`,
67/// `file_search`, or `function`.
68/// default: []
69/// type: array
70/// maxItems: 128
71/// items:
72/// oneOf:
73/// - $ref: "#/components/schemas/AssistantToolsCode"
74/// - $ref: "#/components/schemas/AssistantToolsFileSearch"
75/// - $ref: "#/components/schemas/AssistantToolsFunction"
76/// tool_resources:
77/// type: object
78/// description: >
79/// A set of resources that are used by the assistant's tools. The
80/// resources are specific to the type of tool. For example, the
81/// `code_interpreter` tool requires a list of file IDs, while the
82/// `file_search` tool requires a list of vector store IDs.
83/// properties:
84/// code_interpreter:
85/// type: object
86/// properties:
87/// file_ids:
88/// type: array
89/// description: >
90/// A list of [file](/docs/api-reference/files) IDs made
91/// available to the `code_interpreter`` tool. There can be a
92/// maximum of 20 files associated with the tool.
93/// default: []
94/// maxItems: 20
95/// items:
96/// type: string
97/// file_search:
98/// type: object
99/// properties:
100/// vector_store_ids:
101/// type: array
102/// description: >
103/// The ID of the [vector
104/// store](/docs/api-reference/vector-stores/object) attached to
105/// this assistant. There can be a maximum of 1 vector store
106/// attached to the assistant.
107/// maxItems: 1
108/// items:
109/// type: string
110/// nullable: true
111/// metadata:
112/// $ref: "#/components/schemas/Metadata"
113/// temperature:
114/// description: >
115/// What sampling temperature to use, between 0 and 2. Higher values
116/// like 0.8 will make the output more random, while lower values like
117/// 0.2 will make it more focused and deterministic.
118/// type: number
119/// minimum: 0
120/// maximum: 2
121/// default: 1
122/// example: 1
123/// nullable: true
124/// top_p:
125/// type: number
126/// minimum: 0
127/// maximum: 1
128/// default: 1
129/// example: 1
130/// nullable: true
131/// description: >
132/// An alternative to sampling with temperature, called nucleus
133/// sampling, where the model considers the results of the tokens with
134/// top_p probability mass. So 0.1 means only the tokens comprising the
135/// top 10% probability mass are considered.
136///
137///
138/// We generally recommend altering this or temperature but not both.
139/// response_format:
140/// $ref: "#/components/schemas/AssistantsApiResponseFormatOption"
141/// nullable: true
142/// required:
143/// - id
144/// - object
145/// - created_at
146/// - name
147/// - description
148/// - model
149/// - instructions
150/// - tools
151/// - metadata
152/// x-oaiMeta:
153/// name: The assistant object
154/// beta: true
155/// example: >
156/// {
157/// "id": "asst_abc123",
158/// "object": "assistant",
159/// "created_at": 1698984975,
160/// "name": "Math Tutor",
161/// "description": null,
162/// "model": "gpt-4o",
163/// "instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.",
164/// "tools": [
165/// {
166/// "type": "code_interpreter"
167/// }
168/// ],
169/// "metadata": {},
170/// "top_p": 1.0,
171/// "temperature": 1.0,
172/// "response_format": "auto"
173/// }
174/// ```
175#[derive(Debug, Serialize, Deserialize)]
176pub struct AssistantObject {
177 /// The Unix timestamp (in seconds) for when the assistant was created.
178 #[serde(rename = "created_at")]
179 pub created_at: i32,
180 /// The description of the assistant. The maximum length is 512 characters.
181 #[serde(rename = "description")]
182 pub description: String,
183 /// The identifier, which can be referenced in API endpoints.
184 #[serde(rename = "id")]
185 pub id: String,
186 /// The system instructions that the assistant uses. The maximum length is 256,000 characters.
187 #[serde(rename = "instructions")]
188 pub instructions: String,
189 #[serde(rename = "metadata")]
190 pub metadata: crate::models::Metadata,
191 /// 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.
192 #[serde(rename = "model")]
193 pub model: String,
194 /// The name of the assistant. The maximum length is 256 characters.
195 #[serde(rename = "name")]
196 pub name: String,
197 /// The object type, which is always `assistant`.
198 #[serde(rename = "object")]
199 #[serde(default = "default_object")]
200 pub object: String,
201 #[serde(rename = "response_format")]
202 pub response_format: Option<crate::models::AssistantsApiResponseFormatOption>,
203 /// 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.
204 #[serde(rename = "temperature")]
205 pub temperature: Option<f32>,
206 #[serde(rename = "tool_resources")]
207 pub tool_resources: Option<crate::models::AssistantObjectToolResources>,
208 /// 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`.
209 #[serde(rename = "tools")]
210 pub tools: Vec<AssistantObjectTool>,
211 /// 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.
212 #[serde(rename = "top_p")]
213 pub top_p: Option<f32>,
214}
215
216fn default_object() -> String {
217 "assistant".into()
218}
219
220#[derive(Debug, Serialize, Deserialize)]
221#[serde(untagged)]
222pub enum AssistantObjectTool {
223 Code(crate::AssistantToolsCode),
224 FileSearch(crate::AssistantToolsFileSearch),
225 Function(crate::AssistantToolsFunction),
226}