From e65513eb3d60b90c1e3f167d174480036e143f23 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Fri, 24 May 2024 16:26:30 -0700 Subject: [PATCH] chore: remove messages hacks for external providers --- pkg/openai/client.go | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/pkg/openai/client.go b/pkg/openai/client.go index 46d1a3da..d5d56a22 100644 --- a/pkg/openai/client.go +++ b/pkg/openai/client.go @@ -217,7 +217,7 @@ func toMessages(request types.CompletionRequest, compat bool) (result []openai.C msgs []types.CompletionMessage ) - if request.InternalSystemPrompt == nil || *request.InternalSystemPrompt { + if !compat && (request.InternalSystemPrompt == nil || *request.InternalSystemPrompt) { systemPrompts = append(systemPrompts, system.InternalSystemPrompt) } @@ -236,25 +236,6 @@ func toMessages(request types.CompletionRequest, compat bool) (result []openai.C }) } - if compat { - // This is terrible hack to deal with APIs that strictly want: (system, user | user) (assistant, user)* assistant? - // Two scenarios where this breaks with GPTScript is just sending system, or sending system, assistant - - // Don't send just a system message - if len(msgs) == 1 && msgs[0].Role == types.CompletionMessageRoleTypeSystem { - msgs[0].Role = types.CompletionMessageRoleTypeUser - } - - // Don't send system, assistant. If so, insert a user message that just has "." - if len(msgs) > 1 && msgs[0].Role == types.CompletionMessageRoleTypeSystem && - msgs[1].Role == types.CompletionMessageRoleTypeAssistant { - msgs = slices.Insert(msgs, 1, types.CompletionMessage{ - Role: types.CompletionMessageRoleTypeUser, - Content: types.Text("."), - }) - } - } - for _, message := range msgs { chatMessage := openai.ChatCompletionMessage{ Role: string(message.Role),