Skip to content

Commit

Permalink
really bad patch for flux returning different than everything else fo…
Browse files Browse the repository at this point in the history
…r no reason
  • Loading branch information
artifishvr committed Nov 14, 2024
1 parent 90bc953 commit 5e05543
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
4 changes: 0 additions & 4 deletions src/commands/imagine.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ export default {
.setName("model")
.setDescription("Enter a description of what you're generating.")
.setChoices([
{
name: "black-forest-labs/flux-1-schnell",
value: "@cf/black-forest-labs/flux-1-schnell",
},
{
name: "lykon/dreamshaper-8-lcm",
value: "@cf/lykon/dreamshaper-8-lcm",
Expand Down
17 changes: 15 additions & 2 deletions src/util/models/interactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,22 @@ export class InteractionResponse {

if (callToModel === null) return null;

const buffer = Buffer.from(callToModel);
try {
// Try to parse as JSON first
const textDecoder = new TextDecoder();
const text = textDecoder.decode(callToModel);
const jsonResponse = JSON.parse(text);

// If we have JSON with base64 image
if (jsonResponse?.result?.image) {
return Buffer.from(jsonResponse.result.image, "base64");
}
} catch (e) {
// Not JSON, treat as binary image data
}

return buffer;
// Return original buffer if not JSON or JSON parsing failed
return Buffer.from(callToModel);
}

async formatUserMessage() {
Expand Down

0 comments on commit 5e05543

Please sign in to comment.