fix: skip logging to db during tests

This commit is contained in:
Siddhant Rai 2024-04-16 01:08:39 +05:30
parent 77991896b4
commit 1b61337b75

View File

@ -1,3 +1,4 @@
import sys
from pymongo import MongoClient
from datetime import datetime
from application.core.settings import settings
@ -9,6 +10,8 @@ usage_collection = db["token_usage"]
def update_token_usage(api_key, token_usage):
if "pytest" in sys.modules:
return
usage_data = {
"api_key": api_key,
"prompt_tokens": token_usage["prompt_tokens"],