Spaces:
Build error
Build error
Farid Karimli
commited on
Commit
·
562f13e
1
Parent(s):
5b69151
token regen patch and bug fix
Browse files- apps/ai_tutor/app.py +1 -1
- apps/ai_tutor/helpers.py +1 -1
apps/ai_tutor/app.py
CHANGED
|
@@ -235,7 +235,7 @@ async def cooldown(request: Request):
|
|
| 235 |
user_details = await get_user_details(user_info["email"])
|
| 236 |
current_datetime = get_time()
|
| 237 |
cooldown, cooldown_end_time = await check_user_cooldown(
|
| 238 |
-
user_details, current_datetime
|
| 239 |
)
|
| 240 |
print(f"User in cooldown: {cooldown}")
|
| 241 |
print(f"Cooldown end time: {cooldown_end_time}")
|
|
|
|
| 235 |
user_details = await get_user_details(user_info["email"])
|
| 236 |
current_datetime = get_time()
|
| 237 |
cooldown, cooldown_end_time = await check_user_cooldown(
|
| 238 |
+
user_details, current_datetime, COOLDOWN_TIME, TOKENS_LEFT, REGEN_TIME
|
| 239 |
)
|
| 240 |
print(f"User in cooldown: {cooldown}")
|
| 241 |
print(f"Cooldown end time: {cooldown_end_time}")
|
apps/ai_tutor/helpers.py
CHANGED
|
@@ -68,7 +68,7 @@ async def reset_tokens_for_user(user_info, TOKENS_LEFT, REGEN_TIME):
|
|
| 68 |
# Calculate how many tokens should have been regenerated proportionally
|
| 69 |
if current_tokens < max_tokens:
|
| 70 |
# Calculate the regeneration rate per second based on REGEN_TIME for full regeneration
|
| 71 |
-
regeneration_rate_per_second = max_tokens / REGEN_TIME
|
| 72 |
|
| 73 |
# Calculate how many tokens should have been regenerated based on the elapsed time
|
| 74 |
tokens_to_regenerate = int(
|
|
|
|
| 68 |
# Calculate how many tokens should have been regenerated proportionally
|
| 69 |
if current_tokens < max_tokens:
|
| 70 |
# Calculate the regeneration rate per second based on REGEN_TIME for full regeneration
|
| 71 |
+
regeneration_rate_per_second = (max_tokens - current_tokens) / REGEN_TIME
|
| 72 |
|
| 73 |
# Calculate how many tokens should have been regenerated based on the elapsed time
|
| 74 |
tokens_to_regenerate = int(
|