Chat and Language Models
LLMs are currently available in two API types:
LanguageModels. Their API is very simple - they accept aStringas input and return aStringas output.
This API is now becoming obsolete in favor of chat API (second API type).ChatLanguageModels. These accept either a single or multipleChatMessages as input
and return anAiMessageas output.
ChatMessageusually contains text, but some LLMs also support a mix of text andImages.
Examples of such chat models include OpenAI’sgpt-3.5-turboand Google’sgemini-pro.
Support for LanguageModels will no longer be expanded in LangChain4j,
so in all new features, we will use a ChatLanguageModel API.
ChatLanguageModel is the low-level API in LangChain4j, offering the most power and flexibility.
There are also high-level APIs (Chains and AiServices) that we will cover later, after we go over the basics.
Apart from ChatLanguageModel and LanguageModel, LangChain4j supports the following types of models:
EmbeddingModel- This model can translate text into anEmbedding.ImageModel- This model can generate and editImages.ModerationModel- This model can check if the text contains harmful content.ScoringModel- This model can score (or rank) multiple pieces of text against a query,
essentially determining how relevant each piece of text is to the query. This is useful for RAG.
These will be covered later.
Now, let’s take a closer look at the ChatLanguageModel API.
public interface ChatLanguageModel {
String gen









