Readonly
familyOpaque family-name of the language model. Values might be gpt-3.5-turbo
, gpt4
, phi2
, or llama
but they are defined by extensions contributing languages and subject to change.
Readonly
idOpaque identifier of the language model.
Readonly
maxThe maximum number of tokens that can be sent to the model in a single request.
Readonly
nameHuman-readable name of the language model.
Readonly
vendorA well-known identifier of the vendor of the language model. An example is copilot
, but
values are defined by extensions contributing chat models and need to be looked up with them.
Readonly
versionOpaque version string of the model. This is defined by the extension contributing the language model and subject to change.
Count the number of tokens in a message using the model specific tokenizer-logic.
A string or a message instance.
Optional
token: CancellationTokenOptional cancellation token. See CancellationTokenSource for how to create one.
A thenable that resolves to the number of tokens.
Make a chat request using a language model.
Note that language model use may be subject to access restrictions and user consent. Calling this function for the first time (for an extension) will show a consent dialog to the user and because of that this function must only be called in response to a user action! Extensions can use LanguageModelAccessInformation.canSendRequest to check if they have the necessary permissions to make a request.
This function will return a rejected promise if making a request to the language model is not possible. Reasons for this can be:
NoPermissions
NotFound
Blocked
LanguageModelError.cause
An extension can make use of language model tool calling by passing a set of tools to LanguageModelChatRequestOptions.tools. The language model will return a LanguageModelToolCallPart and the extension can invoke the tool and make another request with the result.
An array of message instances.
Optional
options: LanguageModelChatRequestOptionsOptions that control the request.
Optional
token: CancellationTokenA cancellation token which controls the request. See CancellationTokenSource for how to create one.
A thenable that resolves to a LanguageModelChatResponse. The promise will reject when the request couldn't be made.
Represents a language model for making chat requests.
See
lm.selectChatModels
Stubbed