LangChain4j Listeners - Track Tokens, Log Requests & Monitor AI Performance
Автор: BootcampToProd
Загружено: 2026-02-01
Просмотров: 44
Описание:
Learn how to implement ChatModel Listeners in LangChain4j to monitor requests, log requests and response, and track token usage.
In this detailed tutorial, we will build a Spring Boot application with three powerful listeners:
✅ Content Moderation Listener - Detect sensitive information
✅ Logging & Timing Listener - Track performance metrics
✅ Token Usage Listener - Monitor API costs
🔥 What You'll Learn:
What are ChatModel Listeners and why you need them
Implement the ChatModelListener interface
How to register listeners
How to decide listener execution order
How to pass data between request and response phases using the attributes map
📖 Complete Tutorial & Source Code:
Get the full step-by-step guide and complete source code on our blog:
https://bootcamptoprod.com/langchain4...
Connect with me:
LinkedIn: / bunty-raghani
━━━━━━━━━━━━━━━━━━━━━━━━━
🛒 MY SETUP - The gear that powers these tutorials:
━━━━━━━━━━━━━━━━━━━━━━━━━
🖥️ Mac Mini: https://amzn.to/4ltPhup
⌨️ Logitech K235 Keyboard: https://amzn.to/4mNI0Xh
🖱️ Logitech MX Master 3S Mouse: https://amzn.to/45lZFja
🎤 Boya BY-PM700 Mic: https://amzn.to/4oHUIc1
🌐 Hostinger Web Hosting: https://hostinger.in?REFERRALCODE=A0W...
📝 Disclaimer: This description contains affiliate links (like Amazon & Hostinger). If you click one and make a purchase, I may receive a small commission at no extra cost to you. As an Amazon Associate, I earn from qualifying purchases. Thanks for supporting the channel!
⏰ Timestamps:
00:00 - Introduction
00:23 - What are Chat Model Listeners?
00:54 - Key Methods
01:26 - Request Flow
02:50 - How to Create and Register Listeners
04:22 - Defining Execution Order
05:32 - Demo App Overview
07:04 - Project Structure
07:55 - Code Walkthrough
22:54 - Testing Without Sensitive Information
24:35 - Testing With Sensitive Information
26:23 - onError Method Demo
27:51 - Exception in Listeners
29:09 - Outro
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: