Skip to content

Commit 4f59a08

Browse files
author
Pierre
committed
for low cost, improve print
avoid the scientific notation. before: $ 4.97625e-05 after: $ 0.00005
1 parent b52d756 commit 4f59a08

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

workflowai/core/domain/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def format_output(self) -> str:
110110

111111
# Add run information if available
112112
if self.cost_usd is not None:
113-
output.append(f"Cost: $ {self.cost_usd}")
113+
output.append(f"Cost: $ {self.cost_usd:.5f}")
114114
if self.duration_seconds is not None:
115115
output.append(f"Latency: {self.duration_seconds:.2f}s")
116116

workflowai/core/domain/run_test.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,29 @@ def test_format_output() -> None:
6767
"message": "hello"
6868
}
6969
==================================================
70-
Cost: $ 0.001
70+
Cost: $ 0.00100
71+
Latency: 1.23s"""
72+
73+
assert run.format_output() == expected
74+
75+
76+
def test_format_output_very_low_cost() -> None:
77+
run = Run[_TestOutput](
78+
id="test-id",
79+
agent_id="agent-1",
80+
schema_id=1,
81+
output=_TestOutput(message="hello"),
82+
duration_seconds=1.23,
83+
cost_usd=4.97625e-05,
84+
)
85+
86+
expected = """\nOutput:
87+
==================================================
88+
{
89+
"message": "hello"
90+
}
91+
==================================================
92+
Cost: $ 0.00005
7193
Latency: 1.23s"""
7294

7395
assert run.format_output() == expected

0 commit comments

Comments
 (0)