Update main.py
Browse files
main.py
CHANGED
@@ -1,5 +1,3 @@
|
|
1 |
-
from __future__ import annotations
|
2 |
-
|
3 |
import os
|
4 |
import re
|
5 |
import random
|
@@ -610,7 +608,7 @@ async def chat_completions(request: ChatRequest, req: Request, api_key: str = De
|
|
610 |
yield f"data: {json.dumps(response_chunk)}\n\n"
|
611 |
|
612 |
# After all chunks are sent, send the final message with finish_reason
|
613 |
-
prompt_tokens = sum(len(msg
|
614 |
completion_tokens = len(assistant_content.split())
|
615 |
total_tokens = prompt_tokens + completion_tokens
|
616 |
estimated_cost = calculate_estimated_cost(prompt_tokens, completion_tokens)
|
|
|
|
|
|
|
1 |
import os
|
2 |
import re
|
3 |
import random
|
|
|
608 |
yield f"data: {json.dumps(response_chunk)}\n\n"
|
609 |
|
610 |
# After all chunks are sent, send the final message with finish_reason
|
611 |
+
prompt_tokens = sum(len(msg['content'].split()) for msg in request.messages)
|
612 |
completion_tokens = len(assistant_content.split())
|
613 |
total_tokens = prompt_tokens + completion_tokens
|
614 |
estimated_cost = calculate_estimated_cost(prompt_tokens, completion_tokens)
|