Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files
app.py
CHANGED
|
@@ -37,16 +37,17 @@ session = create_session_with_retry()
|
|
| 37 |
# 初始化 Hugging Face Inference Client
|
| 38 |
# 使用 Qwen/Qwen2.5-VL-72B-Instruct:nebius 模型(更强大的视觉语言模型)
|
| 39 |
try:
|
| 40 |
-
#
|
| 41 |
-
#
|
| 42 |
hf_token = os.environ.get("HF_TOKEN")
|
| 43 |
if hf_token:
|
| 44 |
client = InferenceClient(api_key=hf_token)
|
| 45 |
print(f"✅ Hugging Face client initialized with Qwen/Qwen2.5-VL-72B-Instruct:nebius model")
|
|
|
|
| 46 |
else:
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
except Exception as e:
|
| 51 |
print(f"❌ Warning: Failed to initialize Hugging Face client: {e}")
|
| 52 |
client = None
|
|
|
|
| 37 |
# 初始化 Hugging Face Inference Client
|
| 38 |
# 使用 Qwen/Qwen2.5-VL-72B-Instruct:nebius 模型(更强大的视觉语言模型)
|
| 39 |
try:
|
| 40 |
+
# Hugging Face Space 会自动提供 HF_TOKEN 环境变量
|
| 41 |
+
# 无需手动配置 Secret!
|
| 42 |
hf_token = os.environ.get("HF_TOKEN")
|
| 43 |
if hf_token:
|
| 44 |
client = InferenceClient(api_key=hf_token)
|
| 45 |
print(f"✅ Hugging Face client initialized with Qwen/Qwen2.5-VL-72B-Instruct:nebius model")
|
| 46 |
+
print(f" Using auto-generated HF Space token")
|
| 47 |
else:
|
| 48 |
+
# 如果没有 token,使用无认证模式(免费层,有限制)
|
| 49 |
+
client = InferenceClient()
|
| 50 |
+
print("⚠️ Using Hugging Face Inference API without authentication (rate limited)")
|
| 51 |
except Exception as e:
|
| 52 |
print(f"❌ Warning: Failed to initialize Hugging Face client: {e}")
|
| 53 |
client = None
|