Skip to content

Commit d65f30c

Browse files
jsonbaileyclaude
andcommitted
feat!: remove deprecated client method aliases and type aliases
Remove the following deprecated symbols ahead of the next release: - LDAIClient.config() -> use completion_config() - LDAIClient.create_chat() -> use create_model() - LDAIClient.agent() -> use agent_config() - LDAIClient.agents() -> use agent_configs() - LDAIConfigTracker.track_openai_metrics() -> use track_metrics_of with get_ai_metrics_from_response from ldai_openai - LDAIMetricSummary.duration -> use duration_ms - Chat class and ldai/chat/ shim package -> use ManagedModel - LDAIAgent type alias -> use AIAgentConfig - LDAIAgentConfig type alias -> use AIAgentConfigRequest - LDAIAgentDefaults type alias -> use AIAgentConfigDefault - AIConfig public re-export -> internal base class only BREAKING CHANGE: All deprecated method aliases, type aliases, and the ldai.chat shim package are removed. Migrate to the documented replacements listed above. Note: The plural-form ``evaluation_metric_keys`` field on AIJudgeConfig and AIJudgeConfigDefault is intentionally kept for wire-format compatibility with existing LD-side judge configurations. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7cc3d9b commit d65f30c

8 files changed

Lines changed: 56 additions & 304 deletions

File tree

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,24 @@
33
from ldclient import log
44

55
from ldai.agent_graph import AgentGraphDefinition
6-
from ldai.chat import Chat # Deprecated — use ManagedModel
76
from ldai.client import LDAIClient
87
from ldai.evaluator import Evaluator
98
from ldai.judge import Judge
109
from ldai.managed_agent import ManagedAgent
1110
from ldai.managed_agent_graph import ManagedAgentGraph
1211
from ldai.managed_model import ManagedModel
13-
from ldai.models import ( # Deprecated aliases for backward compatibility
12+
from ldai.models import (
1413
AIAgentConfig,
1514
AIAgentConfigDefault,
1615
AIAgentConfigRequest,
1716
AIAgentGraphConfig,
1817
AIAgents,
1918
AICompletionConfig,
2019
AICompletionConfigDefault,
21-
AIConfig,
2220
AIJudgeConfig,
2321
AIJudgeConfigDefault,
2422
Edge,
2523
JudgeConfiguration,
26-
LDAIAgent,
27-
LDAIAgentConfig,
28-
LDAIAgentDefaults,
2924
LDMessage,
3025
LDTool,
3126
ModelConfig,
@@ -81,10 +76,4 @@
8176
'ModelConfig',
8277
'ProviderConfig',
8378
'log',
84-
# Deprecated exports
85-
'AIConfig',
86-
'Chat',
87-
'LDAIAgent',
88-
'LDAIAgentConfig',
89-
'LDAIAgentDefaults',
9079
]

packages/sdk/server-ai/src/ldai/chat/__init__.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

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

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import uuid
2-
import warnings
32
from typing import Any, Callable, Dict, List, Optional, Tuple
43

54
import chevron
@@ -187,27 +186,6 @@ def completion_config(
187186
key, context, default or _DISABLED_COMPLETION_DEFAULT, variables, default_ai_provider
188187
)
189188

190-
def config(
191-
self,
192-
key: str,
193-
context: Context,
194-
default: Optional[AICompletionConfigDefault] = None,
195-
variables: Optional[Dict[str, Any]] = None,
196-
) -> AICompletionConfig:
197-
"""
198-
Get the value of a model configuration.
199-
200-
.. deprecated:: Use :meth:`completion_config` instead. This method will be removed in a future version.
201-
202-
:param key: The key of the model configuration.
203-
:param context: The context to evaluate the model configuration in.
204-
:param default: The default value of the model configuration.
205-
:param variables: Additional variables for the model configuration.
206-
:return: The value of the model configuration along with a tracker used for gathering metrics.
207-
"""
208-
warnings.warn("config() is deprecated, use completion_config() instead", DeprecationWarning, stacklevel=2)
209-
return self.completion_config(key, context, default, variables)
210-
211189
def _judge_config(
212190
self,
213191
key: str,
@@ -455,20 +433,6 @@ async def create_model(
455433

456434
return ManagedModel(config, runner)
457435

458-
async def create_chat(
459-
self,
460-
key: str,
461-
context: Context,
462-
default: Optional[AICompletionConfigDefault] = None,
463-
variables: Optional[Dict[str, Any]] = None,
464-
default_ai_provider: Optional[str] = None,
465-
) -> Optional[ManagedModel]:
466-
"""
467-
.. deprecated:: Use :meth:`create_model` instead. This method will be removed in a future version.
468-
"""
469-
warnings.warn("create_chat() is deprecated, use create_model() instead", DeprecationWarning, stacklevel=2)
470-
return await self.create_model(key, context, default, variables, default_ai_provider)
471-
472436
async def create_agent(
473437
self,
474438
key: str,
@@ -578,23 +542,6 @@ def agent_config(
578542
key, context, default or _DISABLED_AGENT_DEFAULT, variables
579543
)
580544

581-
def agent(
582-
self,
583-
config: AIAgentConfigRequest,
584-
context: Context,
585-
) -> AIAgentConfig:
586-
"""
587-
Retrieve a single AI Config agent.
588-
589-
.. deprecated:: Use :meth:`agent_config` instead. This method will be removed in a future version.
590-
591-
:param config: The agent configuration to use.
592-
:param context: The context to evaluate the agent configuration in.
593-
:return: Configured AIAgentConfig instance.
594-
"""
595-
warnings.warn("agent() is deprecated, use agent_config() instead", DeprecationWarning, stacklevel=2)
596-
return self.agent_config(config.key, context, config.default, config.variables)
597-
598545
def agent_configs(
599546
self,
600547
agent_configs: List[AIAgentConfigRequest],
@@ -827,23 +774,6 @@ async def create_agent_graph(
827774

828775
return ManagedAgentGraph(graph, runner)
829776

830-
def agents(
831-
self,
832-
agent_configs: List[AIAgentConfigRequest],
833-
context: Context,
834-
) -> AIAgents:
835-
"""
836-
Retrieve multiple AI agent configurations.
837-
838-
.. deprecated:: Use :meth:`agent_configs` instead. This method will be removed in a future version.
839-
840-
:param agent_configs: List of agent configurations to retrieve.
841-
:param context: The context to evaluate the agent configurations in.
842-
:return: Dictionary mapping agent keys to their AIAgentConfig configurations.
843-
"""
844-
warnings.warn("agents() is deprecated, use agent_configs() instead", DeprecationWarning, stacklevel=2)
845-
return self.agent_configs(agent_configs, context)
846-
847777
def __evaluate(
848778
self,
849779
key: str,

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

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import warnings
21
from dataclasses import dataclass, field
32
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Literal, Optional, Union
43

@@ -424,22 +423,3 @@ class AIAgentGraphConfig:
424423
root_config_key: str
425424
edges: List[Edge]
426425
enabled: bool = True
427-
428-
429-
# ============================================================================
430-
# Deprecated Type Aliases for Backward Compatibility
431-
# ============================================================================
432-
433-
# Note: AIConfig is now defined above as a base class (line 169).
434-
# For backward compatibility, code should migrate to:
435-
# - Use AICompletionConfigDefault for default/input values
436-
# - Use AICompletionConfig for return values
437-
438-
# Deprecated: Use AIAgentConfigDefault instead
439-
LDAIAgentDefaults = AIAgentConfigDefault
440-
441-
# Deprecated: Use AIAgentConfigRequest instead
442-
LDAIAgentConfig = AIAgentConfigRequest
443-
444-
# Deprecated: Use AIAgentConfig instead (note: this was the old return type)
445-
LDAIAgent = AIAgentConfig

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

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import base64
44
import json
55
import time
6-
import warnings
76
from dataclasses import dataclass
87
from enum import Enum
98
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional
@@ -59,19 +58,6 @@ def duration_ms(self) -> Optional[int]:
5958
"""Duration of the AI operation in milliseconds."""
6059
return self._duration_ms
6160

62-
@property
63-
def duration(self) -> Optional[int]:
64-
"""
65-
.. deprecated::
66-
Use :attr:`duration_ms` instead.
67-
"""
68-
warnings.warn(
69-
"LDAIMetricSummary.duration is deprecated. Use duration_ms instead.",
70-
DeprecationWarning,
71-
stacklevel=2,
72-
)
73-
return self._duration_ms
74-
7561
@property
7662
def success(self) -> Optional[bool]:
7763
return self._success
@@ -463,48 +449,6 @@ def track_error(self) -> None:
463449
"$ld:ai:generation:error", self._context, self.__get_track_data(), 1
464450
)
465451

466-
def track_openai_metrics(self, func):
467-
"""
468-
Track OpenAI-specific operations.
469-
470-
.. deprecated:: Use :meth:`track_metrics_of` with ``get_ai_metrics_from_response``
471-
from ``ldai_openai`` instead. This method will be removed in a future version.
472-
473-
This function will track the duration of the operation, the token
474-
usage, and the success or error status.
475-
476-
If the provided function throws, then this method will also throw.
477-
478-
In the case the provided function throws, this function will record the
479-
duration and an error.
480-
481-
A failed operation will not have any token usage data.
482-
483-
:param func: Function to track.
484-
:return: Result of the tracked function.
485-
"""
486-
warnings.warn(
487-
"track_openai_metrics is deprecated. Use track_metrics_of with "
488-
"get_ai_metrics_from_response from ldai_openai instead.",
489-
DeprecationWarning,
490-
stacklevel=2,
491-
)
492-
start_ns = time.perf_counter_ns()
493-
try:
494-
result = func()
495-
duration = (time.perf_counter_ns() - start_ns) // 1_000_000
496-
self.track_duration(duration)
497-
self.track_success()
498-
if hasattr(result, "usage") and hasattr(result.usage, "to_dict"):
499-
self.track_tokens(_openai_to_token_usage(result.usage.to_dict()))
500-
except Exception:
501-
duration = (time.perf_counter_ns() - start_ns) // 1_000_000
502-
self.track_duration(duration)
503-
self.track_error()
504-
raise
505-
506-
return result
507-
508452
def track_bedrock_converse_metrics(self, res: dict) -> dict:
509453
"""
510454
Track AWS Bedrock conversation operations.
@@ -597,20 +541,6 @@ def _bedrock_to_token_usage(data: dict) -> TokenUsage:
597541
)
598542

599543

600-
def _openai_to_token_usage(data: dict) -> TokenUsage:
601-
"""
602-
Convert an OpenAI usage dictionary to a TokenUsage object.
603-
604-
:param data: Dictionary containing OpenAI usage data.
605-
:return: TokenUsage object containing usage data.
606-
"""
607-
return TokenUsage(
608-
total=data.get("total_tokens", 0),
609-
input=data.get("prompt_tokens", 0),
610-
output=data.get("completion_tokens", 0),
611-
)
612-
613-
614544
class AIGraphTracker:
615545
"""
616546
Tracks graph-level metrics for AI agent graph operations.

0 commit comments

Comments
 (0)