Skip to content

Commit

Permalink
fix: misses
Browse files Browse the repository at this point in the history
  • Loading branch information
Googlefan committed May 16, 2024
1 parent a8db63d commit f5158de
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
20 changes: 15 additions & 5 deletions src/chat/gemini.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ async function* generateGeminiContent(
parts: [
{
text: c.text,
...(c.attachment
? {
},
...(c.attachment
? [
{
inlineData: {
mimeType: c.attachment.mime,
data: c.attachment.data,
},
}
: {}),
},
},
]
: []),
],
})),
systemInstruction: system
Expand Down Expand Up @@ -81,6 +83,9 @@ async function* generateGeminiContent(
content: text,
};
}
if (chunk.name.includes("Value")) {
console.debug(chunk.name.slice(0, -5), chunk.value);
}
}
} catch (e) {
console.warn(e);
Expand All @@ -92,6 +97,11 @@ export const geminiPro: ChatModel = {
name: "Gemini 1.0 Pro",
id: "gemini-1.0-pro",
async generate(chat, system) {
for (const c of chat) {
if (c.attachment) {
throw new Error("Gemini 1.0 does not support attachments");
}
}
return generateGeminiContent(chat, "gemini-pro", system);
},
};
Expand Down
5 changes: 5 additions & 0 deletions src/chat/llama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import { evar } from "../var";
const endpoint = evar("LLAMA_CPP_ENDPOINT");

async function* generate(chat: Chat[], system?: string) {
for (const c of chat) {
if(c.attachment) {
throw new Error("Llama3 does not support attachments");
}
}
if (system) {
chat.unshift({
role: "system",
Expand Down
9 changes: 5 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ client.on(Events.InteractionCreate, async (i) => {
if (!command) return;
try {
await command.execute(i);
} catch (e) {
} catch (e: unknown) {
console.error(e);
if (i.deferred) i.followUp("Error");
else if (i.replied) i.editReply("Error");
else i.reply("Error");
const err = (e as Error).toString();
if (i.deferred) i.followUp(err);
else if (i.replied) i.editReply(err);
else i.reply(err);
}
}
});
Expand Down

0 comments on commit f5158de

Please sign in to comment.