ObservedDecisionService

@ApiStatus.Experimental
class ObservedDecisionService constructor(delegate: DecisionService, observationRegistry: <Error class: unknown class> = ObservationRegistry.NOOP) : DecisionService, DelegatingDecisionService, QuestionSetExecution, PropositionAssessment, RatingAssessment

Opt-in observations for decision services, preserving the delegate's DECISION metadata snapshot. Classification emits one embabel.ai.classification observation; proposition assessment emits one embabel.ai.decision observation. Both carry only fixed operation and outcome tags. False is an answered outcome, just like true. Operational failures and exceptions use a fixed, stackless error marker with no cause. Original exceptions are rethrown unchanged and never logged. Thread interruption state is untouched. Non-fatal observation lifecycle exceptions use bounded diagnostics when logging is available and never replace service behavior. JVM error types propagate.

An ask emits one logical embabel.ai.ask observation plus one embabel.ai.decision observation per provider call made inside it: ask_question_set for a question-set call, and assess or rate for each proposition or rating question asked on its own. A choice question asked on its own goes through classify and emits one embabel.ai.classification observation. The capabilities are the delegate's. Preflight checks them against the hook interfaces of the delegate, so a delegate whose capabilities claim a hook it does not implement fails with an IllegalStateException before any provider call. Every ask overload runs through the shared execution path, so a delegate's own ask override is not called.

Constructors

Link copied to clipboard
constructor(delegate: DecisionService, observationRegistry: <Error class: unknown class> = ObservationRegistry.NOOP)

Properties

Link copied to clipboard
open override val hookSource: DecisionService

The service that does the work. Nested decorators are unwrapped, so preflight and the hook guards see the hooks of the innermost delegate, and a lying descriptor fails before any provider observation opens.

Link copied to clipboard
open override val name: String

Name of the LLM, such as "gpt-3.5-turbo"

Link copied to clipboard
open override val provider: String

Name of the provider, such as "OpenAI"

Link copied to clipboard
open override val type: ModelType

Family remains DECISION even when this service is used only for classification.

Functions

Link copied to clipboard
open override fun ask(request: DecisionRequest): DecisionResponse

Answers a request inside one embabel.ai.ask observation. Each provider call is a child observation. Preflight uses the delegate's capabilities and hooks.

open override fun ask(input: String, spec: DecisionSpec): DecisionResponse

Answers the questions of a spec against the given input. It behaves as ask with a request.

Link copied to clipboard
open override fun askQuestionSet(request: DecisionRequest): DecisionResponse

Runs the delegate's question-set call inside one ask_question_set observation.

Link copied to clipboard
open override fun assess(request: PropositionRequest): PropositionResult

Assess the proposition; a false answer is successful evidence, not an operational failure.

open override fun assess(input: String, question: PropositionQuestionSpec): PropositionResult

Runs the delegate's proposition question call inside one assess observation.

Link copied to clipboard
open override fun capabilities(): DecisionCapabilities

Returns the delegate's capabilities.

Link copied to clipboard

Classify text using only the request's category domain, returning evidence rather than routing policy.

open override fun classify(input: String, spec: ClassificationSpec): ClassificationResult

Classifies text with a spec. Same as calling classify with ClassificationRequest.of(input, spec).

Link copied to clipboard
open override fun infoString(verbose: Boolean?, indent: Int): String
Link copied to clipboard
open override fun metadata(): DecisionServiceMetadata

Pure DECISION metadata snapshot; never serialize a live service in place of this value.

Link copied to clipboard
open override fun rate(input: String, question: RatingQuestionSpec): RatingResult

Runs the delegate's rating call inside one rate observation.