Skip to content

Language Model Utility

Class: LanguageModelUtility

Implement local AI language models

Process: Utility

new LanguageModelUtility(initialState)

  • initialState Object
    • contextUsage number
    • contextWindow number

[!NOTE] Do not use this constructor directly outside of the class itself, as it will not be properly connected to the localAIHandler

Static Methods

The LanguageModelUtility class has the following static methods:

LanguageModelUtility.create(options) Experimental

Returns Promise<LanguageModelUtility>. Creates a new LanguageModelUtility with the provided options.

LanguageModelUtility.availability([options]) Experimental

Returns Promise<string>

Determines the availability of the language model and returns one of the following strings:

  • available
  • downloadable
  • downloading
  • unavailable

Instance Properties

The following properties are available on instances of LanguageModelUtility:

languageModelUtility.contextUsage Experimental

A number representing how many tokens are currently in the context window.

languageModelUtility.contextWindow Experimental

A number representing the size of the context window, in tokens.

Instance Methods

The following methods are available on instances of LanguageModelUtility:

languageModelUtility.prompt(input, options) Experimental

Returns Promise<string> | Promise<import('stream/web').ReadableStream<string>>. Prompt the model for a response.

languageModelUtility.append(input, options) Experimental

Returns Promise<undefined>. Append a message without prompting for a response.

languageModelUtility.measureContextUsage(input, options) Experimental

Returns Promise<number>. Measure how many tokens the input would use.

languageModelUtility.clone(options) Experimental

Returns Promise<LanguageModelUtility>. Clones the LanguageModelUtility such that the context and initial prompt should be preserved.

languageModelUtility.destroy() Experimental

Destroys the model, and any ongoing executions are aborted.

Markdown source: View on AtomGit·Content from the open-source project el/electron