Skip to content

Commit 728bb96

Browse files
authored
Fixing a bug where the wall time was added to the on_llm_end function… (#133)
* Fixing a bug where the wall time was added to the on_llm_end function in observability but not on_llm_error * Removing irrelevant comment
1 parent f5b5f95 commit 728bb96

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/ursa/observability/timing.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,14 +745,15 @@ def on_llm_end(self, response, *, run_id, **kwargs):
745745
"metadata": metadata,
746746
"metrics": metrics,
747747
"t_start": wall_t0,
748-
"t_end": wall_t1, # <— add these
748+
"t_end": wall_t1,
749749
})
750750

751751
def on_llm_error(self, error, *, run_id, **kwargs):
752-
name, t0, tags, metadata = self._starts.pop(
752+
name, t0, tags, metadata, wall_t0 = self._starts.pop(
753753
run_id, ("llm:unknown", time.perf_counter(), [], {})
754754
)
755755
ms = (time.perf_counter() - t0) * 1000.0
756+
wall_t1 = time.time()
756757
self.agg.add(name, ms, False)
757758
self.samples.append({
758759
"name": name,
@@ -761,6 +762,8 @@ def on_llm_error(self, error, *, run_id, **kwargs):
761762
"tags": tags,
762763
"metadata": metadata,
763764
"metrics": {"error": repr(error)},
765+
"t_start": wall_t0,
766+
"t_end": wall_t1,
764767
})
765768

766769

0 commit comments

Comments
 (0)