forked from phoenix/litellm-mirror
(fix) SpendLogs Table
This commit is contained in:
parent
12f569ad60
commit
55b95e87dd
5 changed files with 25 additions and 13 deletions
|
@ -281,14 +281,20 @@ async def test_key_info_spend_values():
|
|||
await asyncio.sleep(5)
|
||||
spend_logs = await get_spend_logs(session=session, request_id=response["id"])
|
||||
print(f"spend_logs: {spend_logs}")
|
||||
usage = spend_logs[0]["usage"]
|
||||
completion_tokens = spend_logs[0]["completion_tokens"]
|
||||
prompt_tokens = spend_logs[0]["prompt_tokens"]
|
||||
print(f"prompt_tokens: {prompt_tokens}; completion_tokens: {completion_tokens}")
|
||||
|
||||
litellm.set_verbose = True
|
||||
prompt_cost, completion_cost = litellm.cost_per_token(
|
||||
model="gpt-35-turbo",
|
||||
prompt_tokens=usage["prompt_tokens"],
|
||||
completion_tokens=usage["completion_tokens"],
|
||||
prompt_tokens=prompt_tokens,
|
||||
completion_tokens=completion_tokens,
|
||||
custom_llm_provider="azure",
|
||||
)
|
||||
print("prompt_cost: ", prompt_cost, "completion_cost: ", completion_cost)
|
||||
response_cost = prompt_cost + completion_cost
|
||||
print(f"response_cost: {response_cost}")
|
||||
await asyncio.sleep(5) # allow db log to be updated
|
||||
key_info = await get_key_info(session=session, get_key=key, call_key=key)
|
||||
print(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue