pull/22259/head
Bowen Liang 10 months ago
parent a1a12320f2
commit d7c9dfecf3

@ -29,7 +29,7 @@ class EnterpriseService:
raise ValueError("No data found.") raise ValueError("No data found.")
try: try:
# parse the UTC timestamp from the response # parse the UTC timestamp from the response
return datetime.fromisoformat(data.replace("Z", "+00:00")) return datetime.fromisoformat(data)
except ValueError as e: except ValueError as e:
raise ValueError(f"Invalid date format: {data}") from e raise ValueError(f"Invalid date format: {data}") from e
@ -40,7 +40,7 @@ class EnterpriseService:
raise ValueError("No data found.") raise ValueError("No data found.")
try: try:
# parse the UTC timestamp from the response # parse the UTC timestamp from the response
return datetime.fromisoformat(data.replace("Z", "+00:00")) return datetime.fromisoformat(data)
except ValueError as e: except ValueError as e:
raise ValueError(f"Invalid date format: {data}") from e raise ValueError(f"Invalid date format: {data}") from e

@ -116,11 +116,11 @@ def test_execute_llm(flask_req_ctx):
mock_usage = LLMUsage( mock_usage = LLMUsage(
prompt_tokens=30, prompt_tokens=30,
prompt_unit_price=Decimal("0.001"), prompt_unit_price=Decimal("0.001"),
prompt_price_unit=Decimal("1000"), prompt_price_unit=Decimal(1000),
prompt_price=Decimal("0.00003"), prompt_price=Decimal("0.00003"),
completion_tokens=20, completion_tokens=20,
completion_unit_price=Decimal("0.002"), completion_unit_price=Decimal("0.002"),
completion_price_unit=Decimal("1000"), completion_price_unit=Decimal(1000),
completion_price=Decimal("0.00004"), completion_price=Decimal("0.00004"),
total_tokens=50, total_tokens=50,
total_price=Decimal("0.00007"), total_price=Decimal("0.00007"),
@ -219,11 +219,11 @@ def test_execute_llm_with_jinja2(flask_req_ctx, setup_code_executor_mock):
mock_usage = LLMUsage( mock_usage = LLMUsage(
prompt_tokens=30, prompt_tokens=30,
prompt_unit_price=Decimal("0.001"), prompt_unit_price=Decimal("0.001"),
prompt_price_unit=Decimal("1000"), prompt_price_unit=Decimal(1000),
prompt_price=Decimal("0.00003"), prompt_price=Decimal("0.00003"),
completion_tokens=20, completion_tokens=20,
completion_unit_price=Decimal("0.002"), completion_unit_price=Decimal("0.002"),
completion_price_unit=Decimal("1000"), completion_price_unit=Decimal(1000),
completion_price=Decimal("0.00004"), completion_price=Decimal("0.00004"),
total_tokens=50, total_tokens=50,
total_price=Decimal("0.00007"), total_price=Decimal("0.00007"),

@ -27,11 +27,11 @@ def create_mock_usage(prompt_tokens: int = 10, completion_tokens: int = 5) -> LL
return LLMUsage( return LLMUsage(
prompt_tokens=prompt_tokens, prompt_tokens=prompt_tokens,
prompt_unit_price=Decimal("0.001"), prompt_unit_price=Decimal("0.001"),
prompt_price_unit=Decimal("1"), prompt_price_unit=Decimal(1),
prompt_price=Decimal(str(prompt_tokens)) * Decimal("0.001"), prompt_price=Decimal(str(prompt_tokens)) * Decimal("0.001"),
completion_tokens=completion_tokens, completion_tokens=completion_tokens,
completion_unit_price=Decimal("0.002"), completion_unit_price=Decimal("0.002"),
completion_price_unit=Decimal("1"), completion_price_unit=Decimal(1),
completion_price=Decimal(str(completion_tokens)) * Decimal("0.002"), completion_price=Decimal(str(completion_tokens)) * Decimal("0.002"),
total_tokens=prompt_tokens + completion_tokens, total_tokens=prompt_tokens + completion_tokens,
total_price=Decimal(str(prompt_tokens)) * Decimal("0.001") + Decimal(str(completion_tokens)) * Decimal("0.002"), total_price=Decimal(str(prompt_tokens)) * Decimal("0.001") + Decimal(str(completion_tokens)) * Decimal("0.002"),

Loading…
Cancel
Save