Skip to content

for low cost, improve print #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion workflowai/core/domain/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def format_output(self) -> str:

# Add run information if available
if self.cost_usd is not None:
output.append(f"Cost: $ {self.cost_usd}")
output.append(f"Cost: $ {self.cost_usd:.5f}")
if self.duration_seconds is not None:
output.append(f"Latency: {self.duration_seconds:.2f}s")

Expand Down
24 changes: 23 additions & 1 deletion workflowai/core/domain/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,29 @@ def test_format_output() -> None:
"message": "hello"
}
==================================================
Cost: $ 0.001
Cost: $ 0.00100
Latency: 1.23s"""

assert run.format_output() == expected


def test_format_output_very_low_cost() -> None:
run = Run[_TestOutput](
id="test-id",
agent_id="agent-1",
schema_id=1,
output=_TestOutput(message="hello"),
duration_seconds=1.23,
cost_usd=4.97625e-05,
)

expected = """\nOutput:
==================================================
{
"message": "hello"
}
==================================================
Cost: $ 0.00005
Latency: 1.23s"""

assert run.format_output() == expected
Expand Down
Loading