Package org.mockserver.model
Class Completion
java.lang.Object
org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
org.mockserver.model.ObjectWithJsonToString
org.mockserver.model.Completion
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CompletionbooleangetModel()getText()getUsage()inthashCode()withEnforceOutputSchema(Boolean enforceOutputSchema) Opt-in strict structured-output enforcement.Optional model identifier extracted from the provider response.withOutputSchema(String outputSchema) Optional JSON Schema (as a JSON string) that this completion'stextis expected to conform to.withStopReason(String stopReason) withStreaming(Boolean streaming) withStreamingPhysics(Object... parts) Compose streaming physics from independent values.withStreamingPhysics(StreamingPhysics streamingPhysics) withToolCall(ToolUse toolCall) withToolCalls(List<ToolUse> toolCalls) withToolCalls(ToolUse... toolCalls) withToolChoice(String toolChoice) Optional tool-choice directive modelling the request'stool_choicefor this mocked exchange.Methods inherited from class org.mockserver.model.ObjectWithJsonToString
toStringMethods inherited from class org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
fieldsExcludedFromEqualsAndHashCode
-
Constructor Details
-
Completion
public Completion()
-
-
Method Details
-
completion
-
withText
-
getText
-
withToolCalls
-
withToolCalls
-
withToolCall
-
getToolCalls
-
withStopReason
-
getStopReason
-
withUsage
-
getUsage
-
withStreaming
-
streaming
-
getStreaming
-
withStreamingPhysics
-
withStreamingPhysics
Compose streaming physics from independent values. Accepts any combination ofDelay(interpreted as time-to-first-token) andStreamingPhysicsfragments (each typically carrying a single field — e.g.tokensPerSecond(50)orjitter(0.2)). Non-null fields from the fragments are merged left-to-right onto a singleStreamingPhysicsinstance which is then assigned to this completion. Calling implicitly enables streaming. -
getStreamingPhysics
-
withOutputSchema
Optional JSON Schema (as a JSON string) that this completion'stextis expected to conform to. When set, the LLM response handler validates the configured text against the schema as the response is encoded. Validation is fail-soft: a mismatch does not alter the response body — it adds anx-mockserver-structured-output-invaliddiagnostic header and logs a warning, so a deliberately non-conforming fixture still returns exactly as configured while malformed structured-output fixtures are surfaced. -
getOutputSchema
-
withEnforceOutputSchema
Opt-in strict structured-output enforcement. Whentrueand anoutputSchemais declared, the LLM response handler enforces conformance instead of merely flagging it: if the configuredtextdoes not conform to the schema, the handler fails loudly with a provider-correct error response rather than returning the non-conforming body.This models real providers' strict
response_format: json_schemamode, where the provider guarantees schema-valid output — so a non-conforming fixture is a configuration error that should surface rather than pass silently.When unset or
false(the default), behaviour is unchanged: a mismatch is fail-soft — the body is returned as configured and only thex-mockserver-structured-output-invaliddiagnostic header + a warning log are added. Has no effect without anoutputSchema. -
enforceOutputSchema
-
getEnforceOutputSchema
-
withModel
Optional model identifier extracted from the provider response. Set byparseCompletionResponseimplementations so the caller can read the model without re-parsing the response body. -
getModel
-
withToolChoice
Optional tool-choice directive modelling the request'stool_choicefor this mocked exchange. Recognised values:auto(model decides),none(never call a tool),required(must call a tool), or a named tool. When set torequiredand at least one tool call is configured, the encoded response'sfinish_reasonis forced totool_calls. AbsenttoolChoiceleaves the existing finish-reason behaviour unchanged. -
getToolChoice
-
equals
- Overrides:
equalsin classObjectWithReflectiveEqualsHashCodeToString
-
hashCode
public int hashCode()- Overrides:
hashCodein classObjectWithReflectiveEqualsHashCodeToString
-