Skip to content

Commit 87007b9

Browse files
committed
refactor: remove deprecated ModelResponse, StructuredResponse, AgentResult and compat shims
1 parent 301e24c commit 87007b9

7 files changed

Lines changed: 11 additions & 121 deletions

File tree

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
AgentGraphResult,
3636
AgentGraphRunner,
3737
AgentGraphRunnerResult,
38-
AgentResult,
3938
AgentRunner,
4039
GraphMetrics,
4140
GraphMetricSummary,
@@ -53,7 +52,6 @@
5352
'Evaluator',
5453
'AgentRunner',
5554
'AgentGraphRunner',
56-
'AgentResult',
5755
'AgentGraphResult',
5856
'AgentGraphRunnerResult',
5957
'GraphMetrics',

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from ldai import log
55
from ldai.models import AICompletionConfig, LDMessage
66
from ldai.providers.runner import Runner
7-
from ldai.providers.types import JudgeResult, ManagedResult
7+
from ldai.providers.types import JudgeResult, ManagedResult, RunnerResult
88
from ldai.tracker import LDAIConfigTracker
99

1010

@@ -46,7 +46,7 @@ async def run(self, prompt: str) -> ManagedResult:
4646
config_messages = self._ai_config.messages or []
4747
all_messages = config_messages + self._messages
4848

49-
result = await tracker.track_metrics_of_async(
49+
result: RunnerResult = await tracker.track_metrics_of_async(
5050
lambda r: r.metrics,
5151
lambda: self._model_runner.run(all_messages),
5252
)

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,13 @@
77
from ldai.providers.types import (
88
AgentGraphResult,
99
AgentGraphRunnerResult,
10-
AgentResult,
1110
GraphMetrics,
1211
GraphMetricSummary,
1312
JudgeResult,
1413
LDAIMetrics,
1514
ManagedGraphResult,
1615
ManagedResult,
17-
ModelResponse,
1816
RunnerResult,
19-
StructuredResponse,
2017
ToolRegistry,
2118
)
2219

@@ -25,19 +22,16 @@
2522
'AgentGraphResult',
2623
'AgentGraphRunner',
2724
'AgentGraphRunnerResult',
28-
'AgentResult',
2925
'AgentRunner',
3026
'GraphMetrics',
3127
'GraphMetricSummary',
3228
'JudgeResult',
3329
'LDAIMetrics',
3430
'ManagedGraphResult',
3531
'ManagedResult',
36-
'ModelResponse',
3732
'ModelRunner',
3833
'Runner',
3934
'RunnerFactory',
4035
'RunnerResult',
41-
'StructuredResponse',
4236
'ToolRegistry',
4337
]

packages/sdk/server-ai/src/ldai/providers/agent_runner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Any, Protocol, runtime_checkable
22

3-
from ldai.providers.types import AgentResult
3+
from ldai.providers.types import RunnerResult
44

55

66
@runtime_checkable
@@ -18,11 +18,11 @@ class AgentRunner(Protocol):
1818
the caller just passes input.
1919
"""
2020

21-
async def run(self, input: Any) -> AgentResult:
21+
async def run(self, input: Any) -> RunnerResult:
2222
"""
2323
Run the agent with the given input.
2424
2525
:param input: The input to the agent (string prompt or structured input)
26-
:return: AgentResult containing the output, raw response, and metrics
26+
:return: RunnerResult containing the agent's content, metrics, and optional raw/parsed fields
2727
"""
2828
...

packages/sdk/server-ai/src/ldai/providers/ai_provider.py

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
from abc import ABC
2-
from typing import Any, Dict, List, Optional
2+
from typing import Any, Optional
33

44
from ldai import log
5-
from ldai.models import LDMessage
6-
from ldai.providers.types import ModelResponse, StructuredResponse, ToolRegistry
5+
from ldai.providers.types import ToolRegistry
76

87

98
class AIProvider(ABC):
@@ -16,51 +15,6 @@ class AIProvider(ABC):
1615
create_model(), create_agent(), and create_agent_graph().
1716
"""
1817

19-
async def invoke_model(self, messages: List[LDMessage]) -> ModelResponse:
20-
"""
21-
Invoke the chat model with an array of messages.
22-
23-
Default implementation takes no action and returns a placeholder response.
24-
Provider implementations should override this method.
25-
26-
:param messages: Array of LDMessage objects representing the conversation
27-
:return: ModelResponse containing the model's response
28-
"""
29-
log.warning('invoke_model not implemented by this provider')
30-
31-
from ldai.models import LDMessage
32-
from ldai.providers.types import LDAIMetrics
33-
34-
return ModelResponse(
35-
message=LDMessage(role='assistant', content=''),
36-
metrics=LDAIMetrics(success=False, usage=None),
37-
)
38-
39-
async def invoke_structured_model(
40-
self,
41-
messages: List[LDMessage],
42-
response_structure: Dict[str, Any],
43-
) -> StructuredResponse:
44-
"""
45-
Invoke the chat model with structured output support.
46-
47-
Default implementation takes no action and returns a placeholder response.
48-
Provider implementations should override this method.
49-
50-
:param messages: Array of LDMessage objects representing the conversation
51-
:param response_structure: Dictionary of output configurations keyed by output name
52-
:return: StructuredResponse containing the structured data
53-
"""
54-
log.warning('invoke_structured_model not implemented by this provider')
55-
56-
from ldai.providers.types import LDAIMetrics
57-
58-
return StructuredResponse(
59-
data={},
60-
raw_response='',
61-
metrics=LDAIMetrics(success=False, usage=None),
62-
)
63-
6418
def create_model(self, config: Any) -> Optional[Any]:
6519
"""
6620
Create a configured model executor for the given AI config.
Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from typing import Any, Dict, List, Protocol, runtime_checkable
1+
from typing import List, Protocol, runtime_checkable
22

33
from ldai.models import LDMessage
4-
from ldai.providers.types import ModelResponse, StructuredResponse
4+
from ldai.providers.types import RunnerResult
55

66

77
@runtime_checkable
@@ -14,25 +14,11 @@ class ModelRunner(Protocol):
1414
and with what parameters — the caller just passes messages.
1515
"""
1616

17-
async def invoke_model(self, messages: List[LDMessage]) -> ModelResponse:
17+
async def invoke_model(self, messages: List[LDMessage]) -> RunnerResult:
1818
"""
1919
Invoke the model with an array of messages.
2020
2121
:param messages: Array of LDMessage objects representing the conversation
22-
:return: ModelResponse containing the model's response and metrics
23-
"""
24-
...
25-
26-
async def invoke_structured_model(
27-
self,
28-
messages: List[LDMessage],
29-
response_structure: Dict[str, Any],
30-
) -> StructuredResponse:
31-
"""
32-
Invoke the model with structured output support.
33-
34-
:param messages: Array of LDMessage objects representing the conversation
35-
:param response_structure: Dictionary defining the JSON schema for output structure
36-
:return: StructuredResponse containing the structured data
22+
:return: RunnerResult containing the model's response and metrics
3723
"""
3824
...

packages/sdk/server-ai/src/ldai/providers/types.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from dataclasses import dataclass, field
77
from typing import Any, Callable, Dict, List, Optional
88

9-
from ldai.models import LDMessage
109
from ldai.tracker import LDAIMetricSummary, TokenUsage
1110

1211
# Type alias for a registry of tools available to an agent.
@@ -87,33 +86,6 @@ class ManagedResult:
8786
"""Optional asyncio Task that resolves to the list of :class:`JudgeResult` instances when awaited."""
8887

8988

90-
@dataclass
91-
class ModelResponse:
92-
"""
93-
Response from a model invocation.
94-
95-
.. deprecated::
96-
Use :class:`RunnerResult` (from a runner) and :class:`ManagedResult`
97-
(from the managed layer) instead.
98-
"""
99-
message: LDMessage
100-
metrics: LDAIMetrics
101-
evaluations: Optional[asyncio.Task[List[JudgeResult]]] = None
102-
103-
104-
@dataclass
105-
class StructuredResponse:
106-
"""
107-
Structured response from AI models.
108-
109-
.. deprecated::
110-
Structured output is now represented by :attr:`RunnerResult.parsed`.
111-
"""
112-
data: Dict[str, Any]
113-
raw_response: str
114-
metrics: LDAIMetrics
115-
116-
11789
@dataclass
11890
class GraphMetrics:
11991
"""Contains raw metrics from a single agent graph run."""
@@ -234,20 +206,6 @@ def to_dict(self) -> Dict[str, Any]:
234206
return result
235207

236208

237-
@dataclass
238-
class AgentResult:
239-
"""
240-
Result from a single-agent run.
241-
242-
.. deprecated::
243-
Use :class:`ManagedResult` (managed layer) or :class:`RunnerResult`
244-
(runner layer) instead.
245-
"""
246-
output: str
247-
raw: Any
248-
metrics: LDAIMetrics
249-
250-
251209
@dataclass
252210
class AgentGraphResult:
253211
"""Contains the result of an agent graph run."""

0 commit comments

Comments
 (0)