Skip to content

Commit 3c77d76

Browse files
committed
re-order track_metrics_of params to be more intuitive
1 parent 07c5454 commit 3c77d76

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

ldai/chat/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ async def invoke(self, prompt: str) -> ChatResponse:
6262

6363
# Delegate to provider-specific implementation with tracking
6464
response = await self._tracker.track_metrics_of(
65-
lambda result: result.metrics,
6665
lambda: self._provider.invoke_model(all_messages),
66+
lambda result: result.metrics,
6767
)
6868

6969
# Start judge evaluations as async tasks (don't await them)

ldai/judge/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ async def evaluate(
8080

8181
# Track metrics of the structured model invocation
8282
response = await self._ai_config_tracker.track_metrics_of(
83+
lambda: self._ai_provider.invoke_structured_model(messages, self._evaluation_response_structure),
8384
lambda result: result.metrics,
84-
lambda: self._ai_provider.invoke_structured_model(messages, self._evaluation_response_structure)
8585
)
8686

8787
success = response.metrics.success

ldai/tracker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def track_duration_of(self, func):
157157

158158
return result
159159

160-
async def track_metrics_of(self, metrics_extractor, func):
160+
async def track_metrics_of(self, func, metrics_extractor):
161161
"""
162162
Track metrics for a generic AI operation.
163163
@@ -168,8 +168,8 @@ async def track_metrics_of(self, metrics_extractor, func):
168168
In the case the provided function throws, this function will record the duration and an error.
169169
A failed operation will not have any token usage data.
170170
171-
:param metrics_extractor: Function that extracts LDAIMetrics from the operation result
172171
:param func: Async function which executes the operation
172+
:param metrics_extractor: Function that extracts LDAIMetrics from the operation result
173173
:return: The result of the operation
174174
"""
175175
start_time = time.time()

0 commit comments

Comments
 (0)