File size: 518 Bytes
5480e8d
 
 
 
 
 
f7289a6
 
5480e8d
f7289a6
 
 
 
 
 
5480e8d
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
    }