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

Commit

Permalink
Update dependencies and models
Browse files Browse the repository at this point in the history
  • Loading branch information
MrlolDev committed Mar 2, 2024
1 parent 4a2a25f commit 075449f
Show file tree
Hide file tree
Showing 13 changed files with 115 additions and 60 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@
"rabbitmq-client": "^4.3.0",
"redis": "^4.6.8",
"sharp": "^0.33.0",
"turing.sh": "^0.0.9"
"turing.sh": "^0.1.1"
}
}
6 changes: 1 addition & 5 deletions src/bot/commands/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,14 @@ async function buildInfo(bot: Bot, guildId?: BigString): Promise<CreateMessageOp
bot.shards.forEach((shard) => workers.add(shard.workerId));
}

const stats = {
guilds: 291000,
};

return {
embeds: [
{
title: "Bot Statistics",
fields: [
{
name: "Servers 🖥️",
value: "312.000",
value: "334.000",
inline: true,
},
{
Expand Down
36 changes: 31 additions & 5 deletions src/bot/commands/describe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { LOADING_INDICATORS } from "../../types/models/users.js";
import { mergeImages } from "../utils/image-merge.js";
import { getDefaultValues, getSettingsValue } from "../utils/settings.js";
import { chargePlan, requiredPremium } from "../utils/premium.js";
import vision from "../models/vision.js";
import axios from "axios";

export default createCommand({
body: {
Expand All @@ -20,16 +22,40 @@ export default createCommand({
description: "The image to use",
required: true,
},
{
type: "String",
name: "typeImage",
description: "The type of image you want to describe",
choices: [
["Person", "person"],
["Anything", "anything"],
],
},
],
},
cooldown: {
user: 1.5 * 60 * 1000,
voter: 1.25 * 60 * 1000,
subscription: 1 * 60 * 1000,
user: 2 * 60 * 1000,
voter: 1.5 * 60 * 1000,
subscription: 1.25 * 60 * 1000,
},
interaction: async ({ interaction, options, env, premium }) => {
await interaction.edit({
content: "This command is currently disabled.",
let typeImage = options.getString("typeImage") as "person" | "anything";
if (!typeImage) typeImage = "anything";
const image = options.getAttachment("image");
const base64 = await imageUrlToBase64(image.url);

const response = await vision.run(interaction.bot.api, {
image: base64,
typeImage,
});
await interaction.edit({
content: response.description,
} as CreateMessageOptions);
},
});

async function imageUrlToBase64(url: string) {
const res = await axios.get(url, { responseType: "arraybuffer" });
const buffer = Buffer.from(res.data, "binary").toString("base64");
return buffer;
}
14 changes: 8 additions & 6 deletions src/bot/commands/imagine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ export default createCommand({
components: [
{
type: MessageComponentTypes.Button,
label: 'Change model Here',
label: "Change model Here",
customId: "settings_open_image",
disabled: false,
emoji: {
// warning symbol
name: '⚠️',
name: "⚠️",
},
style: ButtonStyles.Secondary,
},
Expand Down Expand Up @@ -197,8 +197,9 @@ export default createCommand({
embeds: [
{
color: config.brand.color,
title: `Waiting in queue <${loadingIndicator.emoji.animated ? "a" : ""}:${loadingIndicator.emoji.name}:${loadingIndicator.emoji.id
}>`,
title: `Waiting in queue <${loadingIndicator.emoji.animated ? "a" : ""}:${loadingIndicator.emoji.name}:${
loadingIndicator.emoji.id
}>`,
},
],
});
Expand All @@ -208,8 +209,9 @@ export default createCommand({
embeds: [
{
color: config.brand.color,
title: `Generating <${loadingIndicator.emoji.animated ? "a" : ""}:${loadingIndicator.emoji.name}:${loadingIndicator.emoji.id
}>`,
title: `Generating <${loadingIndicator.emoji.animated ? "a" : ""}:${loadingIndicator.emoji.name}:${
loadingIndicator.emoji.id
}>`,
},
],
});
Expand Down
3 changes: 2 additions & 1 deletion src/bot/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import Bot from "./bot.js";
import Chat from "./chat.js";
import describe from "./describe.js";
import grant from "./grant.js";
import Imagine from "./imagine.js";
import Premium from "./premium.js";
import Reset from "./reset.js";
import Settings from "./settings.js";

export const commands = [Bot, Chat, Imagine, Premium, Settings, Reset, grant];
export const commands = [Bot, Chat, Imagine, Premium, Settings, describe, Reset, grant];
13 changes: 7 additions & 6 deletions src/bot/models/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import EventEmitter from "node:events";
import { Api } from "../api.js";
import { DALLE3, GPT16K, GPT3_5, GPT4 } from "./openai.js";
import { Claude, Claude_instant } from "./text/anthropic.js";
import openchat from "./text/openchat.js";
import { albedobase, fustercluck, icbinp, sdxl, turbo } from "./stablehorde.js";
import kandinsky from "./kandinsky.js";
import { albedobase, cascade, fustercluck, icbinp, sdxl, turbo } from "./stablehorde.js";
import { Zephyr } from "./text/pawan.js";
import google from "./text/google.js";
import groq from "./text/groq.js";

type Prettify<T> = {
[K in keyof T]: T[K];
Expand Down Expand Up @@ -87,9 +86,11 @@ export type PawanChatModel = Prettify<
>;

export const CHAT_MODELS: (GPTModel | AnthropicModel | OpenChatModel)[] = [
/*GPT4, GPT3_5, GPT16K, */ Claude,
Claude_instant,
/*GPT4, GPT3_5, GPT16K, */
groq,
openchat,
Claude,
Claude_instant,
Zephyr,
google,
];
Expand Down Expand Up @@ -237,8 +238,8 @@ export type ImageVisionModel = Prettify<
run: (
api: Api,
data: {
model: ("blip2" | "ocr")[];
image: string;
typeImage: "anything" | "person";
},
) => EventEmitter | NonNullable<unknown>;
}
Expand Down
15 changes: 0 additions & 15 deletions src/bot/models/kandinsky.ts

This file was deleted.

22 changes: 20 additions & 2 deletions src/bot/models/stablehorde.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,23 @@ const fustercluck: GenericModel<GenericParam> = {
});
},
};

export { sdxl, albedobase, icbinp, turbo, fustercluck };
const cascade: GenericModel<GenericParam> = {
id: "stable_cascade",
name: "Stable Cascade",
from: {
width: 1024,
height: 1024,
},
to: {
width: 1024,
height: 1024,
},
run(api, data) {
return api.image.sh({
...data,
model: "stable_cascade",
prompt: `${data.prompt}`,
});
},
};
export { sdxl, albedobase, icbinp, turbo, fustercluck, cascade };
15 changes: 15 additions & 0 deletions src/bot/models/text/groq.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { OpenChatModel } from "../index.js";

export default {
id: "mixtral-8x7b-32768",
name: "Mixtral",
description: "Large Language Model created by Mistral and inferenced by Groq.",
emoji: { name: "mistral", id: "1213495168179642480" },
maxTokens: 4096,
run: async (api, data) => {
return await api.text.groq({
...data,
model: "mixtral-8x7b-32768",
});
},
} as OpenChatModel;
8 changes: 7 additions & 1 deletion src/bot/models/vision.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { ImageVisionModel } from "./index.js";

export default {
id: "vision",
name: "Image Vision",
run: (api, data) => api.image.vision(data),
premium: false,
run: (api, data) =>
api.image.vision({
...data,
model: ["gemini"],
}),
} satisfies ImageVisionModel;
31 changes: 18 additions & 13 deletions src/bot/utils/premium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,19 @@ export async function generatePremiumEmbed(premiumInfo: {
for (const expense of user.plan.expenses) {
if (expensesFields.length >= 10) break;
expensesFields.push({
name: `${expense.type.slice(0, 1).toUpperCase()}${expense.type.slice(1)} - using \`${expense.data.model}\` - $${expense.used?.toFixed(5) ?? "0"
}`,
name: `${expense.type.slice(0, 1).toUpperCase()}${expense.type.slice(1)} - using \`${expense.data.model}\` - $${
expense.used?.toFixed(5) ?? "0"
}`,
value: `<t:${Math.floor(expense.time / 1000)}:R>`,
});
}
} else if (premiumInfo.premiumSelection.location === "guild" && guild?.plan) {
for (const expense of guild.plan.expenses) {
if (expensesFields.length >= 10) break;
expensesFields.push({
name: `${expense.type.slice(0, 1).toUpperCase()}${expense.type.slice(1)} - using \`${expense.data.model}\` - $${expense.used?.toFixed(5) ?? "0"
}`,
name: `${expense.type.slice(0, 1).toUpperCase()}${expense.type.slice(1)} - using \`${expense.data.model}\` - $${
expense.used?.toFixed(5) ?? "0"
}`,
value: `<t:${Math.floor(expense.time / 1000)}>`,
});
}
Expand All @@ -98,8 +100,9 @@ export async function generatePremiumEmbed(premiumInfo: {
for (const charge of user.plan.history) {
if (chargesFields.length >= 10) break;
chargesFields.push({
name: `${charge.type.slice(0, 1).toUpperCase()}${charge.type.slice(1)} ${charge.gateway ? `- using \`${charge.gateway}\`` : ""
}`,
name: `${charge.type.slice(0, 1).toUpperCase()}${charge.type.slice(1)} ${
charge.gateway ? `- using \`${charge.gateway}\`` : ""
}`,
value: `$${charge.amount?.toFixed(2) ?? "0"} - <t:${Math.floor(charge.time / 1000)}>`,
});
}
Expand All @@ -108,8 +111,9 @@ export async function generatePremiumEmbed(premiumInfo: {
for (const charge of guild.plan.history) {
if (chargesFields.length >= 10) break;
chargesFields.push({
name: `${charge.type.slice(0, 1).toUpperCase()}${charge.type.slice(1)} ${charge.gateway ? `- using \`${charge.gateway}\`` : ""
}`,
name: `${charge.type.slice(0, 1).toUpperCase()}${charge.type.slice(1)} ${
charge.gateway ? `- using \`${charge.gateway}\`` : ""
}`,
value: `$${charge.amount?.toFixed(2)} - <t:${Math.floor(charge.time / 1000)}>`,
});
}
Expand All @@ -126,11 +130,13 @@ export async function generatePremiumEmbed(premiumInfo: {
// LAST EMBED
let description = "";
if (premiumInfo.premiumSelection.location === "user" && user.plan) {
description = `**$${user.plan?.used?.toFixed(2)}**\`${generateProgressBar(user.plan.total, user.plan.used)}\`**$${user.plan?.total
}**`;
description = `**$${user.plan?.used?.toFixed(2)}**\`${generateProgressBar(user.plan.total, user.plan.used)}\`**$${
user.plan?.total
}**`;
} else if (premiumInfo.premiumSelection.location === "guild" && guild?.plan) {
description = `**$${guild.plan?.used?.toFixed(2)}**\`${generateProgressBar(guild.plan.total, guild.plan.used)}\`**$${guild.plan?.total
}**`;
description = `**$${guild.plan?.used?.toFixed(2)}**\`${generateProgressBar(guild.plan.total, guild.plan.used)}\`**$${
guild.plan?.total
}**`;
}
embeds.push({
title: "Your pay-as-you-go plan 📊",
Expand Down Expand Up @@ -276,7 +282,6 @@ export async function chargePlan(cost: number, environment: Environment, type: "
return false;
}
// if is not expired do nothing

} else if (prem.location === "guild") {
if (!environment.guild?.subscription) return false;
const subscription = environment.guild.subscription;
Expand Down
2 changes: 1 addition & 1 deletion src/bot/utils/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export function getDefaultValues(settingId: string) {
case "general:loadingIndicator":
return 3; // default loading indicator
case "chat:model":
return "gemini";
return "mixtral-8x7b-32768";
case "chat:tone":
return "neutral";
case "chat:partialMessages":
Expand Down

0 comments on commit 075449f

Please sign in to comment.