Package com.axelor.ai.chat.plugin
Class ContextPlacement
java.lang.Object
com.axelor.ai.chat.plugin.ContextPlacement
Places per-turn context beside the message it serves, not at the top of the prompt.
Two reasons. The model reads context best next to the question it answers; and a provider's prompt cache reuses the longest unchanged prefix, so anything that changes each turn placed before the history makes the whole history uncacheable. Placed at the latest user message, it only costs the turn it belongs to.
-
Method Summary
Modifier and TypeMethodDescriptionappendToLatestUser(List<UIMessage> messages, String text) Addstextas a trailing part of the latest user message.insertBeforeLatestUser(List<UIMessage> messages, UIMessage context) Insertscontextjust before the latest user message, or last when there is none.static intlatestUserIndex(List<UIMessage> messages) The index of the latest user message, or -1 when there is none.
-
Method Details
-
latestUserIndex
The index of the latest user message, or -1 when there is none. -
appendToLatestUser
Addstextas a trailing part of the latest user message. -
insertBeforeLatestUser
Insertscontextjust before the latest user message, or last when there is none.
-