From c4f4f6abe678f65ce8c08c411cbe1264f33c4614 Mon Sep 17 00:00:00 2001 From: Steve Dudenhoeffer Date: Sun, 20 Oct 2024 21:50:12 -0400 Subject: [PATCH] if an openai message has content and multicontent, fix it before passing it off to the api --- openai.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/openai.go b/openai.go index 224b9f5..caed728 100644 --- a/openai.go +++ b/openai.go @@ -43,6 +43,16 @@ func (o openai) requestToOpenAIRequest(request Request) oai.ChatCompletionReques } } + // openai does not allow Content and MultiContent to be set at the same time, so we need to check + if len(m.MultiContent) > 0 && m.Content != "" { + m.MultiContent = append([]oai.ChatMessagePart{{ + Type: "text", + Text: m.Content, + }}, m.MultiContent...) + + m.Content = "" + } + res.Messages = append(res.Messages, m) }