fix: adjust default when json tool choice is

This commit is contained in:
David Holtz 2024-10-20 21:57:47 +00:00 committed by drbh
parent 905d503971
commit c1eab6cbb3

View File

@ -1066,7 +1066,7 @@ pub enum ToolChoice {
/// ///
/// `none` is the default when no tools are present. `auto` is the default if tools are present." /// `none` is the default when no tools are present. `auto` is the default if tools are present."
enum ToolTypeDeserializer { enum ToolTypeDeserializer {
/// `none` means the model will not call any tool and instead generates a message. /// None means `null` was passed in the JSON, and the default choice is applied based on the presence of tools.
Null, Null,
/// `auto` means the model can pick between generating a message or calling one or more tools. /// `auto` means the model can pick between generating a message or calling one or more tools.
@ -1081,7 +1081,7 @@ enum ToolTypeDeserializer {
impl From<ToolTypeDeserializer> for ToolChoice { impl From<ToolTypeDeserializer> for ToolChoice {
fn from(value: ToolTypeDeserializer) -> Self { fn from(value: ToolTypeDeserializer) -> Self {
match value { match value {
ToolTypeDeserializer::Null => ToolChoice::NoTool, ToolTypeDeserializer::Null => ToolChoice::Auto,
ToolTypeDeserializer::String(s) => match s.as_str() { ToolTypeDeserializer::String(s) => match s.as_str() {
"none" => ToolChoice::NoTool, "none" => ToolChoice::NoTool,
"auto" => ToolChoice::Auto, "auto" => ToolChoice::Auto,