---
title: "Build a custom RAG AI agent in TypeScript and Jupyter"
description: "A local agentic RAG pipeline built in TypeScript inside a Deno Jupyter notebook, using LangChain and LangGraph with Ollama models."
url: "https://swe.quest/articles/build-a-custom-rag-ai-agent-in-typescript-and-jupyter-fc00c37173b8b56a"
canonical: "https://deno.com/blog/build-custom-rag-ai-agent"
source: "Deno"
published: "2025-03-18"
difficulty: "medium"
kind: "How-to"
reading_minutes: 11
tags: ["rag","ai-agents","typescript","llms"]
---

# Build a custom RAG AI agent in TypeScript and Jupyter

A post on [Deno](https://swe.quest/sources/deno.md), published 2025-03-18, 11 min read, How-to. Original: [https://deno.com/blog/build-custom-rag-ai-agent](https://deno.com/blog/build-custom-rag-ai-agent)

## Summary

A local agentic RAG pipeline built in TypeScript inside a Deno Jupyter notebook, using LangChain and LangGraph with Ollama models. Deno blog posts are loaded with Cheerio, split into 500-character chunks, embedded with mxbai-embed-large and stored in an in-memory vector store exposed as a retriever tool. A LangGraph state graph wires an agent node (Llama 3.2 3B, the only small local model the author got tool calling working with) to retrieval, a binary relevance grader, query rewriting and final answer generation with DeepSeek R1 8B. The setup suits confidential documents that must not leave the machine.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [RAG & retrieval](https://swe.quest/tags/rag.md) (AI & ML)
- [AI agents](https://swe.quest/tags/ai-agents.md) (AI & ML)
- [TypeScript](https://swe.quest/tags/typescript.md) (Languages)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)

## Prerequisites

- TypeScript basics ([easy posts on TypeScript](https://swe.quest/tags/typescript.md?difficulty=easy))
- LLM and embedding concepts ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))
- Ollama setup

## Keywords

Deno, LangGraph, LangChain, Ollama, Jupyter, Llama 3.2, DeepSeek R1, mxbai-embed-large

## Related posts

- [Local RAG with Ollama, Mistral, and Turso](https://swe.quest/articles/local-rag-with-ollama-mistral-and-turso-c9414cc4e6a29ef6.md): Turso · 2025-01-08 · Medium · 8 min read · RAG & retrieval, Vector search, SQLite, Local-first & sync, TypeScript
  A local retrieval-augmented generation pipeline can be built in TypeScript using Ollama's Mistral model for both embeddings and generation, with libSQL storing documents and 4096-dimension F32\_BLOB vectors in a single SQLite file indexed via libsql\_vector\_idx.
- [The Dino 🦕, the Llama 🦙, and the Whale 🐋](https://swe.quest/articles/the-dino-the-llama-and-the-whale-cd4c526a1cc60614.md): Deno · 2025-02-27 · Medium · 5 min read · LLMs, TypeScript, JavaScript, Developer tools
  Deno's built-in Jupyter kernel, Ollama and LangChain.js combine into a low-friction environment for experimenting with a locally hosted DeepSeek R1 8B model in TypeScript.
- [Making (Very) Small LLMs Smarter](https://swe.quest/articles/making-very-small-llms-smarter-de3c73ba9f79b97c.md): Docker · 2026-01-16 · Medium · 17 min read · RAG & retrieval, LLMs, AI for coding, Containers, JavaScript
  A 3B-parameter local model (Qwen2.5-Coder-3B, Q4\_K\_M) can become a useful coding assistant for an unfamiliar, recent Go library (Nova) when it is given a small, focused RAG context.
- [Banque des Territoires (CDC Group) x Polyconseil x Hugging Face: Enhancing a Major French Environmental Program with a Sovereign Data Solution](https://swe.quest/articles/banque-des-territoires-cdc-group-x-polyconseil-x-hugging-face-enhancing-a-major-eeda57273a842369.md): Hugging Face · 2024-07-09 · Easy · 17 min read · RAG & retrieval, LLMs, System design, Inference & serving
  Banque des Territoires, Polyconseil and Hugging Face built a sovereign RAG application that drafts sourced email replies for the EduRénov school-renovation program from its internal documentation.
- [Custom Hacker News summaries in your inbox—build an AI Agent with Inngest and Render](https://swe.quest/articles/custom-hacker-news-summaries-in-your-inbox-build-an-ai-agent-with-inngest-and-9ab4714647bce245.md): Render · 2025-01-16 · Medium · 8 min read · AI agents, Vector search, PostgreSQL, TypeScript, LLMs
  A tutorial for building an AI agent that periodically searches Hacker News for user-defined topics and questions and emails summaries.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
