Model
Wraps an AI model layer with provider and model metadata.
A Model can be used anywhere its underlying Layer can be used. It also provides the current provider name and model name through the Effect context. This module includes the Model interface, the ProviderName and ModelName service tags, and the make constructor. Models can also capture their required services from the current context when they need to be used inside another Effect service.
Constructors
Models
A Model represents a provider-specific AI service.
When to use
Use when you use a Model directly as a Layer to provide a particular model implementation to an Effect program, or use it as an Effect to "lift" dependencies of the Model constructor into the parent Effect 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 | ModelName,
never,
Requires
> {
readonly "~effect/ai/Model": "~effect/ai/Model";
readonly captureRequirements: Effect<
Layer<Provides | ProviderName | ModelName, never, never>,
never,
Requires
>;
readonly provider: Provider;
}Services
Service tag that provides the current large language model name.
Details
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.
Signature
declare class ModelName extends Shape<"effect/unstable/ai/Model/ModelName", string, this> {
constructor(_: never);
}ProviderName
Service tag that provides the current large language model provider name.
Details
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 Shape<"effect/unstable/ai/Model/ProviderName", string, this> {
constructor(_: never);
}
Creates a Model from a provider name and a Layer that constructs AI services.