Skip to content

Commit e65513e

Browse files
chore: remove messages hacks for external providers
1 parent 9291758 commit e65513e

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

pkg/openai/client.go

+1-20
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func toMessages(request types.CompletionRequest, compat bool) (result []openai.C
217217
msgs []types.CompletionMessage
218218
)
219219

220-
if request.InternalSystemPrompt == nil || *request.InternalSystemPrompt {
220+
if !compat && (request.InternalSystemPrompt == nil || *request.InternalSystemPrompt) {
221221
systemPrompts = append(systemPrompts, system.InternalSystemPrompt)
222222
}
223223

@@ -236,25 +236,6 @@ func toMessages(request types.CompletionRequest, compat bool) (result []openai.C
236236
})
237237
}
238238

239-
if compat {
240-
// This is terrible hack to deal with APIs that strictly want: (system, user | user) (assistant, user)* assistant?
241-
// Two scenarios where this breaks with GPTScript is just sending system, or sending system, assistant
242-
243-
// Don't send just a system message
244-
if len(msgs) == 1 && msgs[0].Role == types.CompletionMessageRoleTypeSystem {
245-
msgs[0].Role = types.CompletionMessageRoleTypeUser
246-
}
247-
248-
// Don't send system, assistant. If so, insert a user message that just has "."
249-
if len(msgs) > 1 && msgs[0].Role == types.CompletionMessageRoleTypeSystem &&
250-
msgs[1].Role == types.CompletionMessageRoleTypeAssistant {
251-
msgs = slices.Insert(msgs, 1, types.CompletionMessage{
252-
Role: types.CompletionMessageRoleTypeUser,
253-
Content: types.Text("."),
254-
})
255-
}
256-
}
257-
258239
for _, message := range msgs {
259240
chatMessage := openai.ChatCompletionMessage{
260241
Role: string(message.Role),

0 commit comments

Comments
 (0)