DynamicPromptExecutor
A PromptExecutor that introduces an explicit resolveModel step before every LLM operation.
Prefer this base class for new custom prompt executors that need fallback, routing, model substitution, or any other model-resolution policy.
Subclasses use resolveModel to translate a caller-requested LLModel into a ResolvedModel — for example, to swap in a fallback model when the requested one is not directly available. Each PromptExecutor entry point taking a plain LLModel is finalized here and delegates to the matching ResolvedModel-based overload, so model resolution always happens exactly once per call and subclasses cannot bypass it.
Subclasses must implement resolveModel together with the ResolvedModel-based execute, executeStreaming, executeMultipleChoices, and moderate overloads.
Inside those overrides, do not delegate to the LLModel-based overloads. They are finalized to re-enter model resolution and will recurse.
Functions
Executes prompt against an already-resolved resolvedModel.
Finalized to enforce that every call resolves through resolveModel before dispatch. Subclasses customize behavior by overriding the ResolvedModel-based execute overload.
Returns multiple independent choices from an already-resolved resolvedModel.
Finalized to enforce that every call resolves through resolveModel before dispatch. Subclasses customize behavior by overriding the ResolvedModel-based executeMultipleChoices overload.
Streams the response for prompt against an already-resolved resolvedModel.
Finalized to enforce that every call resolves through resolveModel before dispatch. Subclasses customize behavior by overriding the ResolvedModel-based executeStreaming overload.
Executes a prompt with structured output, enhancing it with schema instructions or native structured output parameter, and parses the response into the defined structure.
Basic JSON schema generator required for the given model. Return BasicJsonSchemaGenerator by default.
Standard JSON schema generator required for the given model. Return StandardJsonSchemaGenerator by default.
Finalized to enforce that every call resolves through resolveModel before dispatch. Subclasses customize behavior by overriding the ResolvedModel-based moderate overload.
Parses a structured response from the assistant message using the provided structured output configuration and language model. If a fixing parser is specified in the configuration, it will be used; otherwise, the structure will be parsed directly.
Resolves model into the ResolvedModel to actually use for the given promptExecutorOperation.