Skip to content

fbrcode/rag-chatbot-nextjs-f1gpt

Repository files navigation

RAG Chatbot

RAG Chatbot with JavaScript, LangChain.js, Next.js, Vercel, OpenAI

Introduction

What is RAG?

Retrieval-Augmented Generation or RAG is when you change the output of a Large Language Model or LLM, by providing the model more context alongside a user's input. That way the model can use its ability to generate text along with the extra context to provide accurate answers to users questions.

Why is RAG useful?

RAG is useful because it allows you to provide more context to a model, which can help the model provide more accurate answers. This is useful because it can help the model provide more accurate answers to questions, which can be useful in a variety of applications.

List of benefits:

  • Cost effective
  • Cut off dates
  • Information does not exist

Vector Embeddings

Vector embedding is a popular technique to represent information in a format that can be easily processed by algorithms, especially deep learning models. This information can be text, pictures, video and audio.

Installation

Requirements

  • Node v20.x+
  • OpenAI account
  • DataStax Vector Database

Setup

Vector Database

Go to https://astra.datastax.com/ and create a new serverless vector database in the form.

Database name: dbf1

OpenAI

Create an account at https://platform.openai.com/settings/organization/api-keys and get your API key.

We will work with OpenAI models:

Next.js Project

npx create-next-app@latest rag-chatbot-nextjs-f1gpt

Options:

✔ Would you like to use TypeScript? … Yes
✔ Would you like to use ESLint? … Yes
✔ Would you like to use Tailwind CSS? … No
✔ Would you like your code inside a `src/` directory? … No
✔ Would you like to use App Router? (recommended) … No
✔ Would you like to use Turbopack for `next dev`? … No
✔ Would you like to customize the import alias (`@/*` by default)? › No

Dependencies:

npm i dotenv
npm i openai
npm i langchain
npm i @datastax/astra-db-ts
npm i --save-dev ts-node
npm i @langchain/community
npm i puppeteer
npm i ai@3.4

Execution

Load additional articles to vector database to augment knowledge base.

npm run seed

Run chat application:

npm run dev

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors