Skip to content

Commit

Permalink
add types for flux text to image model
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonpraful committed Nov 26, 2024
1 parent cd2f9da commit 04916ca
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions types/defines/ai.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,16 @@ export type AiTextToImageInput = {
strength?: number;
guidance?: number;
};
export type AiTextToImageOutput = ReadableStream<Uint8Array>;
export declare abstract class BaseAiTextToImage {
export type AiTextToImageOutput<Model extends BaseAiTextToImageModels> =
Model extends "@cf/black-forest-labs/flux-1-schnell"
? { image: string }
: ReadableStream<Uint8Array>;

export declare abstract class BaseAiTextToImage<
Model extends BaseAiTextToImageModels,
> {
inputs: AiTextToImageInput;
postProcessedOutputs: AiTextToImageOutput;
postProcessedOutputs: AiTextToImageOutput<Model>;
}
export type AiTranslationInput = {
text: string;
Expand Down Expand Up @@ -193,7 +199,8 @@ export type BaseAiTextToImageModels =
| "@cf/runwayml/stable-diffusion-v1-5-inpainting"
| "@cf/runwayml/stable-diffusion-v1-5-img2img"
| "@cf/lykon/dreamshaper-8-lcm"
| "@cf/bytedance/stable-diffusion-xl-lightning";
| "@cf/bytedance/stable-diffusion-xl-lightning"
| "@cf/black-forest-labs/flux-1-schnell";
export type BaseAiTextEmbeddingsModels =
| "@cf/baai/bge-small-en-v1.5"
| "@cf/baai/bge-base-en-v1.5"
Expand Down Expand Up @@ -252,11 +259,11 @@ export declare abstract class Ai {
inputs: BaseAiTextClassification["inputs"],
options?: AiOptions
): Promise<BaseAiTextClassification["postProcessedOutputs"]>;
run(
model: BaseAiTextToImageModels,
inputs: BaseAiTextToImage["inputs"],
run<Model extends BaseAiTextToImageModels>(
model: Model,
inputs: BaseAiTextToImage<Model>["inputs"],
options?: AiOptions
): Promise<BaseAiTextToImage["postProcessedOutputs"]>;
): Promise<BaseAiTextToImage<Model>["postProcessedOutputs"]>;
run(
model: BaseAiTextEmbeddingsModels,
inputs: BaseAiTextEmbeddings["inputs"],
Expand Down

0 comments on commit 04916ca

Please sign in to comment.