mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-19 12:40:09 +01:00
Support gpt-4o for Azure deployments (#2182)
This commit is contained in:
parent
12df88b2c5
commit
b4651aff35
@ -65,17 +65,47 @@ class AzureOpenAiLLM {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates appropriate content array for a message + attachments.
|
||||||
|
* @param {{userPrompt:string, attachments: import("../../helpers").Attachment[]}}
|
||||||
|
* @returns {string|object[]}
|
||||||
|
*/
|
||||||
|
#generateContent({ userPrompt, attachments = [] }) {
|
||||||
|
if (!attachments.length) {
|
||||||
|
return userPrompt;
|
||||||
|
}
|
||||||
|
|
||||||
|
const content = [{ type: "text", text: userPrompt }];
|
||||||
|
for (let attachment of attachments) {
|
||||||
|
content.push({
|
||||||
|
type: "image_url",
|
||||||
|
imageUrl: {
|
||||||
|
url: attachment.contentString,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return content.flat();
|
||||||
|
}
|
||||||
|
|
||||||
constructPrompt({
|
constructPrompt({
|
||||||
systemPrompt = "",
|
systemPrompt = "",
|
||||||
contextTexts = [],
|
contextTexts = [],
|
||||||
chatHistory = [],
|
chatHistory = [],
|
||||||
userPrompt = "",
|
userPrompt = "",
|
||||||
|
attachments = [], // This is the specific attachment for only this prompt
|
||||||
}) {
|
}) {
|
||||||
const prompt = {
|
const prompt = {
|
||||||
role: "system",
|
role: "system",
|
||||||
content: `${systemPrompt}${this.#appendContext(contextTexts)}`,
|
content: `${systemPrompt}${this.#appendContext(contextTexts)}`,
|
||||||
};
|
};
|
||||||
return [prompt, ...chatHistory, { role: "user", content: userPrompt }];
|
return [
|
||||||
|
prompt,
|
||||||
|
...chatHistory,
|
||||||
|
{
|
||||||
|
role: "user",
|
||||||
|
content: this.#generateContent({ userPrompt, attachments }),
|
||||||
|
},
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
async getChatCompletion(messages = [], { temperature = 0.7 }) {
|
async getChatCompletion(messages = [], { temperature = 0.7 }) {
|
||||||
|
Loading…
Reference in New Issue
Block a user