Skip to content

Commit 73e42a8

Browse files
LBWhite55HaiHui886
authored andcommitted
fix the bug of #84.undefined model_name
1 parent f08e5a5 commit 73e42a8

File tree

1 file changed

+5
-26
lines changed

1 file changed

+5
-26
lines changed

data_server/api/endpoints/model_validator.py

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -264,38 +264,17 @@ def list_models(
264264
# Send request
265265
response = requests.get(api_url, params=params, timeout=30)
266266
response.raise_for_status()
267-
data = response.json()
268-
269-
# Extract required fields
270-
models_data = []
271-
if data.get('data'):
272-
for model in data['data']:
273-
# Find the first tag with category == "task" and get its show_name
274-
first_tag_show_name = ''
275-
if model.get('tags'):
276-
for tag in model['tags']:
277-
if tag.get('category') == 'task':
278-
first_tag_show_name = tag.get('show_name', '')
279-
break
280-
281-
model_info = {
282-
'path': model.get('path', ''),
283-
'updated_at': model.get('updated_at', ''),
284-
'first_tag': first_tag_show_name,
285-
'downloads': model.get('downloads', 0),
286-
'description': model.get('description', '')
287-
}
288-
models_data.append(model_info)
267+
api_data = response.json()
289268

290-
# Build result
269+
# Build result in the required format
291270
result = {
292-
'models': models_data,
293-
'total': data.get('total', 0),
271+
'models': api_data.get('data', []), # All model data from API
272+
'total': api_data.get('total', 0),
294273
'page': page,
295274
'per_page': per_page
296275
}
297276

298-
logger.info(f'Successfully fetched {len(models_data)} models')
277+
logger.info(f'Successfully fetched {len(result["models"])} models')
299278
return response_success(data=result, msg='获取模型列表成功')
300279

301280
except requests.RequestException as e:

0 commit comments

Comments
 (0)