-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Node.js Bindings
cosmic-snow edited this page Jul 17, 2024
·
1 revision
Most information for the Node.js bindings can be found in the repository Readme of the bindings and the spec folder.
The following is a small code example to get started.
import { LLModel, createCompletion, DEFAULT_DIRECTORY, DEFAULT_LIBRARIES_DIRECTORY, loadModel } from '../src/gpt4all.js'
const model = await loadModel( 'mistral-7b-openorca.gguf2.Q4_0.gguf', { verbose: true, device: 'gpu' });
const completion1 = await createCompletion(model, 'What is 1 + 1?', { verbose: true, })
console.log(completion1.message)
const completion2 = await createCompletion(model, 'And if we add two?', { verbose: true })
console.log(completion2.message)
model.dispose()