Intelligenza Artificiale LLM e NLP JavaScript

LangChain JavaScript - Complete Developer Guide

Build local AI apps with LangChain.js and Ollama: LLM chains, persistent memory, REST API and guard rails in JavaScript.

Course description

LangChain JavaScript with Ollama: Build Local AI Apps from Scratch

This course is the perfect starting point if you want to truly understand how modern AI applications work, without relying on expensive cloud services. You use Ollama to run language models locally on your PC, then build on top with LangChain.js everything you need: chains, memory, REST APIs, moderation. No black magic — just JavaScript, Node.js and code you can read and modify.

What You'll Learn

  • Install and configure Ollama, make API calls with Postman and analyze JSON responses
  • Understand the differences between the native Ollama library and LangChain.js, and when to use each
  • Build your first LLM chains with Chain + PromptTemplate in Node.js
  • Use Prompt Engineering to guide model responses and limit them to what you need
  • Chain multiple pipelines (translation + keyword extraction + more) with LangChain pipes
  • Solve the isolated memory problem between sessions and add conversational context
  • Create a complete REST API that exposes an LLM through LangChain
  • Implement persistent memory with JSON files and SQLite3
  • Add Role, Context and Guard Rails to prompts to control model behavior
  • Manage pre and post-guard rails with an internal LLM moderator

A Practical, Local and 100% Yours Approach

Every lesson is built around concrete examples you can run immediately on your computer. No OpenAI account needed, no API call fees. Start from zero — installation included — and end up building a REST API with persistent memory and integrated moderation. It's the type of project you can put in your portfolio or use as a foundation for something bigger.

Who This Course Is For

Ideal for JavaScript or Node.js developers who want to enter the AI world without depending on cloud services. Basic knowledge of JavaScript and REST APIs is required; no mathematical ML needed — everything works at the integration and orchestration level.

Lessons list

I'll show you how to install Ollama, download the LLAMA3 model, and configure the OLLAMA_HOST variable to set up your local AI development environment in JavaScript — from scratch, no cloud services required.

Guarda lezione

Let's use Postman to send requests to Ollama's REST API with the LLAMA3.1 model, exploring call options, available parameters, and the full structure of JSON responses.

Guarda lezione

I'll walk you step by step through reading and interpreting the JSON responses returned by the Ollama API — understanding each field, handling streaming, and preparing for LangChain.js integration.

Guarda lezione

Let's explore what LangChain.js and the native Ollama library are used for, their key differences, and when to choose one over the other — while initializing the correct Node.js project.

Guarda lezione

I'll build the first practical LangChain example in Node.js: installing the npm package, creating the Ollama client, and sending the first request to an LLM to receive the model's response.

Guarda lezione

Let's see how to use LangChain to simplify and abstract calls to Ollama, and how to refactor the code to make it cleaner, more readable, and more efficient in your JavaScript apps.

Guarda lezione

I'll show you how to use LLAMA as a universal translator with LangChain, building your first Chain with PromptTemplate to customize the prompt and get precise translations from the LLM model.

Guarda lezione

I'll apply Prompt Engineering techniques to constrain the LLAMA model's output to the translation only, avoiding verbose or unwanted responses and achieving precise, controlled results with LangChain.

Guarda lezione

Let's build a multi-step LangChain pipeline that, in a single flow, translates text and automatically extracts keywords — leveraging LLM pipes to connect multiple processing steps in sequence.

Guarda lezione

I'll demonstrate with a practical example why LLM prompts are stateless: each request is completely isolated and the model has no memory of previous conversations — this is the core problem we need to solve.

Guarda lezione

Let's explore the techniques available in LangChain to manage memory in LLM models, adding conversational context to create coherent, fluid interactions across multiple requests.

Guarda lezione

In this lesson we build a complete REST API in Node.js that exposes Ollama through LangChain, enabling HTTP-based LLM conversations with a production-ready architecture.

Guarda lezione

I'll explain how to integrate conversational memory into the LangChain REST API, so each session maintains context across HTTP requests without starting fresh every time.

Guarda lezione

Let's add role, context, and a first guard rail to the LangChain prompt — Prompt Engineering techniques to control LLM behavior and restrict it to domain-relevant responses.

Guarda lezione

I'll refine the prompt guard rail by adding thematic constraints and detailed context, learning to keep the LLM model focused on the application domain without responding to off-topic requests.

Guarda lezione

I'll introduce the Pre-Guard Rail concept in LangChain: a preventive filter that analyzes incoming requests before they reach the LLM, blocking potentially dangerous or off-topic inputs.

Guarda lezione

Let's complete the Pre-Guard Rail implementation and introduce a Post-Guard Rail moderator in LangChain, which analyzes and filters the model's responses before returning them to the client.

Guarda lezione

I'll show you how to implement persistent memory in LangChain using a simple JSON file, with no database or external dependencies — the lightest solution to save and reload conversational history.

Guarda lezione

Let's continue developing JSON-based persistent memory in LangChain: organizing the saved message structure, managing sessions, and optimizing the loading of historical context.

Guarda lezione

Let's see how to move from JSON file memory to SQLite3 in LangChain, using SQL for a more structured, robust, and scalable approach to persistent memory in AI applications.

Guarda lezione

Let's continue the SQLite3 integration in LangChain: refining the logic for saving and retrieving conversational messages with optimized SQL queries for efficient session management.

Guarda lezione

We wrap up the SQLite3 persistent memory implementation in LangChain: optimizing the system to handle multiple sessions, flexible conversation history, and per-conversation message retrieval.

Guarda lezione
Giovanni Pace

Giovanni Pace

Ingegnere Informatico · Pratola Peligna

  • 107 Courses
About the teacher

Sono un ingegnere informatico con oltre 15 anni di esperienza nel settore ICT. Mi occupo di sviluppo software, cybersecurity, data science e intelligenza artificiale, con particolare attenzione all’innovazione e all’automazione dei processi aziendali. Da anni svolgo anche attività di docenza e formazione, creando percorsi pratici e coinvolgenti su programmazione, DevOps, AI e sicurezza informatica.

This course includes

  • Lessons 22
  • Duration 4h 18m
  • Difficulty intermedio
  • Language it
  • Certificate No

Recently viewed