Model
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.
Constructors
Context
ProviderName
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.
Signature
declare class ProviderName extends any {
constructor();
}Models
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.
Signature
interface Model<in out Provider, in out Provides, in out Requires>
extends
Layer<Provides | ProviderName, never, Requires>,
Effect<Layer.Layer<Provides | ProviderName>, never, Requires> {
readonly "~@effect/ai/Model": "~@effect/ai/Model";
readonly provider: Provider;
}
Creates a Model from a provider name and a Layer that constructs AI services.