Skip to content

Commit 583939d

Browse files
authored
feat!: rename GraphMetrics/GraphMetricSummary to AIGraphMetrics/AIGraphMetricSummary (#173)
1 parent 7d6ad23 commit 583939d

12 files changed

Lines changed: 58 additions & 58 deletions

File tree

packages/ai-providers/server-ai-langchain/src/ldai_langchain/langgraph_agent_graph_runner.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from ldai import log
77
from ldai.agent_graph import AgentGraphDefinition, AgentGraphNode
88
from ldai.providers import AgentGraphRunner, ToolRegistry
9-
from ldai.providers.types import AgentGraphRunnerResult, GraphMetrics
9+
from ldai.providers.types import AgentGraphRunnerResult, AIGraphMetrics
1010

1111
from ldai_langchain.langchain_helper import (
1212
build_structured_tools,
@@ -281,10 +281,10 @@ async def run(self, input: Any) -> AgentGraphRunnerResult:
281281
Builds a LangGraph StateGraph from the AgentGraphDefinition, compiles
282282
it, and invokes it. Uses a LangChain callback handler to collect
283283
per-node metrics. Graph-level tracking events are emitted by the
284-
managed layer from the returned GraphMetrics.
284+
managed layer from the returned AIGraphMetrics.
285285
286286
:param input: The string prompt to send to the agent graph
287-
:return: AgentGraphRunnerResult with the final content and GraphMetrics
287+
:return: AgentGraphRunnerResult with the final content and AIGraphMetrics
288288
"""
289289
start_ns = time.perf_counter_ns()
290290

@@ -309,7 +309,7 @@ async def run(self, input: Any) -> AgentGraphRunnerResult:
309309
return AgentGraphRunnerResult(
310310
content=output,
311311
raw=result,
312-
metrics=GraphMetrics(
312+
metrics=AIGraphMetrics(
313313
success=True,
314314
path=handler.path,
315315
duration_ms=duration_ms,
@@ -330,7 +330,7 @@ async def run(self, input: Any) -> AgentGraphRunnerResult:
330330
return AgentGraphRunnerResult(
331331
content='',
332332
raw=None,
333-
metrics=GraphMetrics(
333+
metrics=AIGraphMetrics(
334334
success=False,
335335
duration_ms=duration_ms,
336336
),

packages/ai-providers/server-ai-openai/src/ldai_openai/openai_agent_graph_runner.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from ldai import log
66
from ldai.agent_graph import AgentGraphDefinition, AgentGraphNode
77
from ldai.providers import AgentGraphRunner, ToolRegistry
8-
from ldai.providers.types import AgentGraphRunnerResult, GraphMetrics, LDAIMetrics
8+
from ldai.providers.types import AgentGraphRunnerResult, AIGraphMetrics, LDAIMetrics
99

1010
from ldai_openai.openai_helper import (
1111
extract_usage_from_request_entry,
@@ -72,7 +72,7 @@ async def run(self, input: Any) -> AgentGraphRunnerResult:
7272
Graph-level tracking events are emitted by the managed layer.
7373
7474
:param input: The string prompt to send to the agent graph
75-
:return: AgentGraphRunnerResult with the final content and GraphMetrics
75+
:return: AgentGraphRunnerResult with the final content and AIGraphMetrics
7676
"""
7777
self._node_metrics = {}
7878
path: List[str] = []
@@ -99,7 +99,7 @@ async def run(self, input: Any) -> AgentGraphRunnerResult:
9999
return AgentGraphRunnerResult(
100100
content=str(result.final_output),
101101
raw=result,
102-
metrics=GraphMetrics(
102+
metrics=AIGraphMetrics(
103103
success=True,
104104
path=path,
105105
duration_ms=duration_ms,
@@ -119,7 +119,7 @@ async def run(self, input: Any) -> AgentGraphRunnerResult:
119119
return AgentGraphRunnerResult(
120120
content='',
121121
raw=None,
122-
metrics=GraphMetrics(
122+
metrics=AIGraphMetrics(
123123
success=False,
124124
path=path,
125125
duration_ms=duration_ms,

packages/ai-providers/server-ai-openai/tests/test_openai_agent_graph_runner.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from ldai.agent_graph import AgentGraphDefinition
77
from ldai.models import AIAgentGraphConfig, AIAgentConfig, Edge, ModelConfig, ProviderConfig
88
from ldai.providers import ToolRegistry
9-
from ldai.providers.types import AgentGraphRunnerResult, GraphMetrics
9+
from ldai.providers.types import AgentGraphRunnerResult, AIGraphMetrics
1010
from ldai_openai.openai_agent_graph_runner import OpenAIAgentGraphRunner
1111
from ldai_openai.openai_runner_factory import OpenAIRunnerFactory
1212
from ldai.evaluator import Evaluator
@@ -84,7 +84,7 @@ async def test_openai_agent_graph_runner_run_raises_when_agents_not_installed():
8484

8585
@pytest.mark.asyncio
8686
async def test_openai_agent_graph_runner_run_failure_returns_metrics():
87-
"""On import failure, returned GraphMetrics has success=False (no tracker needed)."""
87+
"""On import failure, returned AIGraphMetrics has success=False (no tracker needed)."""
8888
graph = _make_graph()
8989
runner = OpenAIAgentGraphRunner(graph, {})
9090

@@ -130,7 +130,7 @@ async def test_openai_agent_graph_runner_run_failure_marks_node_not_success():
130130

131131
@pytest.mark.asyncio
132132
async def test_openai_agent_graph_runner_run_success():
133-
"""Successful run returns AgentGraphRunnerResult with populated GraphMetrics."""
133+
"""Successful run returns AgentGraphRunnerResult with populated AIGraphMetrics."""
134134
graph = _make_graph()
135135

136136
mock_result = MagicMock()
@@ -169,7 +169,7 @@ async def test_openai_agent_graph_runner_run_success():
169169

170170
assert isinstance(result, AgentGraphRunnerResult)
171171
assert result.content == "agent answer"
172-
assert isinstance(result.metrics, GraphMetrics)
172+
assert isinstance(result.metrics, AIGraphMetrics)
173173
assert result.metrics.success is True
174174
assert result.metrics.duration_ms is not None
175175
assert 'root-agent' in result.metrics.path

packages/ai-providers/server-ai-openai/tests/test_tracking_openai_agents.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
with the correct payloads — without making real API calls.
77
88
Tracking events are now emitted by ManagedAgentGraph._flush_graph_tracking()
9-
from the GraphMetrics returned by the runner, rather than directly inside the
9+
from the AIGraphMetrics returned by the runner, rather than directly inside the
1010
runner. These tests exercise the full pipeline through ManagedAgentGraph.run().
1111
"""
1212

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
from ldai.providers import (
3535
AgentGraphRunner,
3636
AgentGraphRunnerResult,
37-
GraphMetrics,
38-
GraphMetricSummary,
37+
AIGraphMetrics,
38+
AIGraphMetricSummary,
3939
ManagedGraphResult,
4040
ManagedResult,
4141
Runner,
@@ -50,8 +50,8 @@
5050
'Evaluator',
5151
'AgentGraphRunner',
5252
'AgentGraphRunnerResult',
53-
'GraphMetrics',
54-
'GraphMetricSummary',
53+
'AIGraphMetrics',
54+
'AIGraphMetricSummary',
5555
'ManagedGraphResult',
5656
'ManagedResult',
5757
'Runner',

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from ldai.providers.runner_factory import RunnerFactory
55
from ldai.providers.types import (
66
AgentGraphRunnerResult,
7-
GraphMetrics,
8-
GraphMetricSummary,
7+
AIGraphMetrics,
8+
AIGraphMetricSummary,
99
JudgeResult,
1010
LDAIMetrics,
1111
ManagedGraphResult,
@@ -18,8 +18,8 @@
1818
'AIProvider',
1919
'AgentGraphRunner',
2020
'AgentGraphRunnerResult',
21-
'GraphMetrics',
22-
'GraphMetricSummary',
21+
'AIGraphMetrics',
22+
'AIGraphMetricSummary',
2323
'JudgeResult',
2424
'LDAIMetrics',
2525
'ManagedGraphResult',

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ async def run(self, input: Any) -> AgentGraphRunnerResult:
2323
Run the agent graph with the given input.
2424
2525
:param input: The input to the agent graph (string prompt or structured input)
26-
:return: AgentGraphRunnerResult containing the content, raw response, and GraphMetrics
26+
:return: AgentGraphRunnerResult containing the content, raw response, and AIGraphMetrics
2727
"""
2828
...

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class ManagedResult:
8787

8888

8989
@dataclass
90-
class GraphMetrics:
90+
class AIGraphMetrics:
9191
"""Contains raw metrics from a single agent graph run."""
9292

9393
success: bool
@@ -107,7 +107,7 @@ class GraphMetrics:
107107

108108

109109
@dataclass
110-
class GraphMetricSummary:
110+
class AIGraphMetricSummary:
111111
"""Contains a summary of metrics for an agent graph run."""
112112

113113
success: Optional[bool] = None
@@ -136,7 +136,7 @@ class ManagedGraphResult:
136136
content: str
137137
"""The graph's final output content."""
138138

139-
metrics: GraphMetricSummary
139+
metrics: AIGraphMetricSummary
140140
"""Aggregated metric summary from the graph tracker for this run."""
141141

142142
raw: Optional[Any] = None
@@ -153,7 +153,7 @@ class AgentGraphRunnerResult:
153153
content: str
154154
"""The graph's final output content."""
155155

156-
metrics: GraphMetrics
156+
metrics: AIGraphMetrics
157157
"""Metrics from the graph run."""
158158

159159
raw: Optional[Any] = None

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from ldai import log
1414

1515
if TYPE_CHECKING:
16-
from ldai.providers.types import GraphMetrics, GraphMetricSummary, LDAIMetrics
16+
from ldai.providers.types import AIGraphMetrics, AIGraphMetricSummary, LDAIMetrics
1717

1818

1919
class FeedbackKind(Enum):
@@ -615,7 +615,7 @@ class AIGraphTracker:
615615
"""
616616
Tracks graph-level metrics for AI agent graph operations.
617617
618-
Maintains an internal :class:`~ldai.providers.types.GraphMetricSummary`
618+
Maintains an internal :class:`~ldai.providers.types.AIGraphMetricSummary`
619619
that is updated as tracking methods are called. Retrieve it via
620620
:meth:`get_summary`.
621621
"""
@@ -643,15 +643,15 @@ def __init__(
643643
self._version = version
644644
self._context = context
645645

646-
from ldai.providers.types import GraphMetricSummary
647-
self._summary = GraphMetricSummary()
646+
from ldai.providers.types import AIGraphMetricSummary
647+
self._summary = AIGraphMetricSummary()
648648

649649
@property
650650
def graph_key(self) -> str:
651651
"""Graph configuration key used in tracking payloads."""
652652
return self._graph_key
653653

654-
def get_summary(self) -> GraphMetricSummary:
654+
def get_summary(self) -> AIGraphMetricSummary:
655655
"""
656656
Get the current summary of graph-level metrics.
657657
@@ -820,10 +820,10 @@ def track_handoff_failure(self, source_key: str, target_key: str) -> None:
820820
def _track_from_graph_metrics(
821821
self,
822822
result: Any,
823-
metrics_extractor: Callable[[Any], Optional[GraphMetrics]],
823+
metrics_extractor: Callable[[Any], Optional[AIGraphMetrics]],
824824
elapsed_ms: int,
825825
) -> None:
826-
metrics: Optional[GraphMetrics] = None
826+
metrics: Optional[AIGraphMetrics] = None
827827
try:
828828
metrics = metrics_extractor(result)
829829
except Exception as exc:
@@ -845,24 +845,24 @@ def _track_from_graph_metrics(
845845

846846
def track_graph_metrics_of(
847847
self,
848-
metrics_extractor: Callable[[Any], Optional[GraphMetrics]],
848+
metrics_extractor: Callable[[Any], Optional[AIGraphMetrics]],
849849
func: Callable[[], Any],
850850
) -> Any:
851851
"""
852852
Track graph-level metrics for a synchronous graph operation.
853853
854-
Times the operation, extracts :class:`~ldai.providers.types.GraphMetrics`
854+
Times the operation, extracts :class:`~ldai.providers.types.AIGraphMetrics`
855855
via the provided extractor, and fires graph-level tracking events
856856
(path, duration, success/failure, total tokens).
857857
858-
If the extracted ``GraphMetrics`` has a non-``None`` ``duration_ms``,
858+
If the extracted ``AIGraphMetrics`` has a non-``None`` ``duration_ms``,
859859
that value is used instead of the wall-clock elapsed time.
860860
861861
Node-level metrics are not tracked by this method.
862862
863863
For async operations, use :meth:`track_graph_metrics_of_async`.
864864
865-
:param metrics_extractor: Function that extracts GraphMetrics from the result
865+
:param metrics_extractor: Function that extracts AIGraphMetrics from the result
866866
:param func: Synchronous callable that runs the graph operation
867867
:return: The result of the operation
868868
"""
@@ -881,15 +881,15 @@ def track_graph_metrics_of(
881881

882882
async def track_graph_metrics_of_async(
883883
self,
884-
metrics_extractor: Callable[[Any], Optional[GraphMetrics]],
884+
metrics_extractor: Callable[[Any], Optional[AIGraphMetrics]],
885885
func: Callable[[], Any],
886886
) -> Any:
887887
"""
888888
Track graph-level metrics for an async graph operation (``func`` is awaited).
889889
890890
Same event semantics as :meth:`track_graph_metrics_of`.
891891
892-
:param metrics_extractor: Function that extracts GraphMetrics from the result
892+
:param metrics_extractor: Function that extracts AIGraphMetrics from the result
893893
:param func: Async callable that runs the graph operation
894894
:return: The result of the operation
895895
"""

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
from ldai.providers import AgentGraphRunner, ToolRegistry
1111
from ldai.providers.types import (
1212
AgentGraphRunnerResult,
13-
GraphMetrics,
14-
GraphMetricSummary,
13+
AIGraphMetrics,
14+
AIGraphMetricSummary,
1515
LDAIMetrics,
1616
)
1717
from ldai.tracker import TokenUsage
@@ -28,19 +28,19 @@ async def run(self, input) -> AgentGraphRunnerResult:
2828
return AgentGraphRunnerResult(
2929
content=self._content,
3030
raw={"input": input},
31-
metrics=GraphMetrics(success=True),
31+
metrics=AIGraphMetrics(success=True),
3232
)
3333

3434

3535
class StubRunnerWithMetrics(AgentGraphRunner):
36-
"""Runner that returns AgentGraphRunnerResult with full GraphMetrics."""
36+
"""Runner that returns AgentGraphRunnerResult with full AIGraphMetrics."""
3737
def __init__(self, content: str = "new shape output"):
3838
self._content = content
3939

4040
async def run(self, input) -> AgentGraphRunnerResult:
4141
return AgentGraphRunnerResult(
4242
content=self._content,
43-
metrics=GraphMetrics(
43+
metrics=AIGraphMetrics(
4444
success=True,
4545
path=["root", "specialist"],
4646
duration_ms=42,
@@ -67,7 +67,7 @@ async def run(self, input) -> AgentGraphRunnerResult:
6767
def _make_graph_tracker_mock(runner_result):
6868
"""Create a mock graph tracker whose track_graph_metrics_of_async returns runner_result."""
6969
m = runner_result.metrics
70-
summary = GraphMetricSummary(
70+
summary = AIGraphMetricSummary(
7171
success=m.success,
7272
path=list(m.path),
7373
duration_ms=m.duration_ms,
@@ -104,7 +104,7 @@ def test_managed_agent_graph_get_runner():
104104

105105
@pytest.mark.asyncio
106106
async def test_managed_agent_graph_run_surfaces_graph_metrics():
107-
"""GraphMetrics fields are reflected in GraphMetricSummary."""
107+
"""AIGraphMetrics fields are reflected in AIGraphMetricSummary."""
108108
runner = StubRunnerWithMetrics("final answer")
109109
runner_result = await runner.run("test input")
110110

@@ -214,7 +214,7 @@ async def run(self, input) -> AgentGraphRunnerResult:
214214
return AgentGraphRunnerResult(
215215
content='',
216216
raw=None,
217-
metrics=GraphMetrics(success=False, duration_ms=5),
217+
metrics=AIGraphMetrics(success=False, duration_ms=5),
218218
)
219219

220220
failing_runner = FailingRunner()

0 commit comments

Comments
 (0)