@@ -398,9 +398,9 @@ func ChatEndpoint(cl *config.ModelConfigLoader, ml *model.ModelLoader, evaluator
398
398
}
399
399
400
400
finishReason := "stop"
401
- if toolsCalled {
401
+ if toolsCalled && len ( input . Tools ) > 0 {
402
402
finishReason = "tool_calls"
403
- } else if toolsCalled && len ( input . Tools ) == 0 {
403
+ } else if toolsCalled {
404
404
finishReason = "function_call"
405
405
}
406
406
@@ -443,11 +443,6 @@ func ChatEndpoint(cl *config.ModelConfigLoader, ml *model.ModelLoader, evaluator
443
443
log .Debug ().Msgf ("Text content to return: %s" , textContentToReturn )
444
444
noActionsToRun := len (results ) > 0 && results [0 ].Name == noActionName || len (results ) == 0
445
445
446
- finishReason := "stop"
447
- if len (input .Tools ) > 0 {
448
- finishReason = "tool_calls"
449
- }
450
-
451
446
switch {
452
447
case noActionsToRun :
453
448
result , err := handleQuestion (config , cl , input , ml , startupOptions , results , s , predInput )
@@ -457,11 +452,11 @@ func ChatEndpoint(cl *config.ModelConfigLoader, ml *model.ModelLoader, evaluator
457
452
}
458
453
459
454
* c = append (* c , schema.Choice {
460
- FinishReason : finishReason ,
455
+ FinishReason : "stop" ,
461
456
Message : & schema.Message {Role : "assistant" , Content : & result }})
462
457
default :
463
458
toolChoice := schema.Choice {
464
- FinishReason : finishReason ,
459
+ finishReason : "tool_calls" ,
465
460
Message : & schema.Message {
466
461
Role : "assistant" ,
467
462
},
0 commit comments