File tree Expand file tree Collapse file tree
Tool/Sources/OpenAIService Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -587,24 +587,37 @@ extension ChatGPTService {
587587 } ( ) ,
588588 content: chatMessage. content ?? " " ,
589589 name: chatMessage. name,
590- toolCalls: chatMessage. toolCalls? . map {
591- . init(
592- id: $0. id,
593- type: $0. type,
594- function: . init(
595- name: $0. function. name,
596- arguments: $0. function. arguments
597- )
598- )
599- }
590+ toolCalls: {
591+ if model. info. supportsFunctionCalling {
592+ chatMessage. toolCalls? . map {
593+ . init(
594+ id: $0. id,
595+ type: $0. type,
596+ function: . init(
597+ name: $0. function. name,
598+ arguments: $0. function. arguments
599+ )
600+ )
601+ }
602+ } else {
603+ nil
604+ }
605+ } ( )
600606 ) )
601607
602608 for call in chatMessage. toolCalls ?? [ ] {
603- all. append ( ChatCompletionsRequestBody . Message (
604- role: . tool,
605- content: call. response. content,
606- toolCallId: call. response. id
607- ) )
609+ if model. info. supportsFunctionCalling {
610+ all. append ( ChatCompletionsRequestBody . Message (
611+ role: . tool,
612+ content: call. response. content,
613+ toolCallId: call. response. id
614+ ) )
615+ } else {
616+ all. append ( ChatCompletionsRequestBody . Message (
617+ role: . user,
618+ content: call. response. content
619+ ) )
620+ }
608621 }
609622
610623 return all
You can’t perform that action at this time.
0 commit comments