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
/*
* 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};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct CreateRunRequest {
/// The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run.
#[serde(rename = "assistant_id")]
pub assistant_id: String,
/// The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used.
#[serde(rename = "model", skip_serializing_if = "Option::is_none")]
pub model: Option<String>,
#[serde(
rename = "reasoning_effort",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub reasoning_effort: Option<Option<models::ReasoningEffort>>,
/// Overrides the [instructions](/docs/api-reference/assistants/createAssistant) of the assistant. This is useful for modifying the behavior on a per-run basis.
#[serde(rename = "instructions", skip_serializing_if = "Option::is_none")]
pub instructions: Option<String>,
/// Appends additional instructions at the end of the instructions for the run. This is useful for modifying the behavior on a per-run basis without overriding other instructions.
#[serde(
rename = "additional_instructions",
skip_serializing_if = "Option::is_none"
)]
pub additional_instructions: Option<String>,
/// Adds additional messages to the thread before creating the run.
#[serde(
rename = "additional_messages",
skip_serializing_if = "Option::is_none"
)]
pub additional_messages: Option<Vec<models::CreateMessageRequest>>,
/// Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis.
#[serde(rename = "tools", skip_serializing_if = "Option::is_none")]
pub tools: Option<Vec<models::AssistantObjectToolsInner>>,
/// 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",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub metadata: Option<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", skip_serializing_if = "Option::is_none")]
pub temperature: 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", skip_serializing_if = "Option::is_none")]
pub top_p: Option<f64>,
/// If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message.
#[serde(rename = "stream", skip_serializing_if = "Option::is_none")]
pub stream: Option<bool>,
/// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.
#[serde(rename = "max_prompt_tokens", skip_serializing_if = "Option::is_none")]
pub max_prompt_tokens: Option<i32>,
/// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.
#[serde(
rename = "max_completion_tokens",
skip_serializing_if = "Option::is_none"
)]
pub max_completion_tokens: Option<i32>,
#[serde(
rename = "truncation_strategy",
skip_serializing_if = "Option::is_none"
)]
pub truncation_strategy: Option<Box<models::TruncationObject>>,
#[serde(rename = "tool_choice", skip_serializing_if = "Option::is_none")]
pub tool_choice: Option<Box<models::AssistantsApiToolChoiceOption>>,
/// Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use.
#[serde(
rename = "parallel_tool_calls",
skip_serializing_if = "Option::is_none"
)]
pub parallel_tool_calls: Option<bool>,
#[serde(rename = "response_format", skip_serializing_if = "Option::is_none")]
pub response_format: Option<Box<models::AssistantsApiResponseFormatOption>>,
}
impl CreateRunRequest {
pub fn new(assistant_id: String) -> CreateRunRequest {
CreateRunRequest {
assistant_id,
model: None,
reasoning_effort: None,
instructions: None,
additional_instructions: None,
additional_messages: None,
tools: None,
metadata: None,
temperature: None,
top_p: None,
stream: None,
max_prompt_tokens: None,
max_completion_tokens: None,
truncation_strategy: None,
tool_choice: None,
parallel_tool_calls: None,
response_format: None,
}
}
}
impl std::fmt::Display for CreateRunRequest {
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),
}
}
}