updates
Browse files
app.py
CHANGED
|
@@ -8,6 +8,9 @@ from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
|
| 8 |
from typing import List
|
| 9 |
from collections import Counter
|
| 10 |
from fastapi.staticfiles import StaticFiles
|
|
|
|
|
|
|
|
|
|
| 11 |
CURRENT_TAG = os.getenv("MODEL_TAG", "main")
|
| 12 |
# ====== FastAPI 初始化 ======
|
| 13 |
app = FastAPI(
|
|
@@ -223,9 +226,6 @@ def get_model_info():
|
|
| 223 |
# print(f"⚠️ Failed to upload embeddings: {e}")
|
| 224 |
# return False
|
| 225 |
|
| 226 |
-
from huggingface_hub import HfApi, HfHubHTTPError
|
| 227 |
-
import datetime
|
| 228 |
-
|
| 229 |
HF_DATASET_REPO = "lyi029/malvec-embeddings"
|
| 230 |
|
| 231 |
def upload_embeddings_to_hub(local_path: str):
|
|
@@ -239,7 +239,7 @@ def upload_embeddings_to_hub(local_path: str):
|
|
| 239 |
try:
|
| 240 |
api.dataset_info(repo_id=HF_DATASET_REPO, token=HF_TOKEN)
|
| 241 |
print(f"📂 Dataset {HF_DATASET_REPO} 已存在。")
|
| 242 |
-
except
|
| 243 |
if e.response is not None and e.response.status_code == 404:
|
| 244 |
print(f"🆕 Dataset 不存在,建立中...")
|
| 245 |
api.create_repo(repo_id=HF_DATASET_REPO, repo_type="dataset", token=HF_TOKEN)
|
|
@@ -263,7 +263,7 @@ def upload_embeddings_to_hub(local_path: str):
|
|
| 263 |
|
| 264 |
return True
|
| 265 |
|
| 266 |
-
except
|
| 267 |
print(f"❌ HF API HTTP error: {e.response.status_code} - {e.response.text}")
|
| 268 |
return False
|
| 269 |
except Exception as e:
|
|
|
|
| 8 |
from typing import List
|
| 9 |
from collections import Counter
|
| 10 |
from fastapi.staticfiles import StaticFiles
|
| 11 |
+
from huggingface_hub import HfApi
|
| 12 |
+
import datetime
|
| 13 |
+
|
| 14 |
CURRENT_TAG = os.getenv("MODEL_TAG", "main")
|
| 15 |
# ====== FastAPI 初始化 ======
|
| 16 |
app = FastAPI(
|
|
|
|
| 226 |
# print(f"⚠️ Failed to upload embeddings: {e}")
|
| 227 |
# return False
|
| 228 |
|
|
|
|
|
|
|
|
|
|
| 229 |
HF_DATASET_REPO = "lyi029/malvec-embeddings"
|
| 230 |
|
| 231 |
def upload_embeddings_to_hub(local_path: str):
|
|
|
|
| 239 |
try:
|
| 240 |
api.dataset_info(repo_id=HF_DATASET_REPO, token=HF_TOKEN)
|
| 241 |
print(f"📂 Dataset {HF_DATASET_REPO} 已存在。")
|
| 242 |
+
except Exception as e:
|
| 243 |
if e.response is not None and e.response.status_code == 404:
|
| 244 |
print(f"🆕 Dataset 不存在,建立中...")
|
| 245 |
api.create_repo(repo_id=HF_DATASET_REPO, repo_type="dataset", token=HF_TOKEN)
|
|
|
|
| 263 |
|
| 264 |
return True
|
| 265 |
|
| 266 |
+
except Exception as e:
|
| 267 |
print(f"❌ HF API HTTP error: {e.response.status_code} - {e.response.text}")
|
| 268 |
return False
|
| 269 |
except Exception as e:
|