Skip to content

Storyverse website Chatbot powered by OpenAI GPT 3.5, Langchain, LangchainJS

Notifications You must be signed in to change notification settings

paulovsm/chat-langchainjs

 
 

Repository files navigation

Storyverse Chat

This repo is an implementation of a locally hosted chatbot specifically focused on question answering over the Storyverse Website.

Built with LangChain.

The app leverages LangChain's streaming support and async API to update the page in real time for multiple users.

Getting Started

First, create a new .env file from .env.example and add your OpenAI API key found here.

cp .env.example .env

Prerequisites

  • Node.js (v16 or higher)
  • Yarn
  • wget (on macOS, you can install this with brew install wget)

Next, we'll need to load our data source.

Data Ingestion

Data ingestion happens in two steps.

First, you should install dependencies and run the ingestion script:

Next, install dependencies and run the ingestion script:

yarn
cd ingest
pip install -r requirements.txt
python ingest_url.py
python ingest_docs.py

Note: If on Node v16, use NODE_OPTIONS='--experimental-fetch' yarn ingest

This will parse the data, split text, create embeddings, store them in a vectorstore, and then save it to the db/ directory.

We save it to a directory because we only want to run the (expensive) data ingestion process once.

The Next.js server relies on the presence of the db/ directory. Please make sure to run this before moving on to the next step.

Running the Server

Then, run the development server:

yarn dev

Open http://localhost:3000 with your browser to see the result.

Deploying the server

The production version of this repo is hosted on fly. To deploy your own server on Fly, you can use the provided fly.toml and Dockerfile as a starting point.

Inspirations

This repo borrows heavily from

About

Storyverse website Chatbot powered by OpenAI GPT 3.5, Langchain, LangchainJS

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 52.1%
  • Python 27.9%
  • CSS 14.2%
  • Dockerfile 4.6%
  • Other 1.2%