XThomasBU
commited on
Commit
·
0d2ffa9
1
Parent(s):
b858421
initial logic
Browse files- apps/ai_tutor/helpers.py +4 -1
apps/ai_tutor/helpers.py
CHANGED
@@ -68,7 +68,10 @@ 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 |
-
|
|
|
|
|
|
|
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 |
+
# If current_tokens is close to 0, then the regeneration rate is relatively high, and if current_tokens is close to max_tokens, then the regeneration rate is relatively low
|
72 |
+
regeneration_rate_per_second = (
|
73 |
+
max_tokens - max(current_tokens, 0)
|
74 |
+
) / REGEN_TIME
|
75 |
|
76 |
# Calculate how many tokens should have been regenerated based on the elapsed time
|
77 |
tokens_to_regenerate = int(
|