Skip to content

SimonPrammer/langchainjs-assistant

Repository files navigation

LangchainJS Assistant (Template)

This is a minimal viable example of a Chatbot based on the new Assistant's API of OpenAI utilizing LangchainJS abstractions.

The prompt of the Chatbot is to only answer questions about the content of a given document. I uploaded the LangchainJS Documentation for OpenAI Assistant to the Knowledge Base. This is far from perfect but it works well to illustrate the concept of using OpenAI's native RAG.

The JavaScript framework of choice is SvelteKit, however the code should be easily transferable to other frameworks (most is just simple JavaScript / Node.js code ).

The Template is held purposefully simple in its implementation while still beeing fully functional.

It is best used as reference to learn the basics of how the new Assistant API works and how to use it with LangchainJS.

Caution: This is by no means a finished product. This API is still in beta and the integrated RAG from uploaded Files is average at best.

Links

Other Ressources for building Chatbots

Features

This app features:

  • Endpoint to create an Assistant with Knowledge Base from a Document
  • Endpoint to chat with that Assistant (can pass in assistantId to prevent creating over and over again)
  • Minimalistic Chat interface

Setup

IMPORTANT - Set environment variables in a .env file (see .env.example for reference).

In the current configuration, you need:

  • An OpenAI API Key

Install dependencies.

pnpm i

Run the development server at http://localhost:5173/.

pnpm run dev

Important note

If you build your own example, note that this repos uses a modified vite.config.ts which is necessary to use the environment variables in local development without explicitly declaring them in the code. This is not necessary in production.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published