Skip to content

Commit

Permalink
added support for creating black forest lab images and hugging faces …
Browse files Browse the repository at this point in the history
…images
  • Loading branch information
kevinreber committed Dec 1, 2024
1 parent 862f0f1 commit 1de4b49
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
33 changes: 27 additions & 6 deletions app/server/createNewImages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {
createNewStableDiffusionImages,
createNewDallEImages,
deleteSet,
createHuggingFaceImages,
createBlackForestImages,
} from "~/server";
import { invariantResponse } from "~/utils/invariantResponse";

Expand All @@ -19,12 +21,21 @@ const DEFAULT_PAYLOAD = {
private: DEFAULT_IS_IMAGE_PRIVATE,
};

type FormDataPayload = {
prompt: string;
model: string;
stylePreset?: string;
numberOfImages: number;
// private?: boolean;
const VALID_HUGGING_FACE_MODELS = [
"Lykon/NeverEnding-Dream",
"black-forest-labs/FLUX.1-dev",
"black-forest-labs/FLUX.1-schnell",
"RunDiffusion/Juggernaut-XL-v9",
];

const VALID_BLACK_FOREST_LABS_MODELS = ["flux-pro-1.1", "flux-pro", "flux-dev"];

const isValidHuggingFaceModel = (model: string) => {
return VALID_HUGGING_FACE_MODELS.includes(model);
};

const isValidBlackForestLabsModel = (model: string) => {
return VALID_BLACK_FOREST_LABS_MODELS.includes(model);
};

/**
Expand Down Expand Up @@ -55,6 +66,16 @@ export const createNewImages = async (

setId = data.setId || "";

return data;
} else if (isValidBlackForestLabsModel(AILanguageModelToUse)) {
const data = await createBlackForestImages(formData, userId);

setId = data.setId || "";
return data;
} else if (isValidHuggingFaceModel(AILanguageModelToUse)) {
const data = await createHuggingFaceImages(formData, userId);

setId = data.setId || "";
return data;
}

Expand Down
2 changes: 2 additions & 0 deletions app/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ export * from "./createComment";
export * from "./deleteComment";
export * from "./commentLikes";
export * from "./getUserCollections";
export * from "./createHuggingFaceImages";
export * from "./createBlackForestImages";

0 comments on commit 1de4b49

Please sign in to comment.