Update app.py
Browse files
app.py
CHANGED
|
@@ -10,8 +10,6 @@ import os
|
|
| 10 |
import sys
|
| 11 |
import time
|
| 12 |
import uuid
|
| 13 |
-
from contextlib import asynccontextmanager
|
| 14 |
-
from dataclasses import dataclass, field
|
| 15 |
from typing import Any, Dict, List, Optional, Tuple
|
| 16 |
|
| 17 |
import aiosqlite
|
|
@@ -409,16 +407,17 @@ async def deepseek_chat_complete(messages: list, body: ChatCompletionRequest) ->
|
|
| 409 |
|
| 410 |
return "".join(text_parts), "".join(thinking_parts) or None
|
| 411 |
|
| 412 |
-
# βββ
|
| 413 |
class RateLimitEntry:
|
| 414 |
-
|
| 415 |
-
|
|
|
|
| 416 |
|
| 417 |
class Services:
|
| 418 |
def __init__(self):
|
| 419 |
-
self._rate_limits
|
| 420 |
self._lock = asyncio.Lock()
|
| 421 |
-
self._cleanup_task
|
| 422 |
|
| 423 |
async def init_db(self):
|
| 424 |
async with aiosqlite.connect(CONFIG["db_path"]) as db:
|
|
|
|
| 10 |
import sys
|
| 11 |
import time
|
| 12 |
import uuid
|
|
|
|
|
|
|
| 13 |
from typing import Any, Dict, List, Optional, Tuple
|
| 14 |
|
| 15 |
import aiosqlite
|
|
|
|
| 407 |
|
| 408 |
return "".join(text_parts), "".join(thinking_parts) or None
|
| 409 |
|
| 410 |
+
# βββ Rate Limiting (Ω
ΨΉΨ―Ω Ψ¨Ψ―ΩΩ dataclasses) βββββββββββββββββββββββββββββββββ
|
| 411 |
class RateLimitEntry:
|
| 412 |
+
def __init__(self):
|
| 413 |
+
self.timestamps = []
|
| 414 |
+
self.last_cleanup = time.time()
|
| 415 |
|
| 416 |
class Services:
|
| 417 |
def __init__(self):
|
| 418 |
+
self._rate_limits = {}
|
| 419 |
self._lock = asyncio.Lock()
|
| 420 |
+
self._cleanup_task = None
|
| 421 |
|
| 422 |
async def init_db(self):
|
| 423 |
async with aiosqlite.connect(CONFIG["db_path"]) as db:
|