Skip to content

ExtractionLanguageModel

Namespace: Vercel.AI.Operations

public sealed class ExtractionLanguageModel : IExtractionCaller

Adapts structured language-model output to typed field extraction. Maps to ExtractionLanguageModel.

Inheritance: object

Implements: IExtractionCaller

View source

ExtractionLanguageModel(ILanguageModel, string?, double)

Section titled “ExtractionLanguageModel(ILanguageModel, string?, double)”
public ExtractionLanguageModel(ILanguageModel model, string? provider = null, double maxFieldsPerCall = Infinity)

Wraps a language model. The provider id defaults to {model.Provider}.extraction.

Parameters

Name Type Description
model ILanguageModel The language model.
provider string The extraction provider id.
maxFieldsPerCall double Most fields per language-model call, for providers that limit schema size. Larger field maps are split into parallel calls whose answers are merged. Usage is summed, and response and provider metadata come from the first call. A positive integer or PositiveInfinity, the default, which means no limit.

View source

public string ModelId { get; }

Model id.

Value: string

View source

public string Provider { get; }

Provider id.

Value: string

View source

public string SpecificationVersion { get; }

Specification version. Only v4 is accepted.

Value: string

View source

public IReadOnlyList<string> SupportedFieldTypes { get; }

Field types this model can extract. Unsupported types are rejected before any provider I/O.

Value: IReadOnlyList<string>

View source

Deserialize(ExtractionLanguageModelOptions)

Section titled “Deserialize(ExtractionLanguageModelOptions)”
public static ExtractionLanguageModel Deserialize(ExtractionLanguageModelOptions options)

Restores a model from Serialize(ExtractionLanguageModel). Maps to [WORKFLOW_DESERIALIZE].

Parameters

Name Type Description
options ExtractionLanguageModelOptions

Returns: ExtractionLanguageModel

View source

DoExtractAsync(ExtractionModelCall, CancellationToken)

Section titled “DoExtractAsync(ExtractionModelCall, CancellationToken)”
public Task<ExtractionModelResult> DoExtractAsync(ExtractionModelCall call, CancellationToken cancellationToken = default)

Extracts every field with one structured-output model call, or one per group of maxFieldsPerCall fields.

Parameters

Name Type Description
call ExtractionModelCall
cancellationToken CancellationToken

Returns: Task<ExtractionModelResult>

View source

public static ExtractionLanguageModelOptions Serialize(ExtractionLanguageModel model)

Serializes the wrapped model, the provider id, and the field limit for a workflow boundary. Maps to [WORKFLOW_SERIALIZE].

Parameters

Name Type Description
model ExtractionLanguageModel

Returns: ExtractionLanguageModelOptions

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product