Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,7 +16,7 @@ if not HF_TOKEN:
|
|
| 16 |
raise ValueError("请设置 HF_TOKEN 环境变量(Settings → Secrets)")
|
| 17 |
|
| 18 |
# ⚠️ 关键修改:直接使用 Hugging Face 官方 Inference API
|
| 19 |
-
# 无需部署 Endpoint,支持
|
| 20 |
INFERENCE_API_BASE_URL = "https://api-inference.huggingface.co/v1"
|
| 21 |
|
| 22 |
# 添加调试模式
|
|
@@ -127,11 +127,11 @@ def extract_json_from_response(response_text):
|
|
| 127 |
# =======================
|
| 128 |
# 工具函数:调用模型
|
| 129 |
# =======================
|
| 130 |
-
def query_model(prompt, model_name="Qwen/Qwen3-4B-Thinking-2507
|
| 131 |
"""
|
| 132 |
通用模型调用函数。
|
| 133 |
:param prompt: 输入提示词
|
| 134 |
-
:param model_name: 要调用的完整模型ID,例如 "Qwen/Qwen3-4B-Thinking-2507
|
| 135 |
:return: 模型生成的文本
|
| 136 |
"""
|
| 137 |
try:
|
|
@@ -146,16 +146,16 @@ def query_model(prompt, model_name="Qwen/Qwen3-4B-Thinking-2507:nscale"):
|
|
| 146 |
|
| 147 |
# 添加模型名称验证和备用模型
|
| 148 |
available_models = [
|
| 149 |
-
"Qwen/Qwen3-4B-Thinking-2507
|
| 150 |
-
"Qwen/Qwen2.5-7B-Instruct
|
| 151 |
-
"meta-llama/Llama-3.1-8B-Instruct
|
| 152 |
-
"mistralai/Mistral-Nemo-Instruct-2407
|
| 153 |
]
|
| 154 |
|
| 155 |
# 如果指定的模型不在可用列表中,使用默认模型
|
| 156 |
if model_name not in available_models:
|
| 157 |
print(f"警告: 模型 {model_name} 不在推荐列表中,将使用默认模型")
|
| 158 |
-
model_name = "Qwen/Qwen3-4B-Thinking-2507
|
| 159 |
|
| 160 |
try:
|
| 161 |
debug_print(f"正在调用模型: {model_name}")
|
|
|
|
| 16 |
raise ValueError("请设置 HF_TOKEN 环境变量(Settings → Secrets)")
|
| 17 |
|
| 18 |
# ⚠️ 关键修改:直接使用 Hugging Face 官方 Inference API
|
| 19 |
+
# 无需部署 Endpoint,支持 后缀
|
| 20 |
INFERENCE_API_BASE_URL = "https://api-inference.huggingface.co/v1"
|
| 21 |
|
| 22 |
# 添加调试模式
|
|
|
|
| 127 |
# =======================
|
| 128 |
# 工具函数:调用模型
|
| 129 |
# =======================
|
| 130 |
+
def query_model(prompt, model_name="Qwen/Qwen3-4B-Thinking-2507"):
|
| 131 |
"""
|
| 132 |
通用模型调用函数。
|
| 133 |
:param prompt: 输入提示词
|
| 134 |
+
:param model_name: 要调用的完整模型ID,例如 "Qwen/Qwen3-4B-Thinking-2507"
|
| 135 |
:return: 模型生成的文本
|
| 136 |
"""
|
| 137 |
try:
|
|
|
|
| 146 |
|
| 147 |
# 添加模型名称验证和备用模型
|
| 148 |
available_models = [
|
| 149 |
+
"Qwen/Qwen3-4B-Thinking-2507",
|
| 150 |
+
"Qwen/Qwen2.5-7B-Instruct",
|
| 151 |
+
"meta-llama/Llama-3.1-8B-Instruct",
|
| 152 |
+
"mistralai/Mistral-Nemo-Instruct-2407"
|
| 153 |
]
|
| 154 |
|
| 155 |
# 如果指定的模型不在可用列表中,使用默认模型
|
| 156 |
if model_name not in available_models:
|
| 157 |
print(f"警告: 模型 {model_name} 不在推荐列表中,将使用默认模型")
|
| 158 |
+
model_name = "Qwen/Qwen3-4B-Thinking-2507"
|
| 159 |
|
| 160 |
try:
|
| 161 |
debug_print(f"正在调用模型: {model_name}")
|