don't use multi-media format when there are multiple text items
This commit is contained in:
parent
da905b0e10
commit
fa937c565b
1 changed files with 2 additions and 5 deletions
|
|
@ -57,16 +57,13 @@ class OpenAI extends BaseLLM {
|
|||
protected _convertMessage(message: ChatMessage) {
|
||||
if (typeof message.content === "string") {
|
||||
return message;
|
||||
} else if (
|
||||
} else if (!message.content.some((item) => item.type !== "text")) {
|
||||
// If no multi-media is in the message, just send as text
|
||||
// for compatibility with OpenAI "compatible" servers
|
||||
// that don't support multi-media format
|
||||
message.content.length === 1 &&
|
||||
message.content[0].type === "text"
|
||||
) {
|
||||
return {
|
||||
...message,
|
||||
content: message.content[0].text,
|
||||
content: message.content.map((item) => item.text).join(""),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue