Skip to content
This repository was archived by the owner on Apr 24, 2024. It is now read-only.

Commit 075449f

Browse files
committed
Update dependencies and models
1 parent 4a2a25f commit 075449f

13 files changed

+115
-60
lines changed

package-lock.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
"rabbitmq-client": "^4.3.0",
5454
"redis": "^4.6.8",
5555
"sharp": "^0.33.0",
56-
"turing.sh": "^0.0.9"
56+
"turing.sh": "^0.1.1"
5757
}
5858
}

src/bot/commands/bot.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,14 @@ async function buildInfo(bot: Bot, guildId?: BigString): Promise<CreateMessageOp
3939
bot.shards.forEach((shard) => workers.add(shard.workerId));
4040
}
4141

42-
const stats = {
43-
guilds: 291000,
44-
};
45-
4642
return {
4743
embeds: [
4844
{
4945
title: "Bot Statistics",
5046
fields: [
5147
{
5248
name: "Servers 🖥️",
53-
value: "312.000",
49+
value: "334.000",
5450
inline: true,
5551
},
5652
{

src/bot/commands/describe.ts

+31-5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { LOADING_INDICATORS } from "../../types/models/users.js";
77
import { mergeImages } from "../utils/image-merge.js";
88
import { getDefaultValues, getSettingsValue } from "../utils/settings.js";
99
import { chargePlan, requiredPremium } from "../utils/premium.js";
10+
import vision from "../models/vision.js";
11+
import axios from "axios";
1012

1113
export default createCommand({
1214
body: {
@@ -20,16 +22,40 @@ export default createCommand({
2022
description: "The image to use",
2123
required: true,
2224
},
25+
{
26+
type: "String",
27+
name: "typeImage",
28+
description: "The type of image you want to describe",
29+
choices: [
30+
["Person", "person"],
31+
["Anything", "anything"],
32+
],
33+
},
2334
],
2435
},
2536
cooldown: {
26-
user: 1.5 * 60 * 1000,
27-
voter: 1.25 * 60 * 1000,
28-
subscription: 1 * 60 * 1000,
37+
user: 2 * 60 * 1000,
38+
voter: 1.5 * 60 * 1000,
39+
subscription: 1.25 * 60 * 1000,
2940
},
3041
interaction: async ({ interaction, options, env, premium }) => {
31-
await interaction.edit({
32-
content: "This command is currently disabled.",
42+
let typeImage = options.getString("typeImage") as "person" | "anything";
43+
if (!typeImage) typeImage = "anything";
44+
const image = options.getAttachment("image");
45+
const base64 = await imageUrlToBase64(image.url);
46+
47+
const response = await vision.run(interaction.bot.api, {
48+
image: base64,
49+
typeImage,
3350
});
51+
await interaction.edit({
52+
content: response.description,
53+
} as CreateMessageOptions);
3454
},
3555
});
56+
57+
async function imageUrlToBase64(url: string) {
58+
const res = await axios.get(url, { responseType: "arraybuffer" });
59+
const buffer = Buffer.from(res.data, "binary").toString("base64");
60+
return buffer;
61+
}

src/bot/commands/imagine.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,12 @@ export default createCommand({
150150
components: [
151151
{
152152
type: MessageComponentTypes.Button,
153-
label: 'Change model Here',
153+
label: "Change model Here",
154154
customId: "settings_open_image",
155155
disabled: false,
156156
emoji: {
157157
// warning symbol
158-
name: '⚠️',
158+
name: "⚠️",
159159
},
160160
style: ButtonStyles.Secondary,
161161
},
@@ -197,8 +197,9 @@ export default createCommand({
197197
embeds: [
198198
{
199199
color: config.brand.color,
200-
title: `Waiting in queue <${loadingIndicator.emoji.animated ? "a" : ""}:${loadingIndicator.emoji.name}:${loadingIndicator.emoji.id
201-
}>`,
200+
title: `Waiting in queue <${loadingIndicator.emoji.animated ? "a" : ""}:${loadingIndicator.emoji.name}:${
201+
loadingIndicator.emoji.id
202+
}>`,
202203
},
203204
],
204205
});
@@ -208,8 +209,9 @@ export default createCommand({
208209
embeds: [
209210
{
210211
color: config.brand.color,
211-
title: `Generating <${loadingIndicator.emoji.animated ? "a" : ""}:${loadingIndicator.emoji.name}:${loadingIndicator.emoji.id
212-
}>`,
212+
title: `Generating <${loadingIndicator.emoji.animated ? "a" : ""}:${loadingIndicator.emoji.name}:${
213+
loadingIndicator.emoji.id
214+
}>`,
213215
},
214216
],
215217
});

src/bot/commands/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import Bot from "./bot.js";
22
import Chat from "./chat.js";
3+
import describe from "./describe.js";
34
import grant from "./grant.js";
45
import Imagine from "./imagine.js";
56
import Premium from "./premium.js";
67
import Reset from "./reset.js";
78
import Settings from "./settings.js";
89

9-
export const commands = [Bot, Chat, Imagine, Premium, Settings, Reset, grant];
10+
export const commands = [Bot, Chat, Imagine, Premium, Settings, describe, Reset, grant];

src/bot/models/index.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import EventEmitter from "node:events";
22
import { Api } from "../api.js";
3-
import { DALLE3, GPT16K, GPT3_5, GPT4 } from "./openai.js";
43
import { Claude, Claude_instant } from "./text/anthropic.js";
54
import openchat from "./text/openchat.js";
6-
import { albedobase, fustercluck, icbinp, sdxl, turbo } from "./stablehorde.js";
7-
import kandinsky from "./kandinsky.js";
5+
import { albedobase, cascade, fustercluck, icbinp, sdxl, turbo } from "./stablehorde.js";
86
import { Zephyr } from "./text/pawan.js";
97
import google from "./text/google.js";
8+
import groq from "./text/groq.js";
109

1110
type Prettify<T> = {
1211
[K in keyof T]: T[K];
@@ -87,9 +86,11 @@ export type PawanChatModel = Prettify<
8786
>;
8887

8988
export const CHAT_MODELS: (GPTModel | AnthropicModel | OpenChatModel)[] = [
90-
/*GPT4, GPT3_5, GPT16K, */ Claude,
91-
Claude_instant,
89+
/*GPT4, GPT3_5, GPT16K, */
90+
groq,
9291
openchat,
92+
Claude,
93+
Claude_instant,
9394
Zephyr,
9495
google,
9596
];
@@ -237,8 +238,8 @@ export type ImageVisionModel = Prettify<
237238
run: (
238239
api: Api,
239240
data: {
240-
model: ("blip2" | "ocr")[];
241241
image: string;
242+
typeImage: "anything" | "person";
242243
},
243244
) => EventEmitter | NonNullable<unknown>;
244245
}

src/bot/models/kandinsky.ts

-15
This file was deleted.

src/bot/models/stablehorde.ts

+20-2
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,23 @@ const fustercluck: GenericModel<GenericParam> = {
9696
});
9797
},
9898
};
99-
100-
export { sdxl, albedobase, icbinp, turbo, fustercluck };
99+
const cascade: GenericModel<GenericParam> = {
100+
id: "stable_cascade",
101+
name: "Stable Cascade",
102+
from: {
103+
width: 1024,
104+
height: 1024,
105+
},
106+
to: {
107+
width: 1024,
108+
height: 1024,
109+
},
110+
run(api, data) {
111+
return api.image.sh({
112+
...data,
113+
model: "stable_cascade",
114+
prompt: `${data.prompt}`,
115+
});
116+
},
117+
};
118+
export { sdxl, albedobase, icbinp, turbo, fustercluck, cascade };

src/bot/models/text/groq.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { OpenChatModel } from "../index.js";
2+
3+
export default {
4+
id: "mixtral-8x7b-32768",
5+
name: "Mixtral",
6+
description: "Large Language Model created by Mistral and inferenced by Groq.",
7+
emoji: { name: "mistral", id: "1213495168179642480" },
8+
maxTokens: 4096,
9+
run: async (api, data) => {
10+
return await api.text.groq({
11+
...data,
12+
model: "mixtral-8x7b-32768",
13+
});
14+
},
15+
} as OpenChatModel;

src/bot/models/vision.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { ImageVisionModel } from "./index.js";
22

33
export default {
4+
id: "vision",
45
name: "Image Vision",
5-
run: (api, data) => api.image.vision(data),
6+
premium: false,
7+
run: (api, data) =>
8+
api.image.vision({
9+
...data,
10+
model: ["gemini"],
11+
}),
612
} satisfies ImageVisionModel;

src/bot/utils/premium.ts

+18-13
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,19 @@ export async function generatePremiumEmbed(premiumInfo: {
7070
for (const expense of user.plan.expenses) {
7171
if (expensesFields.length >= 10) break;
7272
expensesFields.push({
73-
name: `${expense.type.slice(0, 1).toUpperCase()}${expense.type.slice(1)} - using \`${expense.data.model}\` - $${expense.used?.toFixed(5) ?? "0"
74-
}`,
73+
name: `${expense.type.slice(0, 1).toUpperCase()}${expense.type.slice(1)} - using \`${expense.data.model}\` - $${
74+
expense.used?.toFixed(5) ?? "0"
75+
}`,
7576
value: `<t:${Math.floor(expense.time / 1000)}:R>`,
7677
});
7778
}
7879
} else if (premiumInfo.premiumSelection.location === "guild" && guild?.plan) {
7980
for (const expense of guild.plan.expenses) {
8081
if (expensesFields.length >= 10) break;
8182
expensesFields.push({
82-
name: `${expense.type.slice(0, 1).toUpperCase()}${expense.type.slice(1)} - using \`${expense.data.model}\` - $${expense.used?.toFixed(5) ?? "0"
83-
}`,
83+
name: `${expense.type.slice(0, 1).toUpperCase()}${expense.type.slice(1)} - using \`${expense.data.model}\` - $${
84+
expense.used?.toFixed(5) ?? "0"
85+
}`,
8486
value: `<t:${Math.floor(expense.time / 1000)}>`,
8587
});
8688
}
@@ -98,8 +100,9 @@ export async function generatePremiumEmbed(premiumInfo: {
98100
for (const charge of user.plan.history) {
99101
if (chargesFields.length >= 10) break;
100102
chargesFields.push({
101-
name: `${charge.type.slice(0, 1).toUpperCase()}${charge.type.slice(1)} ${charge.gateway ? `- using \`${charge.gateway}\`` : ""
102-
}`,
103+
name: `${charge.type.slice(0, 1).toUpperCase()}${charge.type.slice(1)} ${
104+
charge.gateway ? `- using \`${charge.gateway}\`` : ""
105+
}`,
103106
value: `$${charge.amount?.toFixed(2) ?? "0"} - <t:${Math.floor(charge.time / 1000)}>`,
104107
});
105108
}
@@ -108,8 +111,9 @@ export async function generatePremiumEmbed(premiumInfo: {
108111
for (const charge of guild.plan.history) {
109112
if (chargesFields.length >= 10) break;
110113
chargesFields.push({
111-
name: `${charge.type.slice(0, 1).toUpperCase()}${charge.type.slice(1)} ${charge.gateway ? `- using \`${charge.gateway}\`` : ""
112-
}`,
114+
name: `${charge.type.slice(0, 1).toUpperCase()}${charge.type.slice(1)} ${
115+
charge.gateway ? `- using \`${charge.gateway}\`` : ""
116+
}`,
113117
value: `$${charge.amount?.toFixed(2)} - <t:${Math.floor(charge.time / 1000)}>`,
114118
});
115119
}
@@ -126,11 +130,13 @@ export async function generatePremiumEmbed(premiumInfo: {
126130
// LAST EMBED
127131
let description = "";
128132
if (premiumInfo.premiumSelection.location === "user" && user.plan) {
129-
description = `**$${user.plan?.used?.toFixed(2)}**\`${generateProgressBar(user.plan.total, user.plan.used)}\`**$${user.plan?.total
130-
}**`;
133+
description = `**$${user.plan?.used?.toFixed(2)}**\`${generateProgressBar(user.plan.total, user.plan.used)}\`**$${
134+
user.plan?.total
135+
}**`;
131136
} else if (premiumInfo.premiumSelection.location === "guild" && guild?.plan) {
132-
description = `**$${guild.plan?.used?.toFixed(2)}**\`${generateProgressBar(guild.plan.total, guild.plan.used)}\`**$${guild.plan?.total
133-
}**`;
137+
description = `**$${guild.plan?.used?.toFixed(2)}**\`${generateProgressBar(guild.plan.total, guild.plan.used)}\`**$${
138+
guild.plan?.total
139+
}**`;
134140
}
135141
embeds.push({
136142
title: "Your pay-as-you-go plan 📊",
@@ -276,7 +282,6 @@ export async function chargePlan(cost: number, environment: Environment, type: "
276282
return false;
277283
}
278284
// if is not expired do nothing
279-
280285
} else if (prem.location === "guild") {
281286
if (!environment.guild?.subscription) return false;
282287
const subscription = environment.guild.subscription;

src/bot/utils/settings.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export function getDefaultValues(settingId: string) {
159159
case "general:loadingIndicator":
160160
return 3; // default loading indicator
161161
case "chat:model":
162-
return "gemini";
162+
return "mixtral-8x7b-32768";
163163
case "chat:tone":
164164
return "neutral";
165165
case "chat:partialMessages":

0 commit comments

Comments
 (0)