Package com.axelor.ai.chat
Class ChatModelFactory
java.lang.Object
com.axelor.ai.chat.ChatModelFactory
Creates non-streaming
ChatModel instances for background tasks and resolves which model
to use based on agent configuration.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordWhat a utility call is for, and whose: logged with every call its model makes. -
Method Summary
Modifier and TypeMethodDescriptionstatic dev.langchain4j.model.chat.ChatModelCreates a non-streaming ChatModel with the given max output tokens.static dev.langchain4j.model.chat.ChatModelstatic dev.langchain4j.model.chat.ChatModelcreate(AiModel model, int maxOutputTokens, boolean background, ChatModelFactory.Usage usage) A utility call's model, every call of which is logged with what it went to and carried.resolvePrimaryModel(ChatRequest request) resolveReplyTokens(ChatRequest request, AiModel model) The most tokens a reply to this request onmodelmay take; null where the provider's own default applies.resolveUtilityModel(ChatRequest request) Resolves the utility model for background tasks.resolveUtilityModel(AiAgent agent) The same fallback for a caller that holds the agent rather than a request.resolveUtilityModel(AiChat chat) The utility model of a chat outside any request — a recap posted from it — falling back, likeresolveUtilityModel(ChatRequest), to the chat's own model when it may not receive what the chat holds.
-
Method Details
-
resolveUtilityModel
Resolves the utility model for background tasks. Falls back through: agent's utility model → agent's primary model → global default chat model. A task sends the chat's history, so when that model may not receive what the chat holds, the turn's own model does the task instead — held to the same question, since a consulted agent may have read data during the turn that its caller's model may not receive: none when neither may, and the task is skipped. -
resolveUtilityModel
The utility model of a chat outside any request — a recap posted from it — falling back, likeresolveUtilityModel(ChatRequest), to the chat's own model when it may not receive what the chat holds. No turn's gate stands before this call, so each fallback is held to the same question: none when no candidate may receive the chat. -
resolveUtilityModel
The same fallback for a caller that holds the agent rather than a request. A null agent lands on the global default, which is the right answer for a chat that never named one. -
resolveReplyTokens
The most tokens a reply to this request onmodelmay take; null where the provider's own default applies. -
resolvePrimaryModel
-
create
public static dev.langchain4j.model.chat.ChatModel create(AiModel model, int maxOutputTokens, boolean background, ChatModelFactory.Usage usage) A utility call's model, every call of which is logged with what it went to and carried.- See Also:
-
create
Creates a non-streaming ChatModel with the given max output tokens. Request/response logging is controlled viaai.logging.requestsandai.logging.responsesin axelor-config.properties. -
create
public static dev.langchain4j.model.chat.ChatModel create(AiModel model, int maxOutputTokens, boolean background) - Parameters:
background- whether nobody is waiting on the reply, so the model'sbackgroundServiceTierapplies. A task that holds a stream open until it answers — a title, a compaction summary — is not background.
-