Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ Maria AI Tutor — FastAPI Backend
|
|
| 3 |
Hugging Face Spaces (Docker)
|
| 4 |
"""
|
| 5 |
|
| 6 |
-
import os, io, re, json, base64, logging, wave, struct, urllib.request
|
| 7 |
from contextlib import asynccontextmanager
|
| 8 |
from typing import Optional, List, Dict, Any
|
| 9 |
|
|
@@ -258,7 +258,7 @@ def _ensure_faiss(board: str, cls: str, subject: str):
|
|
| 258 |
if key in _faiss:
|
| 259 |
return _faiss[key], _meta[key]
|
| 260 |
try:
|
| 261 |
-
base =
|
| 262 |
headers = {"Authorization": f"Bearer {HF_TOKEN}"} if HF_TOKEN else {}
|
| 263 |
|
| 264 |
def _download(url: str, dest: str):
|
|
@@ -698,4 +698,4 @@ async def chatmessenger(request: Request, body: ChatRequest):
|
|
| 698 |
raise HTTPException(status_code=403, detail="Authentication required")
|
| 699 |
|
| 700 |
result = process(body)
|
| 701 |
-
return result.model_dump(by_alias=True)
|
|
|
|
| 3 |
Hugging Face Spaces (Docker)
|
| 4 |
"""
|
| 5 |
|
| 6 |
+
import os, io, re, json, base64, logging, wave, struct, urllib.request, urllib.parse
|
| 7 |
from contextlib import asynccontextmanager
|
| 8 |
from typing import Optional, List, Dict, Any
|
| 9 |
|
|
|
|
| 258 |
if key in _faiss:
|
| 259 |
return _faiss[key], _meta[key]
|
| 260 |
try:
|
| 261 |
+
base = "{}/knowledgebase/{}/{}/{}".format(DATASET_BASE_URL, urllib.parse.quote(board, safe=""), urllib.parse.quote(cls, safe=""), urllib.parse.quote(subject, safe=""))
|
| 262 |
headers = {"Authorization": f"Bearer {HF_TOKEN}"} if HF_TOKEN else {}
|
| 263 |
|
| 264 |
def _download(url: str, dest: str):
|
|
|
|
| 698 |
raise HTTPException(status_code=403, detail="Authentication required")
|
| 699 |
|
| 700 |
result = process(body)
|
| 701 |
+
return result.model_dump(by_alias=True)
|