@shop-os/modelkit 0.2.10 → 0.2.11
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/CHANGELOG.md +11 -0
- package/README.md +61 -0
- package/dist/catalog.cjs +12 -1
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +23 -4
- package/dist/catalog.d.ts +23 -4
- package/dist/catalog.js +12 -1
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +199 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -5
- package/dist/index.d.ts +29 -5
- package/dist/index.js +196 -21
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/catalog.d.cts
CHANGED
|
@@ -368,17 +368,36 @@ type ProviderKeys = Partial<Record<ProviderKeyName, string>> & {
|
|
|
368
368
|
higgsfieldSecret?: string;
|
|
369
369
|
/** Bedrock runtime credentials for Anthropic models when routing.anthropic = "bedrock". */
|
|
370
370
|
aws?: {
|
|
371
|
-
|
|
372
|
-
secretAccessKey: string;
|
|
371
|
+
/** Bedrock region. Must serve the chosen inference profile (us-east-1 for "us"). */
|
|
373
372
|
region: string;
|
|
373
|
+
accessKeyId?: string;
|
|
374
|
+
secretAccessKey?: string;
|
|
374
375
|
sessionToken?: string;
|
|
376
|
+
/** Bedrock API key (AWS_BEARER_TOKEN_BEDROCK). Wins over SigV4. */
|
|
377
|
+
apiKey?: string;
|
|
378
|
+
/** For ECS task roles and other chains. The kit has no AWS SDK dependency; the app passes e.g. defaultProvider(). */
|
|
379
|
+
credentialProvider?: () => PromiseLike<{
|
|
380
|
+
accessKeyId: string;
|
|
381
|
+
secretAccessKey: string;
|
|
382
|
+
sessionToken?: string;
|
|
383
|
+
}>;
|
|
375
384
|
};
|
|
376
385
|
};
|
|
386
|
+
/** Key names a call can require, including the Bedrock credentials object. */
|
|
387
|
+
type RequiredKeyName = ProviderKeyName | "aws";
|
|
388
|
+
/** True when region is set AND (apiKey OR credentialProvider OR both static keys). */
|
|
389
|
+
declare function hasAwsCredentials(aws: ProviderKeys["aws"]): aws is NonNullable<ProviderKeys["aws"]>;
|
|
377
390
|
interface Routing {
|
|
378
391
|
/** Text models: direct provider or the Cloudflare AI Gateway. */
|
|
379
392
|
text?: "direct" | "cloudflare";
|
|
380
|
-
/**
|
|
393
|
+
/**
|
|
394
|
+
* Anthropic chat via Bedrock or the Anthropic API. Default "direct". A row's
|
|
395
|
+
* `providerOptions.modelkit.transport` wins over this. When the chosen transport has
|
|
396
|
+
* no credentials and the other one has, the kit uses the other one and warns.
|
|
397
|
+
*/
|
|
381
398
|
anthropic?: "direct" | "bedrock";
|
|
399
|
+
/** Inference profile prefix for Bedrock ids. Default "us". */
|
|
400
|
+
bedrockProfile?: "us" | "global" | "eu" | "jp" | "au";
|
|
382
401
|
/** fal from geo-blocked regions goes through the Cloudflare passthrough. */
|
|
383
402
|
fal?: "direct" | "cloudflare-passthrough";
|
|
384
403
|
cloudflare?: {
|
|
@@ -566,4 +585,4 @@ declare function isModelKitError(err: unknown): err is ModelKitError;
|
|
|
566
585
|
/** Resolve caller options against a catalog row, dispatching on `model.type`. */
|
|
567
586
|
declare function resolveOptions(model: CatalogModel, request: ImageRequest | VideoRequest | AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest | VideoRequest | AudioRequest>;
|
|
568
587
|
|
|
569
|
-
export { ADAPTER_IDS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, type CatalogOrigin, CatalogSchema, type CatalogSource, type Exposure, ExposureSchema, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, compareCatalogOrder, isListed, isListedOn, isModelKitError, liveCatalog, liveState, nearestAspectRatio, normalizeExposure, primeCatalog, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions, sortCatalogRows };
|
|
588
|
+
export { ADAPTER_IDS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, type CatalogOrigin, CatalogSchema, type CatalogSource, type Exposure, ExposureSchema, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, compareCatalogOrder, hasAwsCredentials, isListed, isListedOn, isModelKitError, liveCatalog, liveState, nearestAspectRatio, normalizeExposure, primeCatalog, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions, sortCatalogRows };
|
package/dist/catalog.d.ts
CHANGED
|
@@ -368,17 +368,36 @@ type ProviderKeys = Partial<Record<ProviderKeyName, string>> & {
|
|
|
368
368
|
higgsfieldSecret?: string;
|
|
369
369
|
/** Bedrock runtime credentials for Anthropic models when routing.anthropic = "bedrock". */
|
|
370
370
|
aws?: {
|
|
371
|
-
|
|
372
|
-
secretAccessKey: string;
|
|
371
|
+
/** Bedrock region. Must serve the chosen inference profile (us-east-1 for "us"). */
|
|
373
372
|
region: string;
|
|
373
|
+
accessKeyId?: string;
|
|
374
|
+
secretAccessKey?: string;
|
|
374
375
|
sessionToken?: string;
|
|
376
|
+
/** Bedrock API key (AWS_BEARER_TOKEN_BEDROCK). Wins over SigV4. */
|
|
377
|
+
apiKey?: string;
|
|
378
|
+
/** For ECS task roles and other chains. The kit has no AWS SDK dependency; the app passes e.g. defaultProvider(). */
|
|
379
|
+
credentialProvider?: () => PromiseLike<{
|
|
380
|
+
accessKeyId: string;
|
|
381
|
+
secretAccessKey: string;
|
|
382
|
+
sessionToken?: string;
|
|
383
|
+
}>;
|
|
375
384
|
};
|
|
376
385
|
};
|
|
386
|
+
/** Key names a call can require, including the Bedrock credentials object. */
|
|
387
|
+
type RequiredKeyName = ProviderKeyName | "aws";
|
|
388
|
+
/** True when region is set AND (apiKey OR credentialProvider OR both static keys). */
|
|
389
|
+
declare function hasAwsCredentials(aws: ProviderKeys["aws"]): aws is NonNullable<ProviderKeys["aws"]>;
|
|
377
390
|
interface Routing {
|
|
378
391
|
/** Text models: direct provider or the Cloudflare AI Gateway. */
|
|
379
392
|
text?: "direct" | "cloudflare";
|
|
380
|
-
/**
|
|
393
|
+
/**
|
|
394
|
+
* Anthropic chat via Bedrock or the Anthropic API. Default "direct". A row's
|
|
395
|
+
* `providerOptions.modelkit.transport` wins over this. When the chosen transport has
|
|
396
|
+
* no credentials and the other one has, the kit uses the other one and warns.
|
|
397
|
+
*/
|
|
381
398
|
anthropic?: "direct" | "bedrock";
|
|
399
|
+
/** Inference profile prefix for Bedrock ids. Default "us". */
|
|
400
|
+
bedrockProfile?: "us" | "global" | "eu" | "jp" | "au";
|
|
382
401
|
/** fal from geo-blocked regions goes through the Cloudflare passthrough. */
|
|
383
402
|
fal?: "direct" | "cloudflare-passthrough";
|
|
384
403
|
cloudflare?: {
|
|
@@ -566,4 +585,4 @@ declare function isModelKitError(err: unknown): err is ModelKitError;
|
|
|
566
585
|
/** Resolve caller options against a catalog row, dispatching on `model.type`. */
|
|
567
586
|
declare function resolveOptions(model: CatalogModel, request: ImageRequest | VideoRequest | AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest | VideoRequest | AudioRequest>;
|
|
568
587
|
|
|
569
|
-
export { ADAPTER_IDS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, type CatalogOrigin, CatalogSchema, type CatalogSource, type Exposure, ExposureSchema, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, compareCatalogOrder, isListed, isListedOn, isModelKitError, liveCatalog, liveState, nearestAspectRatio, normalizeExposure, primeCatalog, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions, sortCatalogRows };
|
|
588
|
+
export { ADAPTER_IDS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, type CatalogOrigin, CatalogSchema, type CatalogSource, type Exposure, ExposureSchema, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, compareCatalogOrder, hasAwsCredentials, isListed, isListedOn, isModelKitError, liveCatalog, liveState, nearestAspectRatio, normalizeExposure, primeCatalog, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions, sortCatalogRows };
|
package/dist/catalog.js
CHANGED
|
@@ -2034,7 +2034,18 @@ var CatalogModelSchemaBase = z.looseObject({
|
|
|
2034
2034
|
});
|
|
2035
2035
|
}
|
|
2036
2036
|
});
|
|
2037
|
-
var CatalogModelSchema = CatalogModelSchemaBase
|
|
2037
|
+
var CatalogModelSchema = CatalogModelSchemaBase.superRefine(
|
|
2038
|
+
(row, ctx) => {
|
|
2039
|
+
const transport = row.providerOptions?.["modelkit"]?.["transport"];
|
|
2040
|
+
if (transport !== void 0 && transport !== "direct" && transport !== "bedrock") {
|
|
2041
|
+
ctx.addIssue({
|
|
2042
|
+
code: "custom",
|
|
2043
|
+
path: ["providerOptions", "modelkit", "transport"],
|
|
2044
|
+
message: 'transport must be "direct" or "bedrock"'
|
|
2045
|
+
});
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
);
|
|
2038
2049
|
var CatalogSchema = z.array(CatalogModelSchemaBase).superRefine((rows, ctx) => {
|
|
2039
2050
|
const seenIds = /* @__PURE__ */ new Map();
|
|
2040
2051
|
rows.forEach((row, index) => {
|