Package org.mockserver.matchers
Class LlmConversationMatcher
- java.lang.Object
-
- org.mockserver.matchers.LlmConversationMatcher
-
public class LlmConversationMatcher extends Object
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 Constructor Description LlmConversationMatcher()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetContainsToolResultFor()StringgetLatestMessageContains()PatterngetLatestMessageMatches()StringgetLatestMessageMatchesSource()ParsedMessage.RolegetLatestMessageRole()ProvidergetProvider()IntegergetTurnIndex()booleanhasPredicates()Returns true if any predicate is configured on this matcher.booleanmatches(HttpRequest request)Matches the given request against all configured predicates.LlmConversationMatcherwithContainsToolResultFor(String toolName)LlmConversationMatcherwithLatestMessageContains(String text)LlmConversationMatcherwithLatestMessageMatches(String regexSource)Set regex from a source string.LlmConversationMatcherwithLatestMessageMatches(Pattern pattern)LlmConversationMatcherwithLatestMessageRole(ParsedMessage.Role role)LlmConversationMatcherwithProvider(Provider provider)LlmConversationMatcherwithTurnIndex(Integer turnIndex)
-
-
-
Method Detail
-
withTurnIndex
public LlmConversationMatcher withTurnIndex(Integer turnIndex)
-
getTurnIndex
public Integer getTurnIndex()
-
withLatestMessageContains
public LlmConversationMatcher withLatestMessageContains(String text)
-
getLatestMessageContains
public String getLatestMessageContains()
-
withLatestMessageMatches
public LlmConversationMatcher withLatestMessageMatches(String regexSource)
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
public LlmConversationMatcher withLatestMessageMatches(Pattern pattern)
-
getLatestMessageMatches
public Pattern getLatestMessageMatches()
-
getLatestMessageMatchesSource
public String getLatestMessageMatchesSource()
-
withLatestMessageRole
public LlmConversationMatcher withLatestMessageRole(ParsedMessage.Role role)
-
getLatestMessageRole
public ParsedMessage.Role getLatestMessageRole()
-
withContainsToolResultFor
public LlmConversationMatcher withContainsToolResultFor(String toolName)
-
getContainsToolResultFor
public String getContainsToolResultFor()
-
withProvider
public LlmConversationMatcher withProvider(Provider provider)
-
getProvider
public Provider getProvider()
-
hasPredicates
public boolean hasPredicates()
Returns true if any predicate is configured on this matcher.
-
matches
public boolean matches(HttpRequest request)
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.
-
-