@opencode/ai 0.0.0-dev-177 → 0.0.0-dev-189
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -58
- package/dist/image-client.d.ts +45 -0
- package/dist/index.d.ts +36 -19
- package/dist/index.js +13 -2
- package/dist/media-client.d.ts +1 -0
- package/dist/media-client.js +1 -0
- package/dist/provider-error.js +0 -2
- package/dist/providers/digitalocean/responses.d.ts +4 -0
- package/dist/providers/digitalocean/responses.js +1 -0
- package/dist/providers/digitalocean.d.ts +206 -4
- package/dist/providers/digitalocean.js +17 -6
- package/dist/providers/index.d.ts +0 -4
- package/dist/providers/index.js +0 -4
- package/dist/providers/openrouter/responses.d.ts +4 -0
- package/dist/providers/openrouter/responses.js +1 -0
- package/dist/providers/openrouter.d.ts +207 -5
- package/dist/providers/openrouter.js +20 -11
- package/dist/providers/venice/responses.d.ts +4 -0
- package/dist/providers/venice/responses.js +1 -0
- package/dist/providers/venice.d.ts +206 -4
- package/dist/providers/venice.js +33 -17
- package/dist/route/auth.d.ts +1 -1
- package/dist/route/media-protocol.d.ts +2 -4
- package/dist/route/media.d.ts +1 -1
- package/dist/route/media.js +2 -4
- package/dist/speech-client.d.ts +48 -0
- package/dist/testing/decision.d.ts +16 -0
- package/dist/testing/decision.js +20 -0
- package/dist/testing/image.d.ts +14 -0
- package/dist/testing/image.js +12 -0
- package/dist/testing/media.d.ts +18 -0
- package/dist/testing/media.js +36 -0
- package/dist/testing/script.d.ts +28 -0
- package/dist/testing/script.js +60 -0
- package/dist/testing/speech.d.ts +14 -0
- package/dist/testing/speech.js +12 -0
- package/dist/testing/transcription.d.ts +14 -0
- package/dist/testing/transcription.js +12 -0
- package/dist/testing/video.d.ts +14 -0
- package/dist/testing/video.js +12 -0
- package/dist/testing.d.ts +10 -21
- package/dist/testing.js +11 -54
- package/dist/transcription-client.d.ts +64 -0
- package/dist/video-client.d.ts +41 -0
- package/package.json +14 -18
- package/dist/protocols/bfl-images.d.ts +0 -47
- package/dist/protocols/bfl-images.js +0 -155
- package/dist/protocols/fal-images.d.ts +0 -36
- package/dist/protocols/fal-images.js +0 -96
- package/dist/protocols/fal-video.d.ts +0 -29
- package/dist/protocols/fal-video.js +0 -73
- package/dist/protocols/replicate-images.d.ts +0 -28
- package/dist/protocols/replicate-images.js +0 -127
- package/dist/protocols/stability-images.d.ts +0 -44
- package/dist/protocols/stability-images.js +0 -131
- package/dist/protocols/utils/fal-queue.d.ts +0 -26
- package/dist/protocols/utils/fal-queue.js +0 -67
- package/dist/providers/black-forest-labs.d.ts +0 -21
- package/dist/providers/black-forest-labs.js +0 -23
- package/dist/providers/fal.d.ts +0 -24
- package/dist/providers/fal.js +0 -26
- package/dist/providers/replicate.d.ts +0 -21
- package/dist/providers/replicate.js +0 -17
- package/dist/providers/stability.d.ts +0 -23
- package/dist/providers/stability.js +0 -18
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { Effect, Schema } from "effect";
|
|
2
|
-
import { ImageModel, ImageResponse } from "../image.js";
|
|
3
|
-
import { MediaProtocol } from "../route/media-protocol.js";
|
|
4
|
-
import { MediaRoute } from "../route/media.js";
|
|
5
|
-
import { mergeJsonRecords } from "../schema/index.js";
|
|
6
|
-
import { ProviderShared } from "./shared.js";
|
|
7
|
-
import { MediaInput } from "./utils/media-input.js";
|
|
8
|
-
const route = MediaProtocol.identity({ id: "stability-images", name: "Stability AI", provider: "stability" });
|
|
9
|
-
const upscaleRoute = MediaProtocol.identity({ id: "stability-upscale", name: "Stability AI", provider: "stability" });
|
|
10
|
-
export const DEFAULT_BASE_URL = "https://api.stability.ai";
|
|
11
|
-
const RESULTS_PATH = "/v2beta/results";
|
|
12
|
-
const UPSCALE_MODEL = "creative";
|
|
13
|
-
/** Base64 JSON instead of raw bytes, so the seed and finish reason arrive with the image. */
|
|
14
|
-
const HEADERS = { accept: "application/json" };
|
|
15
|
-
// ---------------------------------------------------------------------------
|
|
16
|
-
// 2. Token and response schemas
|
|
17
|
-
// ---------------------------------------------------------------------------
|
|
18
|
-
export const Token = Schema.Struct({ id: Schema.String });
|
|
19
|
-
// Generate names the base64 image `image`; `/v2beta/results/{id}` names it `result`.
|
|
20
|
-
const ImageDocument = Schema.Struct({
|
|
21
|
-
image: Schema.optional(Schema.String),
|
|
22
|
-
result: Schema.optional(Schema.String),
|
|
23
|
-
seed: Schema.optional(Schema.Number),
|
|
24
|
-
finish_reason: Schema.optional(Schema.String),
|
|
25
|
-
});
|
|
26
|
-
const Started = Schema.Struct({ id: Schema.String });
|
|
27
|
-
// ---------------------------------------------------------------------------
|
|
28
|
-
// 5. Request body construction
|
|
29
|
-
// ---------------------------------------------------------------------------
|
|
30
|
-
/** `sd3.5-*` ids share the `sd3` endpoint and select the model with a form field. */
|
|
31
|
-
const endpoint = (model) => (model.startsWith("sd3") ? "sd3" : model);
|
|
32
|
-
const RESERVED_FORM_FIELDS = new Set(["image", "prompt", "mode", "model"]);
|
|
33
|
-
const form = Effect.fnUntraced(function* (identity, fields, native, source) {
|
|
34
|
-
if ((source?.length ?? 0) > 1)
|
|
35
|
-
return yield* identity.unsupported("media.images", `${identity.name} takes one source image`);
|
|
36
|
-
const body = new FormData();
|
|
37
|
-
MediaInput.appendFields(body, fields, { overlay: native, reserved: RESERVED_FORM_FIELDS });
|
|
38
|
-
const image = source?.[0];
|
|
39
|
-
if (image !== undefined)
|
|
40
|
-
body.append("image", MediaInput.blob(yield* MediaInput.inlineBytes(identity.id, image), image.mediaType), "image");
|
|
41
|
-
return MediaProtocol.multipart(body);
|
|
42
|
-
});
|
|
43
|
-
const fromRequest = Effect.fn("StabilityImages.fromRequest")(function* (request) {
|
|
44
|
-
if (request.n !== undefined && request.n > 1)
|
|
45
|
-
return yield* route.unsupported("media.n", `${route.name} generates one image per request; call it once per image`);
|
|
46
|
-
const target = endpoint(request.model.id);
|
|
47
|
-
const edit = (request.images?.length ?? 0) > 0;
|
|
48
|
-
if (edit && target === "core")
|
|
49
|
-
return yield* route.unsupported("media.images", `${route.name} core is text-to-image only; use ultra or sd3.5-*`);
|
|
50
|
-
return yield* form(route, {
|
|
51
|
-
prompt: request.prompt,
|
|
52
|
-
aspect_ratio: request.aspect,
|
|
53
|
-
model: target === "sd3" ? request.model.id : undefined,
|
|
54
|
-
mode: target === "sd3" && edit ? "image-to-image" : undefined,
|
|
55
|
-
}, mergeJsonRecords(request.providerOptions, request.http?.body), request.images);
|
|
56
|
-
});
|
|
57
|
-
const fromUpscaleRequest = Effect.fn("StabilityImages.fromUpscaleRequest")(function* (request) {
|
|
58
|
-
if ((request.images?.length ?? 0) === 0)
|
|
59
|
-
return yield* ProviderShared.invalidRequest(`${upscaleRoute.name} upscale requires the source image in images`);
|
|
60
|
-
return yield* form(upscaleRoute, { prompt: request.prompt }, mergeJsonRecords(request.providerOptions, request.http?.body), request.images);
|
|
61
|
-
});
|
|
62
|
-
// ---------------------------------------------------------------------------
|
|
63
|
-
// 6. Response decoding
|
|
64
|
-
// ---------------------------------------------------------------------------
|
|
65
|
-
const decodeImageDocument = (identity) => {
|
|
66
|
-
const decode = identity.decodeJson(ImageDocument);
|
|
67
|
-
return Effect.fn("StabilityImages.decodeImage")(function* (response) {
|
|
68
|
-
const output = yield* decode(response);
|
|
69
|
-
const document = output.value;
|
|
70
|
-
const data = document.image ?? document.result;
|
|
71
|
-
if (data === undefined)
|
|
72
|
-
return yield* output.invalid(`${identity.name} returned no image`);
|
|
73
|
-
const image = yield* MediaInput.decodedAsset(output.invalid, `${identity.name} result`, data, undefined);
|
|
74
|
-
return new ImageResponse({
|
|
75
|
-
images: [image],
|
|
76
|
-
providerMetadata: { stability: { seed: document.seed, finishReason: document.finish_reason } },
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
const decodeResponse = decodeImageDocument(route);
|
|
81
|
-
const decodeUpscaleImage = decodeImageDocument(upscaleRoute);
|
|
82
|
-
const decodeStart = upscaleRoute.decodeStarted(Started, (value) => ({
|
|
83
|
-
token: { id: value.id },
|
|
84
|
-
snapshot: { id: value.id, status: "queued" },
|
|
85
|
-
}));
|
|
86
|
-
// `/v2beta/results/{id}` answers 202 while in progress and 200 with the finished image document.
|
|
87
|
-
const decodeStatus = (response, context) => Effect.succeed({
|
|
88
|
-
id: context.token.id,
|
|
89
|
-
status: response.status === 202 ? "running" : "completed",
|
|
90
|
-
});
|
|
91
|
-
const decodeUpscaleResult = Effect.fn("StabilityImages.decodeUpscaleResult")(function* (response, context) {
|
|
92
|
-
if (response.status === 202) {
|
|
93
|
-
const output = yield* upscaleRoute.text(response);
|
|
94
|
-
return yield* output.pending(context.token.id);
|
|
95
|
-
}
|
|
96
|
-
return yield* decodeUpscaleImage(response);
|
|
97
|
-
});
|
|
98
|
-
// ---------------------------------------------------------------------------
|
|
99
|
-
// 7. Protocol and route
|
|
100
|
-
// ---------------------------------------------------------------------------
|
|
101
|
-
export const protocol = MediaProtocol.inline(route, {
|
|
102
|
-
unsupported: ["resolution"],
|
|
103
|
-
body: { from: fromRequest },
|
|
104
|
-
response: { decode: decodeResponse },
|
|
105
|
-
});
|
|
106
|
-
export const upscaleProtocol = MediaProtocol.queued(upscaleRoute, {
|
|
107
|
-
token: Token,
|
|
108
|
-
unsupported: ["n", "aspect", "resolution"],
|
|
109
|
-
start: { body: { from: fromUpscaleRequest }, decode: decodeStart },
|
|
110
|
-
status: { path: (token) => `${RESULTS_PATH}/${token.id}`, decode: decodeStatus },
|
|
111
|
-
result: { path: (token) => `${RESULTS_PATH}/${token.id}`, decode: decodeUpscaleResult },
|
|
112
|
-
});
|
|
113
|
-
export const model = (input) => ImageModel.fromRoute({
|
|
114
|
-
protocol,
|
|
115
|
-
baseURL: DEFAULT_BASE_URL,
|
|
116
|
-
headers: HEADERS,
|
|
117
|
-
path: ({ request }) => `/v2beta/stable-image/generate/${endpoint(request.model.id)}`,
|
|
118
|
-
}, input);
|
|
119
|
-
export const upscaleModel = (input) => ImageModel.fromRoute({
|
|
120
|
-
protocol: upscaleProtocol,
|
|
121
|
-
baseURL: DEFAULT_BASE_URL,
|
|
122
|
-
headers: HEADERS,
|
|
123
|
-
// Only the creative upscaler is asynchronous; fast and conservative answer inline.
|
|
124
|
-
path: `/v2beta/stable-image/upscale/${UPSCALE_MODEL}`,
|
|
125
|
-
}, { ...input, id: UPSCALE_MODEL });
|
|
126
|
-
export const StabilityImages = {
|
|
127
|
-
protocol,
|
|
128
|
-
upscaleProtocol,
|
|
129
|
-
model,
|
|
130
|
-
upscaleModel,
|
|
131
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Effect, Schema } from "effect";
|
|
2
|
-
import type { HttpClientResponse } from "effect/http";
|
|
3
|
-
import type { Media } from "../../media.js";
|
|
4
|
-
import { MediaProtocol } from "../../route/media-protocol.js";
|
|
5
|
-
import type { AIError } from "../../schema/index.js";
|
|
6
|
-
export declare const DEFAULT_BASE_URL = "https://queue.fal.run";
|
|
7
|
-
/** fal hands back absolute follow-up URLs on submit; they are authoritative for status, result, and cancel. */
|
|
8
|
-
export declare const Token: Schema.Struct<{
|
|
9
|
-
readonly requestID: Schema.String;
|
|
10
|
-
readonly statusURL: Schema.String;
|
|
11
|
-
readonly responseURL: Schema.String;
|
|
12
|
-
readonly cancelURL: Schema.String;
|
|
13
|
-
}>;
|
|
14
|
-
export type Token = Schema.Schema.Type<typeof Token>;
|
|
15
|
-
export declare const mediaUrl: (asset: Media.Asset, name: string) => Effect.Effect<string, AIError, never>;
|
|
16
|
-
export declare const protocol: <Request, Response>(route: MediaProtocol.Identity, input: {
|
|
17
|
-
readonly unsupported?: ReadonlyArray<keyof Request & string>;
|
|
18
|
-
readonly from: (request: Request) => Effect.Effect<MediaProtocol.Body, AIError>;
|
|
19
|
-
readonly decodeResult: (response: HttpClientResponse.HttpClientResponse, context: MediaProtocol.PollContext<Token>) => Effect.Effect<Response, AIError>;
|
|
20
|
-
}) => MediaProtocol.Queued<Request, Response, {
|
|
21
|
-
readonly requestID: string;
|
|
22
|
-
readonly statusURL: string;
|
|
23
|
-
readonly responseURL: string;
|
|
24
|
-
readonly cancelURL: string;
|
|
25
|
-
}>;
|
|
26
|
-
export * as FalQueue from "./fal-queue.js";
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { Effect, Schema } from "effect";
|
|
2
|
-
import { MediaProtocol } from "../../route/media-protocol.js";
|
|
3
|
-
import { ProviderShared, optionalNull } from "../shared.js";
|
|
4
|
-
export const DEFAULT_BASE_URL = "https://queue.fal.run";
|
|
5
|
-
/** fal hands back absolute follow-up URLs on submit; they are authoritative for status, result, and cancel. */
|
|
6
|
-
export const Token = Schema.Struct({
|
|
7
|
-
requestID: Schema.String,
|
|
8
|
-
statusURL: Schema.String,
|
|
9
|
-
responseURL: Schema.String,
|
|
10
|
-
cancelURL: Schema.String,
|
|
11
|
-
});
|
|
12
|
-
const StartResponse = Schema.Struct({
|
|
13
|
-
request_id: Schema.String,
|
|
14
|
-
status_url: Schema.String,
|
|
15
|
-
response_url: Schema.String,
|
|
16
|
-
cancel_url: Schema.String,
|
|
17
|
-
queue_position: optionalNull(Schema.Number),
|
|
18
|
-
});
|
|
19
|
-
const QueueStatus = Schema.Struct({
|
|
20
|
-
status: Schema.String,
|
|
21
|
-
queue_position: optionalNull(Schema.Number),
|
|
22
|
-
error: optionalNull(Schema.Unknown),
|
|
23
|
-
});
|
|
24
|
-
const STATUS = {
|
|
25
|
-
IN_QUEUE: "queued",
|
|
26
|
-
IN_PROGRESS: "running",
|
|
27
|
-
COMPLETED: "completed",
|
|
28
|
-
};
|
|
29
|
-
// fal accepts public URLs and data URIs; there is no provider file handle to forward.
|
|
30
|
-
export const mediaUrl = (asset, name) => ProviderShared.mediaReference(asset, undefined, name).pipe(Effect.map((reference) => reference.value));
|
|
31
|
-
export const protocol = (route, input) => {
|
|
32
|
-
const decodeQueueStatus = route.decodeJson(QueueStatus);
|
|
33
|
-
return MediaProtocol.queued(route, {
|
|
34
|
-
token: Token,
|
|
35
|
-
unsupported: input.unsupported,
|
|
36
|
-
start: {
|
|
37
|
-
body: { from: input.from },
|
|
38
|
-
decode: route.decodeStarted(StartResponse, (value) => ({
|
|
39
|
-
token: {
|
|
40
|
-
requestID: value.request_id,
|
|
41
|
-
statusURL: value.status_url,
|
|
42
|
-
responseURL: value.response_url,
|
|
43
|
-
cancelURL: value.cancel_url,
|
|
44
|
-
},
|
|
45
|
-
snapshot: { id: value.request_id, status: "queued", position: value.queue_position ?? undefined },
|
|
46
|
-
})),
|
|
47
|
-
},
|
|
48
|
-
status: {
|
|
49
|
-
path: (token) => token.statusURL,
|
|
50
|
-
decode: Effect.fn("FalQueue.decodeStatus")(function* (response, context) {
|
|
51
|
-
const output = yield* decodeQueueStatus(response);
|
|
52
|
-
const decoded = output.value;
|
|
53
|
-
const status = yield* MediaProtocol.status(STATUS, decoded.status, output);
|
|
54
|
-
// fal reports request failures as COMPLETED with an `error`; the response endpoint carries the details.
|
|
55
|
-
const failed = status === "completed" && decoded.error !== undefined && decoded.error !== null;
|
|
56
|
-
return {
|
|
57
|
-
id: context.token.requestID,
|
|
58
|
-
status: failed ? "failed" : status,
|
|
59
|
-
position: status === "queued" ? (decoded.queue_position ?? undefined) : undefined,
|
|
60
|
-
};
|
|
61
|
-
}),
|
|
62
|
-
},
|
|
63
|
-
result: { path: (token) => token.responseURL, decode: input.decodeResult },
|
|
64
|
-
cancel: { method: "PUT", path: (token) => token.cancelURL },
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
export * as FalQueue from "./fal-queue.js";
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
2
|
-
import { type HttpOptions, type ModelID } from "../schema/index.js";
|
|
3
|
-
export type { BlackForestLabsImageOptions } from "../protocols/bfl-images.js";
|
|
4
|
-
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
5
|
-
export type Config = ProviderAuthOption<"optional"> & {
|
|
6
|
-
/** `https://api.eu.bfl.ai` or `https://api.us.bfl.ai` pin inference to one region. */
|
|
7
|
-
readonly baseURL?: string;
|
|
8
|
-
readonly headers?: Record<string, string>;
|
|
9
|
-
readonly http?: HttpOptions.Input;
|
|
10
|
-
};
|
|
11
|
-
export declare const configure: (input?: Config) => {
|
|
12
|
-
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
13
|
-
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/bfl-images.js").BlackForestLabsImageOptions>;
|
|
14
|
-
configure: typeof configure;
|
|
15
|
-
};
|
|
16
|
-
export declare const provider: {
|
|
17
|
-
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
18
|
-
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/bfl-images.js").BlackForestLabsImageOptions>;
|
|
19
|
-
configure: typeof configure;
|
|
20
|
-
};
|
|
21
|
-
export declare const image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/bfl-images.js").BlackForestLabsImageOptions>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Auth } from "../route/auth.js";
|
|
2
|
-
import { MediaRoute } from "../route/media.js";
|
|
3
|
-
import { ProviderID } from "../schema/index.js";
|
|
4
|
-
import { BlackForestLabsImages } from "../protocols/bfl-images.js";
|
|
5
|
-
export const id = ProviderID.make("black-forest-labs");
|
|
6
|
-
const auth = (options) => {
|
|
7
|
-
if ("auth" in options && options.auth)
|
|
8
|
-
return options.auth;
|
|
9
|
-
return Auth.optional("apiKey" in options ? options.apiKey : undefined, "apiKey")
|
|
10
|
-
.orElse(Auth.config("BFL_API_KEY"))
|
|
11
|
-
.pipe(Auth.header("x-key"));
|
|
12
|
-
};
|
|
13
|
-
export const configure = (input = {}) => {
|
|
14
|
-
const media = MediaRoute.deployment(input, auth(input));
|
|
15
|
-
const image = (modelID) => BlackForestLabsImages.model({ ...media, id: modelID });
|
|
16
|
-
return {
|
|
17
|
-
id,
|
|
18
|
-
image,
|
|
19
|
-
configure,
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
export const provider = configure();
|
|
23
|
-
export const image = provider.image;
|
package/dist/providers/fal.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
2
|
-
import { type HttpOptions, type ModelID } from "../schema/index.js";
|
|
3
|
-
export type { FalImageOptions } from "../protocols/fal-images.js";
|
|
4
|
-
export type { FalVideoOptions } from "../protocols/fal-video.js";
|
|
5
|
-
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
6
|
-
export type Config = ProviderAuthOption<"optional"> & {
|
|
7
|
-
readonly baseURL?: string;
|
|
8
|
-
readonly headers?: Record<string, string>;
|
|
9
|
-
readonly http?: HttpOptions.Input;
|
|
10
|
-
};
|
|
11
|
-
export declare const configure: (input?: Config) => {
|
|
12
|
-
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
13
|
-
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/fal-images.js").FalImageOptions>;
|
|
14
|
-
video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/fal-video.js").FalVideoOptions>;
|
|
15
|
-
configure: typeof configure;
|
|
16
|
-
};
|
|
17
|
-
export declare const provider: {
|
|
18
|
-
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
19
|
-
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/fal-images.js").FalImageOptions>;
|
|
20
|
-
video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/fal-video.js").FalVideoOptions>;
|
|
21
|
-
configure: typeof configure;
|
|
22
|
-
};
|
|
23
|
-
export declare const image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/fal-images.js").FalImageOptions>;
|
|
24
|
-
export declare const video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/fal-video.js").FalVideoOptions>;
|
package/dist/providers/fal.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Auth } from "../route/auth.js";
|
|
2
|
-
import { MediaRoute } from "../route/media.js";
|
|
3
|
-
import { ProviderID } from "../schema/index.js";
|
|
4
|
-
import { FalImages } from "../protocols/fal-images.js";
|
|
5
|
-
import { FalVideo } from "../protocols/fal-video.js";
|
|
6
|
-
export const id = ProviderID.make("fal");
|
|
7
|
-
// fal authenticates with `Authorization: Key <FAL_KEY>` rather than a bearer token.
|
|
8
|
-
const auth = (options) => {
|
|
9
|
-
if ("auth" in options && options.auth)
|
|
10
|
-
return options.auth;
|
|
11
|
-
return Auth.optional("apiKey" in options ? options.apiKey : undefined, "apiKey")
|
|
12
|
-
.orElse(Auth.config("FAL_KEY"))
|
|
13
|
-
.pipe(Auth.scheme("Key"));
|
|
14
|
-
};
|
|
15
|
-
export const configure = (input = {}) => {
|
|
16
|
-
const media = MediaRoute.deployment(input, auth(input));
|
|
17
|
-
return {
|
|
18
|
-
id,
|
|
19
|
-
image: (modelID) => FalImages.model({ ...media, id: modelID }),
|
|
20
|
-
video: (modelID) => FalVideo.model({ ...media, id: modelID }),
|
|
21
|
-
configure,
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
export const provider = configure();
|
|
25
|
-
export const image = provider.image;
|
|
26
|
-
export const video = provider.video;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
2
|
-
import { type HttpOptions, type ModelID } from "../schema/index.js";
|
|
3
|
-
export type { ReplicateImageOptions } from "../protocols/replicate-images.js";
|
|
4
|
-
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
5
|
-
export type Config = ProviderAuthOption<"optional"> & {
|
|
6
|
-
readonly baseURL?: string;
|
|
7
|
-
/** `{ Prefer: "wait=60" }` holds the submission open until the prediction finishes (up to 60 seconds). */
|
|
8
|
-
readonly headers?: Record<string, string>;
|
|
9
|
-
readonly http?: HttpOptions.Input;
|
|
10
|
-
};
|
|
11
|
-
export declare const configure: (input?: Config) => {
|
|
12
|
-
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
13
|
-
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/replicate-images.js").ReplicateImageOptions>;
|
|
14
|
-
configure: typeof configure;
|
|
15
|
-
};
|
|
16
|
-
export declare const provider: {
|
|
17
|
-
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
18
|
-
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/replicate-images.js").ReplicateImageOptions>;
|
|
19
|
-
configure: typeof configure;
|
|
20
|
-
};
|
|
21
|
-
export declare const image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/replicate-images.js").ReplicateImageOptions>;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { AuthOptions } from "../route/auth-options.js";
|
|
2
|
-
import { MediaRoute } from "../route/media.js";
|
|
3
|
-
import { ProviderID } from "../schema/index.js";
|
|
4
|
-
import { ReplicateImages } from "../protocols/replicate-images.js";
|
|
5
|
-
export const id = ProviderID.make("replicate");
|
|
6
|
-
const auth = (options) => AuthOptions.bearer(options, "REPLICATE_API_TOKEN");
|
|
7
|
-
export const configure = (input = {}) => {
|
|
8
|
-
const media = MediaRoute.deployment(input, auth(input));
|
|
9
|
-
const image = (modelID) => ReplicateImages.model({ ...media, id: modelID });
|
|
10
|
-
return {
|
|
11
|
-
id,
|
|
12
|
-
image,
|
|
13
|
-
configure,
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export const provider = configure();
|
|
17
|
-
export const image = provider.image;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
2
|
-
import { type HttpOptions, type ModelID } from "../schema/index.js";
|
|
3
|
-
export type { StabilityImageOptions, StabilityUpscaleOptions } from "../protocols/stability-images.js";
|
|
4
|
-
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
5
|
-
export type Config = ProviderAuthOption<"optional"> & {
|
|
6
|
-
readonly baseURL?: string;
|
|
7
|
-
readonly headers?: Record<string, string>;
|
|
8
|
-
readonly http?: HttpOptions.Input;
|
|
9
|
-
};
|
|
10
|
-
export declare const configure: (input?: Config) => {
|
|
11
|
-
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
12
|
-
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/stability-images.js").StabilityImageOptions>;
|
|
13
|
-
upscale: () => import("../image.js").ImageModel<import("../protocols/stability-images.js").StabilityUpscaleOptions>;
|
|
14
|
-
configure: typeof configure;
|
|
15
|
-
};
|
|
16
|
-
export declare const provider: {
|
|
17
|
-
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
18
|
-
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/stability-images.js").StabilityImageOptions>;
|
|
19
|
-
upscale: () => import("../image.js").ImageModel<import("../protocols/stability-images.js").StabilityUpscaleOptions>;
|
|
20
|
-
configure: typeof configure;
|
|
21
|
-
};
|
|
22
|
-
export declare const image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/stability-images.js").StabilityImageOptions>;
|
|
23
|
-
export declare const upscale: () => import("../image.js").ImageModel<import("../protocols/stability-images.js").StabilityUpscaleOptions>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { AuthOptions } from "../route/auth-options.js";
|
|
2
|
-
import { MediaRoute } from "../route/media.js";
|
|
3
|
-
import { ProviderID } from "../schema/index.js";
|
|
4
|
-
import { StabilityImages } from "../protocols/stability-images.js";
|
|
5
|
-
export const id = ProviderID.make("stability");
|
|
6
|
-
const auth = (options) => AuthOptions.bearer(options, "STABILITY_API_KEY");
|
|
7
|
-
export const configure = (input = {}) => {
|
|
8
|
-
const media = MediaRoute.deployment(input, auth(input));
|
|
9
|
-
return {
|
|
10
|
-
id,
|
|
11
|
-
image: (modelID) => StabilityImages.model({ ...media, id: modelID }),
|
|
12
|
-
upscale: () => StabilityImages.upscaleModel(media),
|
|
13
|
-
configure,
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export const provider = configure();
|
|
17
|
-
export const image = provider.image;
|
|
18
|
-
export const upscale = provider.upscale;
|