mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-19 00:01:29 +00:00
add expires_at check to gigachat authenticator
This commit is contained in:
parent
0cc9147f49
commit
4fc3e2e064
1 changed files with 7 additions and 6 deletions
|
|
@ -112,12 +112,13 @@ def get_access_token(
|
|||
# Request new token
|
||||
token, expires_at = _request_token_sync(credentials, scope, auth_url)
|
||||
|
||||
# Cache token
|
||||
ttl_seconds = max(
|
||||
0, (expires_at - TOKEN_EXPIRY_BUFFER_MS - time.time() * 1000) / 1000
|
||||
)
|
||||
if ttl_seconds > 0:
|
||||
_token_cache.set_cache(cache_key, (token, expires_at), ttl=ttl_seconds)
|
||||
if expires_at:
|
||||
# Cache token
|
||||
ttl_seconds = max(
|
||||
0, (expires_at - TOKEN_EXPIRY_BUFFER_MS - time.time() * 1000) / 1000
|
||||
)
|
||||
if ttl_seconds > 0:
|
||||
_token_cache.set_cache(cache_key, (token, expires_at), ttl=ttl_seconds)
|
||||
|
||||
return token
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue