Skip to content

Commit 8a9cdd8

Browse files
authored
fix: skip serialization to null if field is none in CreateRunRequest (64bit#235)
* Make parallel_tool_calls not optional and use default * Skip serialization for all optional attributes
1 parent 6e354ce commit 8a9cdd8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

async-openai/src/types/run.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,44 +192,57 @@ pub struct CreateRunRequest {
192192
pub model: Option<String>,
193193

194194
/// Overrides the [instructions](https://platform.openai.com/docs/api-reference/assistants/createAssistant) of the assistant. This is useful for modifying the behavior on a per-run basis.
195+
#[serde(skip_serializing_if = "Option::is_none")]
195196
pub instructions: Option<String>,
196197

197198
/// 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.
199+
#[serde(skip_serializing_if = "Option::is_none")]
198200
pub additional_instructions: Option<String>,
199201

200202
/// Adds additional messages to the thread before creating the run.
203+
#[serde(skip_serializing_if = "Option::is_none")]
201204
pub additional_messages: Option<Vec<CreateMessageRequest>>,
202205

203206
/// Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis.
207+
#[serde(skip_serializing_if = "Option::is_none")]
204208
pub tools: Option<Vec<AssistantTools>>,
205209

206210
pub metadata: Option<HashMap<String, serde_json::Value>>,
207211

208212
/// The sampling temperature used for this run. If not set, defaults to 1.
213+
#[serde(skip_serializing_if = "Option::is_none")]
209214
pub temperature: Option<f32>,
210215

211216
/// 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.
212217
///
213218
/// We generally recommend altering this or temperature but not both.
219+
#[serde(skip_serializing_if = "Option::is_none")]
214220
pub top_p: Option<f32>,
215221

216222
/// 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.
223+
#[serde(skip_serializing_if = "Option::is_none")]
217224
pub stream: Option<bool>,
218225

219226
/// 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.
227+
#[serde(skip_serializing_if = "Option::is_none")]
220228
pub max_prompt_tokens: Option<u32>,
221229

222230
/// 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.
231+
#[serde(skip_serializing_if = "Option::is_none")]
223232
pub max_completion_tokens: Option<u32>,
224233

225234
/// Controls for how a thread will be truncated prior to the run. Use this to control the intial context window of the run.
235+
#[serde(skip_serializing_if = "Option::is_none")]
226236
pub truncation_strategy: Option<TruncationObject>,
227237

238+
#[serde(skip_serializing_if = "Option::is_none")]
228239
pub tool_choice: Option<AssistantsApiToolChoiceOption>,
229240

230241
/// Whether to enable [parallel function calling](https://platform.openai.com/docs/guides/function-calling/parallel-function-calling) during tool use.
242+
#[serde(skip_serializing_if = "Option::is_none")]
231243
pub parallel_tool_calls: Option<bool>,
232244

245+
#[serde(skip_serializing_if = "Option::is_none")]
233246
pub response_format: Option<AssistantsApiResponseFormatOption>,
234247
}
235248

0 commit comments

Comments
 (0)