Spaces:
Running
Running
VladGeekPro commited on
Commit ·
013a9ea
1
Parent(s): f85abb8
ChangedUserThreshold
Browse files- app.py +0 -21
- extractors/user_extractor.py +1 -1
app.py
CHANGED
|
@@ -389,24 +389,6 @@ def process_voice_request(audio_path: str, mode: str, payload: dict[str, Any], d
|
|
| 389 |
return payload
|
| 390 |
|
| 391 |
|
| 392 |
-
def require_auth():
|
| 393 |
-
"""Проверяет авторизацию запроса."""
|
| 394 |
-
expected_token = os.getenv("PYTHON_API_TOKEN", os.getenv("EXPENSE_VOICE_FASTAPI_TOKEN", "")).strip()
|
| 395 |
-
|
| 396 |
-
if not expected_token:
|
| 397 |
-
return None
|
| 398 |
-
|
| 399 |
-
authorization = request.headers.get("Authorization", "")
|
| 400 |
-
if not authorization.startswith("Bearer "):
|
| 401 |
-
return jsonify({"status": "error", "message": "Missing bearer token."}), 401
|
| 402 |
-
|
| 403 |
-
provided = authorization.removeprefix("Bearer ").strip()
|
| 404 |
-
if provided != expected_token:
|
| 405 |
-
return jsonify({"status": "error", "message": "Invalid bearer token."}), 401
|
| 406 |
-
|
| 407 |
-
return None
|
| 408 |
-
|
| 409 |
-
|
| 410 |
def parse_context(raw: str | None) -> dict[str, Any]:
|
| 411 |
"""Парсит JSON контекст."""
|
| 412 |
if not raw:
|
|
@@ -487,9 +469,6 @@ def test_data():
|
|
| 487 |
@app.post("/process-audio")
|
| 488 |
def process_audio():
|
| 489 |
"""Обработка аудио файла."""
|
| 490 |
-
auth_error = require_auth()
|
| 491 |
-
if auth_error:
|
| 492 |
-
return auth_error
|
| 493 |
|
| 494 |
audio = request.files.get("audio")
|
| 495 |
mode = (request.form.get("mode") or "expense").strip()
|
|
|
|
| 389 |
return payload
|
| 390 |
|
| 391 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 392 |
def parse_context(raw: str | None) -> dict[str, Any]:
|
| 393 |
"""Парсит JSON контекст."""
|
| 394 |
if not raw:
|
|
|
|
| 469 |
@app.post("/process-audio")
|
| 470 |
def process_audio():
|
| 471 |
"""Обработка аудио файла."""
|
|
|
|
|
|
|
|
|
|
| 472 |
|
| 473 |
audio = request.files.get("audio")
|
| 474 |
mode = (request.form.get("mode") or "expense").strip()
|
extractors/user_extractor.py
CHANGED
|
@@ -16,7 +16,7 @@ class ExpenseUserExtractor:
|
|
| 16 |
users: list[str],
|
| 17 |
suppliers: list[str],
|
| 18 |
model: Any = None,
|
| 19 |
-
threshold: float = 0.
|
| 20 |
) -> None:
|
| 21 |
self.users = users
|
| 22 |
self.threshold = threshold
|
|
|
|
| 16 |
users: list[str],
|
| 17 |
suppliers: list[str],
|
| 18 |
model: Any = None,
|
| 19 |
+
threshold: float = 0.25,
|
| 20 |
) -> None:
|
| 21 |
self.users = users
|
| 22 |
self.threshold = threshold
|