Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,6 +11,24 @@ from huggingface_hub import hf_hub_download
|
|
| 11 |
from typing import List, Dict, Tuple, Optional
|
| 12 |
import numpy as np
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
# ==================== 配置區 ====================
|
| 15 |
HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
| 16 |
DATASET_REPO_ID = "Paul720810/Text-to-SQL-Softline"
|
|
@@ -350,19 +368,6 @@ with gr.Blocks(theme=gr.themes.Soft(), title="Text-to-SQL 智能查詢系統") a
|
|
| 350 |
inputs=[question_input],
|
| 351 |
outputs=[sql_output, status_output, log_output]
|
| 352 |
)
|
| 353 |
-
|
| 354 |
-
from huggingface_hub import InferenceClient
|
| 355 |
-
import os
|
| 356 |
-
|
| 357 |
-
# 測試列出目前 Hugging Face 免費 API 已部署的模型
|
| 358 |
-
try:
|
| 359 |
-
client = InferenceClient(token=os.environ.get("HF_TOKEN"))
|
| 360 |
-
deployed = client.list_deployed_models("text-generation-inference")
|
| 361 |
-
print("🔍 已部署的 text-generation 模型:")
|
| 362 |
-
for m in deployed.get("text-generation", []):
|
| 363 |
-
print(" -", m)
|
| 364 |
-
except Exception as e:
|
| 365 |
-
print("⚠️ 查詢已部署模型失敗:", e)
|
| 366 |
|
| 367 |
if __name__ == "__main__":
|
| 368 |
if text_to_sql_system:
|
|
|
|
| 11 |
from typing import List, Dict, Tuple, Optional
|
| 12 |
import numpy as np
|
| 13 |
|
| 14 |
+
from huggingface_hub import HfApi
|
| 15 |
+
|
| 16 |
+
api = HfApi()
|
| 17 |
+
|
| 18 |
+
# 列出 Hugging Face 免費 serverless (inference endpoint) 已 warm 的模型
|
| 19 |
+
models = api.list_models(
|
| 20 |
+
filter="text-generation",
|
| 21 |
+
inference="warm", # 只要已 warm 的
|
| 22 |
+
sort="downloads",
|
| 23 |
+
direction=-1,
|
| 24 |
+
limit=20
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
print("🔥 可用的 warm 模型 (前 20):")
|
| 28 |
+
for m in models:
|
| 29 |
+
print(" -", m.modelId)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
# ==================== 配置區 ====================
|
| 33 |
HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
| 34 |
DATASET_REPO_ID = "Paul720810/Text-to-SQL-Softline"
|
|
|
|
| 368 |
inputs=[question_input],
|
| 369 |
outputs=[sql_output, status_output, log_output]
|
| 370 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 371 |
|
| 372 |
if __name__ == "__main__":
|
| 373 |
if text_to_sql_system:
|