Skip to main content
Version: v1.x

Building an AI Chatbot with Llama and NLUX

In this section, we'll show you how to build an AI chatbot with Llama (hosted on Hugging Face) and NLUX.

How to connect to Llama 2 on Hugging Face

Installation

npm install @nlux/hf-react

Usage

import {
useChatAdapter,
llama2InputPreProcessor,
llama2OutputPreProcessor,
} from '@nlux/hf-react';

const Component = () => {
const adapter = useChatAdapter({
dataTransferMode: 'stream',
model: '<MODEL NAME OR URL>',
systemMessage: '<SYSTEM MESSAGE FOR LLAMA 2>',
preProcessors: {
input: llama2InputPreProcessor,
output: llama2OutputPreProcessor,
},
maxNewTokens: 800,
});

return (
<AiChat adapter={adapter} />
);
}