GithubHelp home page GithubHelp logo

aawadat / node-llama-cpp-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from withcatai/node-llama-cpp

0.0 0.0 0.0 8.13 MB

Run AI models locally on your machine with node.js bindings for llama.cpp. Force a JSON schema on the model output on the generation level

Home Page: https://withcatai.github.io/node-llama-cpp/

License: MIT License

Shell 0.04% JavaScript 0.54% C++ 6.97% TypeScript 88.28% CSS 3.36% CMake 0.82%

node-llama-cpp-1's Introduction

node-llama-cpp Logo

node-llama-cpp

Run AI models locally on your machine

Pre-built bindings are provided with a fallback to building from source with cmake

Build License License Version

✨ New! Try the beta of version 3.0.0 ✨ (included: function calling, automatic chat wrapper detection, embedding support, and more)

Features

  • Run a text generation model locally on your machine
  • Metal and CUDA support
  • Pre-built binaries are provided, with a fallback to building from source without node-gyp or Python
  • Chat with a model using a chat wrapper
  • Use the CLI to chat with a model without writing any code
  • Up-to-date with the latest version of llama.cpp. Download and compile the latest release with a single CLI command.
  • Force a model to generate output in a parseable format, like JSON, or even force it to follow a specific JSON schema

Installation

npm install --save node-llama-cpp

This package comes with pre-built binaries for macOS, Linux and Windows.

If binaries are not available for your platform, it'll fallback to download the latest version of llama.cpp and build it from source with cmake. To disable this behavior set the environment variable NODE_LLAMA_CPP_SKIP_DOWNLOAD to true.

Usage

import {fileURLToPath} from "url";
import path from "path";
import {LlamaModel, LlamaContext, LlamaChatSession} from "node-llama-cpp";

const __dirname = path.dirname(fileURLToPath(import.meta.url));

const model = new LlamaModel({
    modelPath: path.join(__dirname, "models", "codellama-13b.Q3_K_M.gguf")
});
const context = new LlamaContext({model});
const session = new LlamaChatSession({context});


const q1 = "Hi there, how are you?";
console.log("User: " + q1);

const a1 = await session.prompt(q1);
console.log("AI: " + a1);


const q2 = "Summerize what you said";
console.log("User: " + q2);

const a2 = await session.prompt(q2);
console.log("AI: " + a2);

For more examples, see the getting started guide

Contributing

To contribute to node-llama-cpp read the contribution guide.

Acknowledgements


Star please

If you like this repo, star it ✨                                                    

node-llama-cpp-1's People

Contributors

giladgd avatar ido-pluto avatar scenaristeur avatar jonholman avatar itsuka-dev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.