From 9acf04f816cac1bffb185b5c9cdc60beb49df99a Mon Sep 17 00:00:00 2001 From: Dongri Jin Date: Wed, 20 Nov 2024 08:44:58 +0900 Subject: [PATCH] Fix run object --- src/v1/assistant.rs | 42 +----------------------------------------- src/v1/run.rs | 3 ++- src/v1/types.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 42 deletions(-) diff --git a/src/v1/assistant.rs b/src/v1/assistant.rs index 9a42e1a..0c18ffe 100644 --- a/src/v1/assistant.rs +++ b/src/v1/assistant.rs @@ -57,53 +57,13 @@ pub struct AssistantObject { pub model: String, #[serde(skip_serializing_if = "Option::is_none")] pub instructions: Option, - pub tools: Vec, + pub tools: Vec, #[serde(skip_serializing_if = "Option::is_none")] pub tool_resources: Option, pub metadata: Option>, pub headers: Option>, } -#[derive(Debug, Deserialize, Serialize, Clone)] -#[serde(tag = "type")] -#[serde(rename_all = "snake_case")] -pub enum Tools { - CodeInterpreter, - FileSearch(ToolsFileSearch), - Function(ToolsFunction), -} - -#[derive(Debug, Deserialize, Serialize, Clone)] -pub struct ToolsFileSearch { - #[serde(skip_serializing_if = "Option::is_none")] - pub file_search: Option, -} - -#[derive(Debug, Deserialize, Serialize, Clone)] -pub struct ToolsFunction { - pub function: types::Function, -} - -#[derive(Debug, Deserialize, Serialize, Clone)] -pub struct ToolsFileSearchObject { - pub max_num_results: Option, - pub ranking_options: Option, -} - -#[derive(Debug, Deserialize, Serialize, Clone)] -pub struct FileSearchRankingOptions { - pub ranker: Option, - pub score_threshold: Option, -} - -#[derive(Debug, Deserialize, Serialize, Clone)] -pub enum FileSearchRanker { - #[serde(rename = "auto")] - Auto, - #[serde(rename = "default_2024_08_21")] - Default2024_08_21, -} - #[derive(Debug, Deserialize, Serialize, Clone)] pub struct ToolResource { #[serde(skip_serializing_if = "Option::is_none")] diff --git a/src/v1/run.rs b/src/v1/run.rs index 88f4276..645104f 100644 --- a/src/v1/run.rs +++ b/src/v1/run.rs @@ -3,6 +3,7 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; +use super::types; use crate::impl_builder_methods; #[derive(Debug, Serialize, Clone)] @@ -95,7 +96,7 @@ pub struct RunObject { pub completed_at: Option, pub model: String, pub instructions: Option, - pub tools: Vec>, + pub tools: Vec, pub metadata: HashMap, pub headers: Option>, } diff --git a/src/v1/types.rs b/src/v1/types.rs index d07343d..45c6b9a 100644 --- a/src/v1/types.rs +++ b/src/v1/types.rs @@ -45,3 +45,43 @@ pub struct JSONSchemaDefine { #[serde(skip_serializing_if = "Option::is_none")] pub items: Option>, } + +#[derive(Debug, Deserialize, Serialize, Clone)] +#[serde(tag = "type")] +#[serde(rename_all = "snake_case")] +pub enum Tools { + CodeInterpreter, + FileSearch(ToolsFileSearch), + Function(ToolsFunction), +} + +#[derive(Debug, Deserialize, Serialize, Clone)] +pub struct ToolsFileSearch { + #[serde(skip_serializing_if = "Option::is_none")] + pub file_search: Option, +} + +#[derive(Debug, Deserialize, Serialize, Clone)] +pub struct ToolsFunction { + pub function: Function, +} + +#[derive(Debug, Deserialize, Serialize, Clone)] +pub struct ToolsFileSearchObject { + pub max_num_results: Option, + pub ranking_options: Option, +} + +#[derive(Debug, Deserialize, Serialize, Clone)] +pub struct FileSearchRankingOptions { + pub ranker: Option, + pub score_threshold: Option, +} + +#[derive(Debug, Deserialize, Serialize, Clone)] +pub enum FileSearchRanker { + #[serde(rename = "auto")] + Auto, + #[serde(rename = "default_2024_08_21")] + Default2024_08_21, +}