@@ -575,6 +575,13 @@ extension ChatGPTService {
575575 model: ChatModel ,
576576 stream: Bool
577577 ) -> ChatCompletionsRequestBody {
578+ let serviceSupportsFunctionCalling = switch model. format {
579+ case . openAI, . openAICompatible, . azureOpenAI:
580+ model. info. supportsFunctionCalling
581+ case . ollama, . googleAI:
582+ false
583+ }
584+
578585 let messages = prompt. history. flatMap { chatMessage in
579586 var all = [ ChatCompletionsRequestBody . Message] ( )
580587 all. append ( ChatCompletionsRequestBody . Message (
@@ -588,7 +595,7 @@ extension ChatGPTService {
588595 content: chatMessage. content ?? " " ,
589596 name: chatMessage. name,
590597 toolCalls: {
591- if model . info . supportsFunctionCalling {
598+ if serviceSupportsFunctionCalling {
592599 chatMessage. toolCalls? . map {
593600 . init(
594601 id: $0. id,
@@ -606,7 +613,7 @@ extension ChatGPTService {
606613 ) )
607614
608615 for call in chatMessage. toolCalls ?? [ ] {
609- if model . info . supportsFunctionCalling {
616+ if serviceSupportsFunctionCalling {
610617 all. append ( ChatCompletionsRequestBody . Message (
611618 role: . tool,
612619 content: call. response. content,
@@ -635,10 +642,10 @@ extension ChatGPTService {
635642 maxToken: model. info. maxTokens,
636643 remainingTokens: remainingTokens
637644 ) ,
638- toolChoice: model . info . supportsFunctionCalling
645+ toolChoice: serviceSupportsFunctionCalling
639646 ? functionProvider. functionCallStrategy
640647 : nil ,
641- tools: model . info . supportsFunctionCalling
648+ tools: serviceSupportsFunctionCalling
642649 ? functionProvider. functions. map {
643650 . init( function: ChatGPTFunctionSchema (
644651 name: $0. name,
0 commit comments