Skip to content

Commit

Permalink
fixed inconsistent hf token naming bug
Browse files Browse the repository at this point in the history
  • Loading branch information
aandyw committed Aug 14, 2024
1 parent 8ca65e6 commit 5fbf322
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 84 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
DISCORD_TOKEN: ${DISCORD_TOKEN}
PUBLIC_KEY: ${PUBLIC_KEY}
HF_TOKEN: ${HF_TOKEN}
HUGGINGFACE_ENDPOINT: ${HUGGINGFACE_ENDPOINT}
HF_ENDPOINT: ${HF_ENDPOINT}
env_file:
- .env

Expand Down
2 changes: 1 addition & 1 deletion fly.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# fly.toml app configuration file generated for discorddiffusion on 2024-08-14T17:52:28-04:00
# fly.toml app configuration file generated for discorddiffusion on 2024-08-14T18:30:35-04:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#
Expand Down
162 changes: 80 additions & 82 deletions src/commands/utility/sticker.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,92 +59,90 @@ module.exports = {
await interaction.deferReply({ ephemeral: true });

try {
while (true) {
await query({
inputs: interaction.options.getString("prompt"),
num_images: 4,
rows: 2,
cols: 2,
}).then((response) => {
const { images, preview } = response;
await query({
inputs: interaction.options.getString("prompt"),
num_images: 4,
rows: 2,
cols: 2,
}).then((response) => {
const { images, preview } = response;

previewImage = preview;
topLeftImage = images[0];
topRightImage = images[1];
bottomLeftImage = images[2];
bottomRightImage = images[3];
});
previewImage = preview;
topLeftImage = images[0];
topRightImage = images[1];
bottomLeftImage = images[2];
bottomRightImage = images[3];
});

const previewImagePath = await saveBase64Image(previewImage);
const reply = await interaction.editReply({
files: [new AttachmentBuilder(previewImagePath)],
components: [row],
ephemeral: true,
});
const previewImagePath = await saveBase64Image(previewImage);
const reply = await interaction.editReply({
files: [new AttachmentBuilder(previewImagePath)],
components: [row],
ephemeral: true,
});

const collector = reply.createMessageComponentCollector({
ComponentType: ComponentType.Button,
});
const collector = reply.createMessageComponentCollector({
ComponentType: ComponentType.Button,
});

collector.on("collect", async (interaction) => {
if (interaction.customId === "top_left") {
const topLeftPath = await saveBase64Image(topLeftImage);
interaction.reply({
files: [new AttachmentBuilder(topLeftPath)],
});
return;
}
if (interaction.customId === "top_right") {
const topRightPath = await saveBase64Image(topRightImage);
interaction.reply({
files: [new AttachmentBuilder(topRightPath)],
});
return;
}
if (interaction.customId === "bottom_left") {
const bottomLeftPath = await saveBase64Image(bottomLeftImage);
interaction.reply({
files: [new AttachmentBuilder(bottomLeftPath)],
});
return;
}
if (interaction.customId === "bottom_right") {
const bottomRightPath = await saveBase64Image(bottomRightImage);
interaction.reply({
files: [new AttachmentBuilder(bottomRightPath)],
});
return;
}
if (interaction.customId === "regenerate") {
// do nothing since we are in a while loop that will only terminate
// when the user makes a selection
//
// interaction.deferReply({ ephemeral: true });
// await query({
// inputs: interaction.options.getString("prompt"),
// num_images: 4,
// rows: 2,
// cols: 2,
// }).then((response) => {
// const { images, preview } = response;
// previewImage = preview;
// topLeftImage = images[0];
// topRightImage = images[1];
// bottomLeftImage = images[2];
// bottomRightImage = images[3];
// });
// const previewImagePath = await saveBase64Image(previewImage);
// const reply = await interaction.editReply({
// files: [new AttachmentBuilder(previewImagePath)],
// components: [row],
// ephemeral: true,
// });
// const collector = reply.createMessageComponentCollector({
// ComponentType: ComponentType.Button,
// });
}
});
}
collector.on("collect", async (interaction) => {
if (interaction.customId === "top_left") {
const topLeftPath = await saveBase64Image(topLeftImage);
interaction.reply({
files: [new AttachmentBuilder(topLeftPath)],
});
return;
}
if (interaction.customId === "top_right") {
const topRightPath = await saveBase64Image(topRightImage);
interaction.reply({
files: [new AttachmentBuilder(topRightPath)],
});
return;
}
if (interaction.customId === "bottom_left") {
const bottomLeftPath = await saveBase64Image(bottomLeftImage);
interaction.reply({
files: [new AttachmentBuilder(bottomLeftPath)],
});
return;
}
if (interaction.customId === "bottom_right") {
const bottomRightPath = await saveBase64Image(bottomRightImage);
interaction.reply({
files: [new AttachmentBuilder(bottomRightPath)],
});
return;
}
if (interaction.customId === "regenerate") {
// TODO:
// interaction.deferReply({ ephemeral: true });
// await query({
// inputs: interaction.options.getString("prompt"),
// num_images: 4,
// rows: 2,
// cols: 2,
// }).then((response) => {
// const { images, preview } = response;
// previewImage = preview;
// topLeftImage = images[0];
// topRightImage = images[1];
// bottomLeftImage = images[2];
// bottomRightImage = images[3];
// });
// const previewImagePath = await saveBase64Image(previewImage);
// const reply = await interaction.editReply({
// files: [new AttachmentBuilder(previewImagePath)],
// components: [row],
// ephemeral: true,
// });
// const collector = reply.createMessageComponentCollector({
// ComponentType: ComponentType.Button,
// });

return;
}
});
} catch (error) {
await interaction.editReply("/(✖ ᗝ ✖)/ sorry something went wrong");
console.error(`Failed to generate stickers: ${error}`);
Expand Down

0 comments on commit 5fbf322

Please sign in to comment.