From fb2e7efb34a9ca652b07c4af2667668094d6f396 Mon Sep 17 00:00:00 2001 From: Pierpaolo Follia Date: Sun, 16 Jun 2024 15:22:15 +0200 Subject: [PATCH 1/2] Make parallel_tool_calls not optional and use default --- async-openai/src/types/run.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/async-openai/src/types/run.rs b/async-openai/src/types/run.rs index 16f58c5..abf51c9 100644 --- a/async-openai/src/types/run.rs +++ b/async-openai/src/types/run.rs @@ -228,7 +228,8 @@ pub struct CreateRunRequest { pub tool_choice: Option, /// Whether to enable [parallel function calling](https://platform.openai.com/docs/guides/function-calling/parallel-function-calling) during tool use. - pub parallel_tool_calls: Option, + #[serde(default)] + pub parallel_tool_calls: bool, pub response_format: Option, } From 54e82c53ad11c1b21c5ca935267f6ace5df37bc0 Mon Sep 17 00:00:00 2001 From: Pierpaolo Follia Date: Mon, 17 Jun 2024 11:01:37 +0200 Subject: [PATCH 2/2] Skip serialization for all optional attributes --- async-openai/src/types/run.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/async-openai/src/types/run.rs b/async-openai/src/types/run.rs index abf51c9..5aae377 100644 --- a/async-openai/src/types/run.rs +++ b/async-openai/src/types/run.rs @@ -192,45 +192,57 @@ pub struct CreateRunRequest { pub model: Option, /// 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. + #[serde(skip_serializing_if = "Option::is_none")] pub instructions: Option, /// 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(skip_serializing_if = "Option::is_none")] pub additional_instructions: Option, /// Adds additional messages to the thread before creating the run. + #[serde(skip_serializing_if = "Option::is_none")] pub additional_messages: Option>, /// Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. + #[serde(skip_serializing_if = "Option::is_none")] pub tools: Option>, pub metadata: Option>, /// The sampling temperature used for this run. If not set, defaults to 1. + #[serde(skip_serializing_if = "Option::is_none")] pub temperature: Option, /// 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(skip_serializing_if = "Option::is_none")] pub top_p: Option, /// 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(skip_serializing_if = "Option::is_none")] pub stream: Option, /// 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(skip_serializing_if = "Option::is_none")] pub max_prompt_tokens: Option, /// 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(skip_serializing_if = "Option::is_none")] pub max_completion_tokens: Option, /// Controls for how a thread will be truncated prior to the run. Use this to control the intial context window of the run. + #[serde(skip_serializing_if = "Option::is_none")] pub truncation_strategy: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub tool_choice: Option, /// Whether to enable [parallel function calling](https://platform.openai.com/docs/guides/function-calling/parallel-function-calling) during tool use. - #[serde(default)] - pub parallel_tool_calls: bool, + #[serde(skip_serializing_if = "Option::is_none")] + pub parallel_tool_calls: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub response_format: Option, }