Skip to content

Commit 55fc9cd

Browse files
TogetherAI Llama 3.2 vision models support (#2666)
* togetherai llama 3.2 vision models support * remove console log * fix listing to reflect what is on the chart --------- Co-authored-by: timothycarambat <[email protected]>
1 parent 5e69853 commit 55fc9cd

File tree

4 files changed

+489
-181
lines changed

4 files changed

+489
-181
lines changed

server/utils/AiProviders/togetherAi/index.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,23 @@ class TogetherAiLLM {
4040
);
4141
}
4242

43+
#generateContent({ userPrompt, attachments = [] }) {
44+
if (!attachments.length) {
45+
return userPrompt;
46+
}
47+
48+
const content = [{ type: "text", text: userPrompt }];
49+
for (let attachment of attachments) {
50+
content.push({
51+
type: "image_url",
52+
image_url: {
53+
url: attachment.contentString,
54+
},
55+
});
56+
}
57+
return content.flat();
58+
}
59+
4360
allModelInformation() {
4461
return togetherAiModels();
4562
}
@@ -70,12 +87,20 @@ class TogetherAiLLM {
7087
contextTexts = [],
7188
chatHistory = [],
7289
userPrompt = "",
90+
attachments = [],
7391
}) {
7492
const prompt = {
7593
role: "system",
7694
content: `${systemPrompt}${this.#appendContext(contextTexts)}`,
7795
};
78-
return [prompt, ...chatHistory, { role: "user", content: userPrompt }];
96+
return [
97+
prompt,
98+
...chatHistory,
99+
{
100+
role: "user",
101+
content: this.#generateContent({ userPrompt, attachments }),
102+
},
103+
];
79104
}
80105

81106
async getChatCompletion(messages = null, { temperature = 0.7 }) {

0 commit comments

Comments
 (0)