From the course: GenAI for Busy Java Developers by Pearson

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Implement a basic chatbot using ChatMemory

Implement a basic chatbot using ChatMemory - Java Tutorial

From the course: GenAI for Busy Java Developers by Pearson

Implement a basic chatbot using ChatMemory

Now, how do we do this in LangChain4j? So let's implement a basic chatbot using what's called chat memory. So in LangChain4j, we talked about some core components, right? We talked about the chat model, and as an example for OpenAI, I had an OpenAI chat model that maybe there's the Google Gemini chat model, but those are classes, right? Chat models and the interface. And we're sending chat messages to the language model. And again, chat message is another type of interface in this blue color. And we've talked about user messages and system messages. Those are classes. Those are types of chat messages. So, so far so good. And what we get back, we get back a chat response. And inside the chat response is an AI message, what comes back from the language model. Now, over time, what we have to do is that we have to preserve the ongoing conversation with the language model. So there's a new type of interface that we're gonna cover here called chat memory. So chat memory is a type of history…

Contents