JC321 commited on
Commit
c9bd1a2
·
verified ·
1 Parent(s): 53cf0bf

Upload 3 files

Browse files
Files changed (1) hide show
  1. app.py +6 -5
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
- # Hugging Face Space 环境变量读取 token
41
- # HF Space 设置中配置 HF_TOKEN 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
  else:
47
- print("⚠️ HF_TOKEN not found in environment variables")
48
- print("ℹ️ Please add HF_TOKEN in your Hugging Face Space Settings > Repository secrets")
49
- client = None
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