Integrations
Weave
Trace Drex decision requests in W&B Weave by patching the TypeSafe client, as spans.
Weave is Weights & Biases' tracing and evaluation toolkit. It patches the typesafe-sdk client with patch_typesafe(), and Drex answers that client's requests, so a patched client that points at Drex traces Drex calls. See Questions and Reading answers.
Verified with weave 0.54.0 and typesafe-sdk 0.7.5 against https://console.nace.ai: the patched call succeeds and produces a span for the request. The span was read from an in-memory OpenTelemetry exporter. weave.init and a W&B project were not part of the test, so nothing reached Weave's backend, and what the Weave UI shows is not verified.
Setup
pip install weave typesafe-sdk
export TYPESAFE_API_KEY=nace_sk_...Create the key as shown in Authentication. Set TYPESAFE_BASE_URL to https://console.nace.ai (the host, without /v1); the sample reads it. For Drex on your own infrastructure, use that deployment's URL.
Trace a request
Call patch_typesafe() before you make requests, and set the model on every call. The SDK's default model, jev-latest, is refused by Drex with a 422 (unknown model).
import os
from weave.integrations.patch import patch_typesafe
patch_typesafe()
from typesafe_sdk import Noul, TypeSafeClient
client = TypeSafeClient(
api_key=os.environ["TYPESAFE_API_KEY"],
base_url=os.environ["TYPESAFE_BASE_URL"],
timeout=60,
)
result = client.system_one(
"I was charged twice and want a refund.",
{"refund": Noul(instructions="Is the customer asking for a refund?")},
model="drex-max",
)
result.answers["refund"].noul # probability of yesTo send the spans to a Weave project, initialize Weave with weave.init("<project>") as its documentation describes. That call was not part of the test.
timeout=60 is in seconds: the SDK's default of 10 seconds is shorter than Drex can take on a large request. See Migrate from TypeSafe.
What works and what doesn't
noulandchoicequestions, and the modelsdrex-max,drex-v2.0anddrex-max-v1.1, worked through the SDK. The async client,AsyncTypeSafeClient, also worked against Drex, without Weave. See Models.boxquestions aren't supported by Drex, which answers422and says so.- A
scorequestion has not been tried through Weave. Drex used to return itslegendas a list of level labels, whichtypesafe-sdk0.7.5 rejects when used directly (it validates an object keyed by level), and Weave wraps that client. Drex now sends the TypeSafe SDK an object keyed by level, recognized by itsX-TypeSafe-SDKheader, andX-Nace-Legend: arrayorobjectoverrides it; see Reading answers. That is available once the change is deployed. An objectlegendvalidates against the realtypesafe-sdkScoreAnswermodel offline, but a livescorecall through Weave against a deployment has not been run yet. Until you have tested one, ask score questions with the Python or TypeScript Nace SDK, or over HTTP.
Drex enforces its own request limits; see Limits. A failed request raises the SDK's error, never a low score; see Errors and retries.