/** * The `Model` module provides a unified interface for AI service providers. * * This module enables creation of provider-specific AI models that can be used * interchangeably within the Effect AI ecosystem. It combines Layer * functionality with provider identification, allowing for seamless switching * between different AI service providers while maintaining type safety. * * @example * ```ts * import type { Layer } from "effect" * import { Effect } from "effect" * import { LanguageModel, Model } from "effect/unstable/ai" * * declare const myAnthropicLayer: Layer.Layer * * const anthropicModel = Model.make("anthropic", "claude-3-5-haiku", myAnthropicLayer) * * const program = Effect.gen(function*() { * const response = yield* LanguageModel.generateText({ * prompt: "Hello, world!" * }) * return response.text * }).pipe( * Effect.provide(anthropicModel) * ) * ``` * * @since 4.0.0 */ import * as Context from "../../Context.ts"; import * as Effect from "../../Effect.ts"; import * as Layer from "../../Layer.ts"; declare const TypeId: "~effect/ai/Model"; /** * A Model represents a provider-specific AI service. * * A Model can be used directly as a Layer to provide a particular model * implementation to an Effect program. * * A Model can also be used as an Effect to "lift" dependencies of the Model * constructor into the parent Effect. This is particularly useful when you * want to use a Model from within an Effect service. * * @template Provider - String literal type identifying the AI provider. * @template Provides - Services that this model provides. * @template Requires - Services that this model requires. * * @since 4.0.0 * @category models */ export interface Model extends Layer.Layer { readonly [TypeId]: typeof TypeId; /** * The provider identifier (e.g., "openai", "anthropic", "amazon-bedrock"). */ readonly provider: Provider; /** * Returns a `Layer` with the requirements satisfied, using the current context. */ readonly captureRequirements: Effect.Effect, never, Requires>; } declare const ProviderName_base: Context.ServiceClass; /** * Service tag that provides the current large language model provider name. * * This tag is automatically provided by Model instances and can be used to * access the name of the provider that is currently in use within a given * Effect program. * * @since 4.0.0 * @category services */ export declare class ProviderName extends ProviderName_base { } declare const ModelName_base: Context.ServiceClass; /** * Service tag that provides the current large language model name. * * This tag is automatically provided by Model instances and can be used to * access the name of the model that is currently in use within a given Effect * program. * * @since 4.0.0 * @category services */ export declare class ModelName extends ModelName_base { } /** * Creates a Model from a provider name and a Layer that constructs AI services. * * @example * ```ts * import type { Layer } from "effect" * import { Effect } from "effect" * import { LanguageModel, Model } from "effect/unstable/ai" * * declare const bedrockLayer: Layer.Layer * * // Model automatically provides ProviderName and ModelName services * const checkProviderAndGenerate = Effect.gen(function*() { * const provider = yield* Model.ProviderName * const modelName = yield* Model.ModelName * * console.log(`Generating with: ${provider}/${modelName}`) * * return yield* LanguageModel.generateText({ * prompt: `Hello from ${provider}!` * }) * }) * * const program = checkProviderAndGenerate.pipe( * Effect.provide(Model.make("amazon-bedrock", "claude-3-5-haiku", bedrockLayer)) * ) * // Will log: "Generating with: amazon-bedrock/claude-3-5-haiku" * ``` * * @since 4.0.0 * @category constructors */ export declare const make: ( /** * Provider identifier (e.g., "openai", "anthropic", "amazon-bedrock"). */ provider: Provider, /** * Model identifier (e.g., "gpt-5", "claude-3-5-haiku"). */ modelName: Name, /** * Layer that provides the AI services for this provider. */ layer: Layer.Layer) => Model; export {}; //# sourceMappingURL=Model.d.ts.map