Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add types for flux text to image model #3163

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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