apache_beam.ml.inference.typesafe_inference module

Optional TypeSafe adapter for Beam decision models.

class apache_beam.ml.inference.typesafe_inference.JevDecisionModel(model='jev-latest', timeout=10.0)[source]

Bases: DecisionModel

Evaluate Beam decision questions with Jev through the TypeSafe SDK.

Install the optional SDK from typesafe_tests_requirements.txt and set TYPESAFE_API_KEY on the workers. The client is created when Beam enters the adapter context; its HTTP pool is reused until teardown. Choice and Score map directly to the SDK primitives. Boolean maps to Noul, whose noul field becomes BooleanAnswer.probability.

The SDK retries 429 and server errors with exponential backoff, jitter, and Retry-After support. Calls and retries block the processing thread; they do not coordinate rate limits across workers. Invalid answer keys, types, labels, numeric ranges, or probability keys raise ValueError.

Parameters:
  • model – TypeSafe model identifier, defaulting to jev-latest.

  • timeout – Timeout in seconds for HTTP operations. The SDK handles retries.

evaluate(state, questions)[source]