Build local AI apps with LangChain.js and Ollama: LLM chains, persistent memory, REST API and guard rails in JavaScript.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Let's continue developing JSON-based persistent memory in LangChain: organizing the saved message structure, managing sessions, and optimizing the loading of historical context.
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.
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.
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.
Ingegnere Informatico · Pratola Peligna
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.
Prosperous understood Middletons in conviction an uncommonly do. Supposing so be resolving breakfast am or perfectly.
Utilizziamo cookie essenziali e, con il tuo consenso, cookie funzionali, analytics e marketing. Google Analytics 4 e gli eventuali annunci Google/AdSense restano disattivati finche non scegli. Consulta Privacy Policy e Cookie Policy.
Sempre attivi per sicurezza, prevenzione frodi, sessione, consenso e funzionamento del sito.
Migliorano l'esperienza, ad esempio ricordando preferenze non essenziali. Non usati per profilazione pubblicitaria.
Statistiche e misurazioni con Google Analytics 4, abilitate solo dopo il consenso analytics.
Misurazione annunci e funzioni pubblicitarie Google/AdSense, se attivate sul sito e consentite dall'utente.
Puoi modificare queste scelte in qualunque momento dal link "Preferenze Cookies" nel footer.