Skip to content

Commit

Permalink
TogetherAI Llama 3.2 vision models support (#2666)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
shatfield4 and timothycarambat authored Nov 21, 2024
1 parent 5e69853 commit 55fc9cd
Show file tree
Hide file tree
Showing 4 changed files with 489 additions and 181 deletions.
27 changes: 26 additions & 1 deletion server/utils/AiProviders/togetherAi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ class TogetherAiLLM {
);
}

#generateContent({ userPrompt, attachments = [] }) {
if (!attachments.length) {
return userPrompt;
}

const content = [{ type: "text", text: userPrompt }];
for (let attachment of attachments) {
content.push({
type: "image_url",
image_url: {
url: attachment.contentString,
},
});
}
return content.flat();
}

allModelInformation() {
return togetherAiModels();
}
Expand Down Expand Up @@ -70,12 +87,20 @@ class TogetherAiLLM {
contextTexts = [],
chatHistory = [],
userPrompt = "",
attachments = [],
}) {
const prompt = {
role: "system",
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 = null, { temperature = 0.7 }) {
Expand Down
Loading

0 comments on commit 55fc9cd

Please sign in to comment.