feat: compatible old openai message
This commit is contained in:
parent
42ee0e0924
commit
3782c48008
|
@ -83,10 +83,15 @@ export class ChatGPTApi implements LLMApi {
|
||||||
const base64 = Buffer.from(response.data, "binary").toString("base64");
|
const base64 = Buffer.from(response.data, "binary").toString("base64");
|
||||||
return base64;
|
return base64;
|
||||||
};
|
};
|
||||||
|
if (options.config.model === "gpt-4-vision-preview") {
|
||||||
for (const v of options.messages) {
|
for (const v of options.messages) {
|
||||||
let message: {
|
let message: {
|
||||||
role: string;
|
role: string;
|
||||||
content: { type: string; text?: string; image_url?: { url: string } }[];
|
content: {
|
||||||
|
type: string;
|
||||||
|
text?: string;
|
||||||
|
image_url?: { url: string };
|
||||||
|
}[];
|
||||||
} = {
|
} = {
|
||||||
role: v.role,
|
role: v.role,
|
||||||
content: [],
|
content: [],
|
||||||
|
@ -106,6 +111,14 @@ export class ChatGPTApi implements LLMApi {
|
||||||
}
|
}
|
||||||
messages.push(message);
|
messages.push(message);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
options.messages.map((v) =>
|
||||||
|
messages.push({
|
||||||
|
role: v.role,
|
||||||
|
content: v.content,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const modelConfig = {
|
const modelConfig = {
|
||||||
...useAppConfig.getState().modelConfig,
|
...useAppConfig.getState().modelConfig,
|
||||||
|
|
Loading…
Reference in New Issue