diff --git a/async-openai/src/types/impls.rs b/async-openai/src/types/impls.rs index 631e5fe5..57f060ac 100644 --- a/async-openai/src/types/impls.rs +++ b/async-openai/src/types/impls.rs @@ -351,13 +351,14 @@ impl_from_for_array_of_integer_array!(u16, Prompt); impl From<&str> for ChatCompletionFunctionCall { fn from(value: &str) -> Self { - ChatCompletionFunctionCall::String(value.to_string()) + match value { + "none" => Self::None, + "auto" => Self::Auto, + _ => Self::Function { name: value.to_string() }, + } } } -impl From for ChatCompletionFunctionCall { - fn from(value: serde_json::Value) -> Self { - ChatCompletionFunctionCall::Object(value) } } diff --git a/async-openai/src/types/types.rs b/async-openai/src/types/types.rs index 6f569cac..22676197 100644 --- a/async-openai/src/types/types.rs +++ b/async-openai/src/types/types.rs @@ -37,11 +37,14 @@ pub enum Stop { StringArray(Vec), // minItems: 1; maxItems: 4 } -#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -#[serde(untagged)] +#[derive(Debug, Clone, PartialEq)] pub enum ChatCompletionFunctionCall { - String(String), - Object(serde_json::Value), + /// The model does not call a function, and responds to the end-user. + None, + /// The model can pick between an end-user or calling a function. + Auto, + /// Forces the model to call the specified function. + Function { name : String }, } #[derive(Clone, Serialize, Default, Debug, Builder, PartialEq)]