60 lines
2.3 KiB
Python
60 lines
2.3 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
简单检查API状态
|
|
"""
|
|
import urllib.request
|
|
import json
|
|
|
|
def simple_check():
|
|
try:
|
|
print("=== API状态检查 ===")
|
|
|
|
# 检查主端点
|
|
url = 'http://localhost:5000/api/models'
|
|
with urllib.request.urlopen(url) as response:
|
|
print(f"主端点状态: {response.status}")
|
|
data = response.read().decode('utf-8')
|
|
result = json.loads(data)
|
|
models = result.get('data', [])
|
|
|
|
if models:
|
|
model = models[0]
|
|
has_filename = 'filename' in model and model['filename']
|
|
has_model_id = model.get('model_id', '') != ''
|
|
|
|
print(f"模型数量: {len(models)}")
|
|
print(f"第一个模型有filename: {has_filename}")
|
|
print(f"第一个模型有model_id: {has_model_id}")
|
|
|
|
if not has_filename:
|
|
print("ERROR: API未使用最新代码 - filename字段缺失")
|
|
if not has_model_id:
|
|
print("ERROR: model_id为空 - 这会导致删除404错误")
|
|
|
|
# 检查测试端点
|
|
try:
|
|
test_url = 'http://localhost:5000/api/models/test'
|
|
with urllib.request.urlopen(test_url) as response:
|
|
print(f"测试端点状态: {response.status}")
|
|
data = response.read().decode('utf-8')
|
|
result = json.loads(data)
|
|
print(f"测试端点找到模型: {result.get('models_found', 0)} 个")
|
|
|
|
if result.get('models_found', 0) > 0:
|
|
test_model = result['models'][0]
|
|
print(f"测试端点model_id: '{test_model.get('model_id', 'MISSING')}'")
|
|
|
|
except urllib.error.HTTPError as e:
|
|
print(f"测试端点错误: {e.code} (可能不存在)")
|
|
|
|
print("\n=== 解决方案 ===")
|
|
print("1. 完全停止API服务器 (Ctrl+C)")
|
|
print("2. 等待5秒")
|
|
print("3. 重新启动: uv run ./server/api.py")
|
|
print("4. 检查控制台是否有 'DEBUG: 模型管理器目录' 输出")
|
|
|
|
except Exception as e:
|
|
print(f"检查失败: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
simple_check() |