Skip to content

Commit

Permalink
Added support for G1.5 Pro + WIP Wolfram command
Browse files Browse the repository at this point in the history
  • Loading branch information
maamokun committed Apr 16, 2024
1 parent 36e3393 commit faa28e9
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
4 changes: 2 additions & 2 deletions characters.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"image": "https://cdn.mikn.dev/bot-assets/gemini/characters/frieren.jpg",
"copyright": "© 山田鐘人・アベツカサ/小学館/「葬送のフリーレン」製作委員会"
},
{
{
"id": "anya",
"name": "アーニャ・フォージャー",
"place": "SPY×FAMILY",
Expand All @@ -35,7 +35,7 @@
"image": "https://cdn.mikn.dev/bot-assets/gemini/characters/anya.webp",
"copyright": "© 遠藤達哉/集英社・SPY×FAMILY製作委員会"
},
{
{
"id": "hikakin",
"name": "開發光 (HikakinTV)",
"place": "ユーチューバー",
Expand Down
6 changes: 4 additions & 2 deletions src/characters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export async function CharacterCommand(i: ChatInputCommandInteraction) {
const embed = new EmbedBuilder()
.setTitle("AIキャラクターを招待")
.setDescription("招待したいキャラクターを選択してください")
.setImage("https://cdn.mikn.dev/bot-assets/gemini/AICharSplash.png")
.setImage("https://cdn.mikn.dev/bot-assets/gemini/AICharSplash.png")
.setFooter({
text: "DISCLAIMER: All characters are owned by their respective rights holders. Neody is not affiliated with these owners in any way.",
})
Expand Down Expand Up @@ -110,7 +110,9 @@ export async function CharacterInvite(i: ButtonInteraction) {

const embed = new EmbedBuilder()
.setTitle("キャラクター招待")
.setDescription(`${character.name}がチャットに招待されました!\n\n:warning: キャラクターが言うことは全て作り話です!`)
.setDescription(
`${character.name}がチャットに招待されました!\n\n:warning: キャラクターが言うことは全て作り話です!`,
)
.setImage(character.image)
.setColor("#00ff00");

Expand Down
21 changes: 19 additions & 2 deletions src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,29 @@ export const commands = [
new SlashCommandBuilder()
.setName("clear")
.setDescription("AIチャットをリセットします"),
new SlashCommandBuilder()
.setName("wolfram")
.setDescription("Wolfram Alphaに質問します")
.addStringOption((x) =>
x.setName("text").setDescription("質問する内容").setRequired(true),
)
.addStringOption((x) =>
x
.setName("format")
.setDescription("出力形式を指定します")
.setRequired(false)
.addChoices(
{ name: "分析画像", value: "image" },
{ name: "短文", value: "short" },
),
),
new SlashCommandBuilder()
.setName("ask")
.setDescription("AIに質問します")
.addStringOption((x) =>
x.setName("text").setDescription("質問する内容").setRequired(true),
)

.addAttachmentOption((x) =>
x.setName("attachment").setDescription("質問する画像").setRequired(false),
)
Expand All @@ -26,8 +43,8 @@ export const commands = [
.setDescription("モデルを指定します")
.setRequired(false)
.addChoices(
{ name: "Gemini", value: "gemini-pro" },
{ name: "Swallow", value: "swallow" },
{ name: "Gemini 1.0 Pro", value: "gemini-pro" },
{ name: "Gemini 1.5 Pro", value: "gemini-1.5-pro" },
),
)
.addBooleanOption((x) =>
Expand Down
7 changes: 4 additions & 3 deletions src/i.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
StringSelectMenuInteraction,
} from "discord.js";
import { resetChat } from "./queue";
import { model, visionModel, resolveImages } from "./model";
import { model, ProModel, visionModel, resolveImages } from "./model";
import { LLamaCppChat, resetLLamaCppChat } from "./llamacpp";
import { imagineCommand, editButtonPress, editModalSubmit } from "./imagine";
import {
Expand Down Expand Up @@ -143,9 +143,10 @@ async function askCommand(i: ChatInputCommandInteraction) {
);
await i.deferReply({ ephemeral });
resText = (await chatFn([question, ...images])).response.text();
} else if (modelName === "swallow") {
} else if (modelName === "gemini-1.5-pro") {
let chatFn = ProModel.generateContent.bind(model);
await i.deferReply({ ephemeral });
resText = await new LLamaCppChat().chat(question);
resText = (await chatFn([question])).response.text();
}
if (resText.length == 0) {
await i.editReply("AIからの返信がありませんでした");
Expand Down
3 changes: 2 additions & 1 deletion src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { evar } from "./var";
import { request } from "undici";

const genAI = new GoogleGenerativeAI(evar("GEMINI_KEY"));
export const model = genAI.getGenerativeModel({ model: "gemini-pro" });
export const model = genAI.getGenerativeModel({ model: "gemini-1.0-pro" });
export const ProModel = genAI.getGenerativeModel({ model: "gemini-1.5-pro" });
export const visionModel = genAI.getGenerativeModel({
model: "gemini-pro-vision",
});
Expand Down

0 comments on commit faa28e9

Please sign in to comment.