Skip to content

Commit df722f9

Browse files
jsonbaileyclaude
andcommitted
refactor: Reorder LDAIConfigTracker __init__ params to match spec
New order: ld_client, run_id, config_key, variation_key, version, model_name, provider_name, context, graph_key. All call sites converted to keyword arguments for resilience against future reorders. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7839104 commit df722f9

4 files changed

Lines changed: 58 additions & 52 deletions

File tree

packages/sdk/server-ai/src/ldai/client.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ def create_tracker(self, token: str, context: Context) -> LDAIConfigTracker:
9494

9595
return LDAIConfigTracker(
9696
ld_client=self._client,
97-
variation_key=payload.get("variationKey", ""),
97+
run_id=payload["runId"],
9898
config_key=payload["configKey"],
99+
variation_key=payload.get("variationKey", ""),
99100
version=payload["version"],
100101
model_name="",
101102
provider_name="",
102103
context=context,
103-
run_id=payload["runId"],
104104
)
105105

106106
def _completion_config(
@@ -859,14 +859,14 @@ def __evaluate(
859859

860860
def tracker_factory() -> LDAIConfigTracker:
861861
return LDAIConfigTracker(
862-
self._client,
863-
variation_key,
864-
key,
865-
version,
866-
model_name,
867-
provider_name,
868-
context,
862+
ld_client=self._client,
869863
run_id=str(uuid.uuid4()),
864+
config_key=key,
865+
variation_key=variation_key,
866+
version=version,
867+
model_name=model_name,
868+
provider_name=provider_name,
869+
context=context,
870870
graph_key=graph_key,
871871
)
872872

packages/sdk/server-ai/src/ldai/tracker.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,26 +76,26 @@ class LDAIConfigTracker:
7676
def __init__(
7777
self,
7878
ld_client: LDClient,
79-
variation_key: str,
79+
run_id: str,
8080
config_key: str,
81+
variation_key: str,
8182
version: int,
8283
model_name: str,
8384
provider_name: str,
8485
context: Context,
85-
run_id: str,
8686
graph_key: Optional[str] = None,
8787
):
8888
"""
8989
Initialize an AI Config tracker.
9090
9191
:param ld_client: LaunchDarkly client instance.
92-
:param variation_key: Variation key for tracking.
92+
:param run_id: Unique identifier for this execution.
9393
:param config_key: Configuration key for tracking.
94+
:param variation_key: Variation key for tracking.
9495
:param version: Version of the variation.
9596
:param model_name: Name of the model used.
9697
:param provider_name: Name of the provider used.
9798
:param context: Context for evaluation.
98-
:param run_id: Unique identifier for this execution.
9999
:param graph_key: When set, include ``graphKey`` in all event payloads
100100
(e.g. config-level metrics inside a graph).
101101
"""

packages/sdk/server-ai/tests/test_judge.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ def context() -> Context:
5454
@pytest.fixture
5555
def tracker(client: LDClient, context: Context) -> LDAIConfigTracker:
5656
return LDAIConfigTracker(
57-
client, 'judge-v1', 'judge-config', 1, 'gpt-4', 'openai', context,
58-
run_id='test-run-id',
57+
ld_client=client, run_id='test-run-id', config_key='judge-config',
58+
variation_key='judge-v1', version=1, model_name='gpt-4',
59+
provider_name='openai', context=context,
5960
)
6061

6162

0 commit comments

Comments
 (0)