From dcf35dd25f522b79e1e412e51cb80836a1475aea Mon Sep 17 00:00:00 2001 From: mudler Date: Sun, 9 Jul 2023 11:13:19 +0200 Subject: [PATCH] Fixup custom role encoding Signed-off-by: mudler --- api/openai.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/openai.go b/api/openai.go index 9746952..77d2c8e 100644 --- a/api/openai.go +++ b/api/openai.go @@ -459,13 +459,13 @@ func chatEndpoint(cm *ConfigMerger, o *Option) func(c *fiber.Ctx) error { for _, i := range input.Messages { var content string role := i.Role - // if function call, we want to customize the role so we can display better that the "assistant called a json action" + // if function call, we might want to customize the role so we can display better that the "assistant called a json action" // if an "assistant_function_call" role is defined, we use it, otherwise we use the role that is passed by in the request - if i.FunctionCall != nil { + if i.FunctionCall != nil && i.Role == "assistant" { roleFn := "assistant_function_call" r := config.Roles[roleFn] if r != "" { - role = r + role = roleFn } } r := config.Roles[role]