MCPcopy Index your code
hub / github.com/SimonPrammer/svelte-chat-langchain

github.com/SimonPrammer/svelte-chat-langchain @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
7 symbols 22 edges 7 files 0 documented · 0% updated 2y ago★ 611 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Svelte Chat Langchain (Template)

This is a minimal version of "Chat LangChain" implemented with SvelteKit, Vercel AI SDK and or course Langchain!

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 a QA chatbot over Documents or a starting point for your own custom implementation.

Links

  • Step by step tutorial: https://simon-prammer.vercel.app/blog/post/easiest-qa-chatbot
  • Introduction to Chatbots: https://simon-prammer.vercel.app/blog/post/sveltekit-langchain (sadly I had to take down the deployed version because it was abused by some users. If you want to see it in action, feel free to deploy it yourself!)

Features

This app features:

  • Ingestion
  • Document Loading (from Langchain JS docs https://js.langchain.com/docs/get_started/introduction)
  • Document Splitting
  • Embedding using VercelPostgres as Vector Database
  • RAG (Retrieval Augmented Generation)
  • Langchain Expression Language (Sequences & Conditional Chaining)
  • Streaming (simplified with Vercel AI SDK)

Honorable Mentions

This repository is heavily inspired by the original Chat Langchain repository.

For more advanced features such as Indexing / Record Management, user feedback and stream parsing to display sources, I highly recommend checking out the original Chat Langchain repository(https://github.com/langchain-ai/chat-langchain).

  • Langchain Chat Website: https://chat.langchain.com/
  • Langchain Chat Github: https://github.com/langchain-ai/chat-langchain
  • Langchain Blog: https://blog.langchain.dev/building-chat-langchain-2/

Setup

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

In the current configuration, you need:

  • An OpenAI API Key
  • A Vercel account
  • A Vercel Postgres database instance to run the app (https://vercel.com/)
  • Optionally (but highly encouraged) you can add a Langsmith API Key (https://docs.smith.langchain.com/) for debugging and testing chains.

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.

Core symbols most depended-on inside this repo

loadApiDocs
called by 1
src/routes/api/ingest/+server.ts
splitDocs
called by 1
src/routes/api/ingest/+server.ts
initVectorDb
called by 1
src/routes/api/ingest/+server.ts
load
called by 0
src/routes/+page.server.ts
POST
called by 0
src/routes/api/ingest/+server.ts
getRetriever
called by 0
src/routes/api/chat/+server.ts
POST
called by 0
src/routes/api/chat/+server.ts

Shape

Function 7

Languages

TypeScript100%

Modules by API surface

src/routes/api/ingest/+server.ts4 symbols
src/routes/api/chat/+server.ts2 symbols
src/routes/+page.server.ts1 symbols

For agents

$ claude mcp add svelte-chat-langchain \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page