Class RequestInterceptor.RequestInterceptEvent
- All Implemented Interfaces:
Serializable
- Enclosing interface:
RequestInterceptor
RequestInterceptor before
the orchestrator acts on it. Carries the user's message text and
attachments; both can be replaced, and the whole prompt can be rejected
or postponed for asynchronous preprocessing.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionRequestInterceptEvent(String userMessage, List<AIAttachment> attachments) Creates a new event. -
Method Summary
Modifier and TypeMethodDescriptionGets the attachments as they currently stand — the submitted ones untilsetAttachments(List)replaces them.Gets the user-facing rejection message.Gets the message text as it currently stands — the user's original text untilsetUserMessage(String)replaces it.booleanGets whether the prompt has been rejected.Postpones the prompt so preprocessing can finish asynchronously.voidreject()Rejects the prompt without user-facing feedback: nothing is sent to the LLM, nothing is added to the message list or the conversation history, and neithercontrollernorRequestListenerhooks fire.voidRejects the prompt likereject()and shows the exchange in the message list: the user's message and attachments as originally submitted (unaffected by any replacements), followed by the given message under the assistant name, so the user sees what was rejected and why.voidsetAttachments(List<AIAttachment> attachments) Replaces the attachments sent to the LLM.voidsetUserMessage(String userMessage) Replaces the message text sent to the LLM.
-
Constructor Details
-
RequestInterceptEvent
Creates a new event. The orchestrator creates these itself on every prompt; create one manually only when invoking an interceptor without an orchestrator (e.g. in tests).- Parameters:
userMessage- the user's message text, notnullattachments- the attachments submitted with the message, notnull; copied defensively- Throws:
NullPointerException- ifuserMessageorattachmentsisnull, orattachmentscontainsnullelements
-
-
Method Details
-
getUserMessage
Gets the message text as it currently stands — the user's original text untilsetUserMessage(String)replaces it.- Returns:
- the message text, never
null
-
setUserMessage
Replaces the message text sent to the LLM. The replacement is also what appears in the message list and the conversation history. A blank replacement drops the prompt; preferreject()to cancel explicitly.- Parameters:
userMessage- the new message text, notnull- Throws:
NullPointerException- ifuserMessageisnullIllegalStateException- if a postponed prompt has already been completed
-
getAttachments
Gets the attachments as they currently stand — the submitted ones untilsetAttachments(List)replaces them.- Returns:
- unmodifiable list of attachments with full data; empty when
the message has no attachments, never
null
-
setAttachments
Replaces the attachments sent to the LLM. The replacements are also what appears in the message list. Pass an empty list to strip all attachments.- Parameters:
attachments- the new attachments, notnull; copied defensively- Throws:
NullPointerException- ifattachmentsisnullor containsnullelementsIllegalStateException- if a postponed prompt has already been completed
-
reject
public void reject()Rejects the prompt without user-facing feedback: nothing is sent to the LLM, nothing is added to the message list or the conversation history, and neithercontrollernorRequestListenerhooks fire. Rejection is final — later content changes do not undo it.- Throws:
IllegalStateException- if a postponed prompt has already been completed
-
reject
Rejects the prompt likereject()and shows the exchange in the message list: the user's message and attachments as originally submitted (unaffected by any replacements), followed by the given message under the assistant name, so the user sees what was rejected and why. Neither entry is added to the conversation history and nothing is sent to the LLM. Without a configured message list nothing is shown anywhere. When called multiple times, the last message wins.Because both entries live only in the message list component, they survive session serialization together with the rest of the UI, but are absent from
AIOrchestrator.getHistory()— a UI rebuilt from saved history does not show past rejected exchanges.- Parameters:
userFacingMessage- the message to show to the user, notnull- Throws:
NullPointerException- ifuserFacingMessageisnullIllegalStateException- if a postponed prompt has already been completed
-
isRejected
public boolean isRejected()Gets whether the prompt has been rejected.- Returns:
truewhenreject()orreject(String)has been called,falseotherwise
-
getRejectionMessage
Gets the user-facing rejection message.- Returns:
- the message passed to
reject(String), ornullwhen the prompt is not rejected or was rejected silently
-
postpone
Postpones the prompt so preprocessing can finish asynchronously. The prompt stays suspended — nothing is shown in the UI, no hooks fire, and further prompts are ignored — until the returned continuation is completed. The event can keep being changed after this method returns; the verdict, including an earlierreject(), is applied when the prompt resumes. Make all changes on the thread that completes the continuation, before completing it — a change racing a concurrent completion (such as the timeout) is not reliably detected.When the timeout elapses before the continuation is completed, the prompt fails as if
failedwith aTimeoutException. If the UI the prompt was submitted from is detached before completion, the prompt is abandoned. The prompt's content, including attachment data, stays referenced until the continuation completes or the timeout fires — also when the UI is detached in the meantime — so keep the timeout as tight as the work allows. Throwing from the interceptor after postponing aborts the prompt like any other interceptor failure and the returned continuation becomes inert — completing it has no effect.- Parameters:
timeout- the maximum time to wait for the continuation to be completed, notnull, positive- Returns:
- the continuation to complete, never
null - Throws:
NullPointerException- iftimeoutisnullIllegalArgumentException- iftimeoutis zero or negativeIllegalStateException- if the prompt is already postponed
-