Package org.mockserver.matchers
Class LlmConversationMatcher
java.lang.Object
org.mockserver.matchers.LlmConversationMatcher
Matches inbound HTTP requests against LLM conversation predicates.
All predicates compose with AND semantics. Parse failures and oversize
bodies are treated as no-match (fail-closed) without throwing.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true if any predicate is configured on this matcher.booleanmatches(HttpRequest request) Matches the given request against all configured predicates.withContainsToolResultFor(String toolName) withLatestMessageMatches(String regexSource) Set regex from a source string.withLatestMessageMatches(Pattern pattern) withNormalization(NormalizationOptions normalization) Set optional prompt normalisation applied to the latest-message text (and, forlatestMessageContains, the expected substring) before the text predicates are evaluated.withProvider(Provider provider) withSemanticMatchAgainst(String semanticMatchAgainst) withTurnIndex(Integer turnIndex)
-
Constructor Details
-
LlmConversationMatcher
public LlmConversationMatcher()
-
-
Method Details
-
withTurnIndex
-
getTurnIndex
-
withLatestMessageContains
-
getLatestMessageContains
-
withLatestMessageMatches
Set regex from a source string. The pattern is compiled eagerly so that syntactically-invalid regexes are rejected at configuration time (not at match time). ThrowsPatternSyntaxExceptionwrapped inIllegalArgumentExceptionif the regex does not compile.- Parameters:
regexSource- the regex source string- Returns:
- this matcher
- Throws:
IllegalArgumentException- if the regex source is syntactically invalid
-
withLatestMessageMatches
-
getLatestMessageMatches
-
getLatestMessageMatchesSource
-
withLatestMessageRole
-
getLatestMessageRole
-
withContainsToolResultFor
-
getContainsToolResultFor
-
withSemanticMatchAgainst
-
getSemanticMatchAgainst
-
withProvider
-
getProvider
-
withNormalization
Set optional prompt normalisation applied to the latest-message text (and, forlatestMessageContains, the expected substring) before the text predicates are evaluated. Null leaves matching exact (today's behaviour). -
getNormalization
-
hasPredicates
public boolean hasPredicates()Returns true if any predicate is configured on this matcher. -
matches
Matches the given request against all configured predicates. Returns true if no predicates are set. Returns false on parse failure, oversize body, missing codec, or any predicate mismatch. Never throws.
-