Spaces:
Running
Running
import os | |
from apis.LangSmith import LangSmithAPI | |
from dotenv import load_dotenv | |
load_dotenv() | |
# Convert DAILY_LIMIT to int with a default value of 0 | |
DAILY_LIMIT = int(os.getenv("DAILY_MESSAGES_LIMIT", "0")) | |
if(DAILY_LIMIT > 0): | |
langsmith = LangSmithAPI() | |
count = langsmith.getDailyMessages() | |
def daily_limit_enabled(): | |
return DAILY_LIMIT > 0 | |
def is_usage_limit_reached(): | |
return count >= DAILY_LIMIT | |
def get_usages(): | |
return { | |
"count": count, | |
"daily_limit": DAILY_LIMIT | |
} |