Skip to content

Commit dcf35dd

Browse files
committed
Fixup custom role encoding
Signed-off-by: mudler <[email protected]>
1 parent e703226 commit dcf35dd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

api/openai.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -459,13 +459,13 @@ func chatEndpoint(cm *ConfigMerger, o *Option) func(c *fiber.Ctx) error {
459459
for _, i := range input.Messages {
460460
var content string
461461
role := i.Role
462-
// if function call, we want to customize the role so we can display better that the "assistant called a json action"
462+
// if function call, we might want to customize the role so we can display better that the "assistant called a json action"
463463
// if an "assistant_function_call" role is defined, we use it, otherwise we use the role that is passed by in the request
464-
if i.FunctionCall != nil {
464+
if i.FunctionCall != nil && i.Role == "assistant" {
465465
roleFn := "assistant_function_call"
466466
r := config.Roles[roleFn]
467467
if r != "" {
468-
role = r
468+
role = roleFn
469469
}
470470
}
471471
r := config.Roles[role]

0 commit comments

Comments
 (0)