Package com.axelor.ai.chat.provider
Class LangChain4jChatProvider
java.lang.Object
com.axelor.ai.chat.provider.LangChain4jChatProvider
- All Implemented Interfaces:
ChatProvider
Adapts a LangChain4j
StreamingChatModel to the ChatProvider interface.
Converts UIMessage history to LangChain4j message types, streams the response via
ChatProvider.Listener callbacks, and blocks until the LLM finishes.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.axelor.ai.chat.ChatProvider
ChatProvider.Listener -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DurationHow long a model may send nothing when its own timeout does not say. -
Constructor Summary
ConstructorsConstructorDescriptionLangChain4jChatProvider(dev.langchain4j.model.chat.StreamingChatModel model, List<dev.langchain4j.agent.tool.ToolSpecification> toolSpecs, String modelCode, String providerCode, Integer rateLimit, AiRateLimiter rateLimiter, Duration silence) -
Method Summary
Modifier and TypeMethodDescriptionvoidstream(List<UIMessage> messages, ChatProvider.Listener listener) Sends the conversation history to the LLM and streams the response back via the listener.
-
Field Details
-
DEFAULT_SILENCE
How long a model may send nothing when its own timeout does not say.
-
-
Constructor Details
-
LangChain4jChatProvider
public LangChain4jChatProvider(dev.langchain4j.model.chat.StreamingChatModel model, List<dev.langchain4j.agent.tool.ToolSpecification> toolSpecs, String modelCode, String providerCode, Integer rateLimit, AiRateLimiter rateLimiter, Duration silence) - Parameters:
silence- how long the call may send nothing before it is given up; a call that keeps writing, a long reasoning one included, runs for as long as it writes
-
-
Method Details
-
stream
Description copied from interface:ChatProviderSends the conversation history to the LLM and streams the response back via the listener.Implementations must call
ChatProvider.Listener.onFinish(com.axelor.ai.chat.ChatResult)exactly once, after all content callbacks. This method blocks until the LLM response is fully consumed.- Specified by:
streamin interfaceChatProvider- Parameters:
messages- the conversation history to sendlistener- receives streaming deltas and the finish signal
-