Language Model Utility
Class: LanguageModelUtility¶
Implement local AI language models
Process: Utility
new LanguageModelUtility(initialState)¶
initialStateObjectcontextUsagenumbercontextWindownumber
[!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¶
optionsLanguageModelCreateOptions
Returns Promise<LanguageModelUtility>. Creates a new LanguageModelUtility with the provided options.
LanguageModelUtility.availability([options]) Experimental¶
optionsLanguageModelCreateCoreOptions (optional)
Returns Promise<string>
Determines the availability of the language model and returns one of the following strings:
availabledownloadabledownloadingunavailable
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¶
inputLanguageModelMessage[]optionsLanguageModelPromptOptions
Returns Promise<string> | Promise<import('stream/web').ReadableStream<string>>. Prompt the model for a response.
languageModelUtility.append(input, options) Experimental¶
inputLanguageModelMessage[]optionsLanguageModelAppendOptions
Returns Promise<undefined>. Append a message without prompting for a response.
languageModelUtility.measureContextUsage(input, options) Experimental¶
inputLanguageModelMessage[]optionsLanguageModelPromptOptions
Returns Promise<number>. Measure how many tokens the input would use.
languageModelUtility.clone(options) Experimental¶
optionsLanguageModelCloneOptions
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