Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
85c456afe0 | ||
|
|
b3b52848c2 | ||
|
|
d6e9f2e7a0 | ||
|
|
821edbc8f5 |
19
main.py
19
main.py
@@ -121,12 +121,12 @@ def init_db():
|
||||
# ModelScope 搜索
|
||||
# ============================================================
|
||||
|
||||
def search_models(keyword: str, limit: int = 100) -> list:
|
||||
def search_models(keyword: str, limit: int = 50) -> list:
|
||||
"""从 ModelScope 搜索模型"""
|
||||
url = "https://modelscope.cn/openapi/v1/models"
|
||||
params = {
|
||||
'search': keyword,
|
||||
'page_size': limit,
|
||||
'page_size': min(limit, 50), # API 上限 50
|
||||
'page_number': 1,
|
||||
'sort': 'downloads',
|
||||
}
|
||||
@@ -135,7 +135,11 @@ def search_models(keyword: str, limit: int = 100) -> list:
|
||||
headers={'User-Agent': 'Mozilla/5.0'})
|
||||
data = resp.json()
|
||||
if data.get('success'):
|
||||
return data.get('data', {}).get('models', [])
|
||||
models = data.get('data', {}).get('models', [])
|
||||
log(f" 搜索 [{keyword}]: status={resp.status_code} models={len(models)}")
|
||||
return models
|
||||
else:
|
||||
log(f" 搜索 [{keyword}]: success=false, data={str(data)[:200]}")
|
||||
except Exception as e:
|
||||
log(f" 搜索失败 [{keyword}]: {e}")
|
||||
return []
|
||||
@@ -191,7 +195,8 @@ def check_platform_verify(model_id: str) -> dict:
|
||||
resp = requests.get(url, headers=headers, params={'modelId': model_id}, timeout=10)
|
||||
data = resp.json()
|
||||
if data.get('code') == 0:
|
||||
return data.get('data', {}).get('verifyResult', {})
|
||||
result = data.get('data', {}).get('verifyResult', {})
|
||||
return result if isinstance(result, dict) else {}
|
||||
except Exception:
|
||||
pass
|
||||
return {}
|
||||
@@ -297,9 +302,7 @@ def build_config_params(gpu: str) -> str:
|
||||
'gpu_num': 1,
|
||||
'command': [
|
||||
'/bin/bash', '-ic',
|
||||
'vllm serve /model --port 8000 --served-model-name llm '
|
||||
'--max-model-len 2048 --dtype auto --gpu-memory-utilization 0.95 '
|
||||
'-tp 1 --enforce-eager --trust-remote-code'
|
||||
'vllm serve /model --port 8000 --served-model-name llm --max-model-len 2048 --dtype auto --gpu-memory-utilization 0.95 -tp 1 --enforce-eager --trust-remote-code'
|
||||
]
|
||||
}
|
||||
},
|
||||
@@ -316,7 +319,7 @@ def build_config_params(gpu: str) -> str:
|
||||
},
|
||||
'model': 'llm',
|
||||
}
|
||||
return yaml.dump(params, default_flow_style=False, allow_unicode=True)
|
||||
return yaml.dump(params, default_flow_style=False, allow_unicode=True, width=1000)
|
||||
|
||||
|
||||
def submit_model(model_url: str, gpu: str, token: str) -> tuple:
|
||||
|
||||
Reference in New Issue
Block a user