from dash import dcc, html import feffery_antd_components as fac from flask import session from . import profile, allocate_role from api.modmag import get_model_run_api from config.global_config import ApiBaseUrlConfig # from utils.mod_mag import get_model_run_data import uuid import callbacks.model_c.modmag_c def render(*args, **kwargs): mode_llm_run_data,mode_embed_run_data,mode_rerank_run_data = get_model_run_api() print("*****************model_run_infos") # print("*****************model_run_infos") for item in mode_llm_run_data: item['key'] = str(uuid.uuid4()) # 添加唯一的 key item['actions'] = [ { 'content': '试用', 'type': 'link', 'icon': 'antd-edit' }, { 'content': '终止', 'type': 'link', 'icon': 'antd-delete' }, ] llm_columns = [ { 'dataIndex': 'model_uid', 'title': 'model_uid', 'width': '10%' }, { 'dataIndex': 'model_name', 'title': 'model_name', 'width': '10%' }, { 'dataIndex': 'worker_address', 'title': 'worker_address', 'width': '10%' }, { 'dataIndex': 'GPU_indexs', 'title': 'GPU_indexs', 'width': '10%' }, { 'dataIndex': 'model_size', 'title': 'model_size', 'width': '10%' }, { 'dataIndex': 'model_quant', 'title': 'model_quant', 'width': '10%' }, { 'dataIndex': 'model_replica', 'title': 'model_replica', 'width': '10%' }, { 'dataIndex': 'actions', 'title': 'actions', 'width': '15%', 'renderOptions': { 'renderType': 'button' } }, ] for item in mode_embed_run_data: item['key'] = str(uuid.uuid4()) # 添加唯一的 key item['actions'] = [ # { # 'content': '试用', # 'type': 'link', # 'icon': 'antd-edit' # }, { 'content': '终止', 'type': 'link', 'icon': 'antd-delete' }, ] # print(mode_embed_run_data) # 定义表格的列,包括 actions 列的 renderOptions embed_columns = [ { 'dataIndex': 'model_uid', 'title': 'model_uid', 'width': '10%' }, { 'dataIndex': 'model_name', 'title': 'model_name', 'width': '10%' }, { 'dataIndex': 'worker_address', 'title': 'worker_address', 'width': '10%' }, { 'dataIndex': 'GPU_indexs', 'title': 'GPU_indexs', 'width': '10%' }, # { # 'dataIndex': 'model_size', # 'title': 'model_size', # 'width': '10%' # }, # { # 'dataIndex': 'model_quant', # 'title': 'model_quant', # 'width': '10%' # }, { 'dataIndex': 'model_replica', 'title': 'model_replica', 'width': '10%' }, { 'dataIndex': 'actions', 'title': 'actions', 'width': '15%', 'renderOptions': { 'renderType': 'button' } }, ] for item in mode_rerank_run_data: item['key'] = str(uuid.uuid4()) # 添加唯一的 key item['actions'] = [ # { # 'content': '试用', # 'type': 'link', # 'icon': 'antd-edit' # }, { 'content': '终止', 'type': 'link', 'icon': 'antd-delete' }, ] # print(mode_embed_run_data) # 定义表格的列,包括 actions 列的 renderOptions rerank_columns = [ { 'dataIndex': 'model_uid', 'title': 'model_uid', 'width': '10%' }, { 'dataIndex': 'model_name', 'title': 'model_name', 'width': '10%' }, { 'dataIndex': 'worker_address', 'title': 'worker_address', 'width': '10%' }, { 'dataIndex': 'GPU_indexs', 'title': 'GPU_indexs', 'width': '10%' }, # { # 'dataIndex': 'model_size', # 'title': 'model_size', # 'width': '10%' # }, # { # 'dataIndex': 'model_quant', # 'title': 'model_quant', # 'width': '10%' # }, { 'dataIndex': 'model_replica', 'title': 'model_replica', 'width': '10%' }, { 'dataIndex': 'actions', 'title': 'actions', 'width': '15%', 'renderOptions': { 'renderType': 'button' } }, ] return [ dcc.Store(id='mode_llm_run_data', data=mode_llm_run_data), dcc.Store(id='mode_embed_run_data', data=mode_embed_run_data), dcc.Store(id='mode_rerank_run_data', data=mode_rerank_run_data), fac.AntdTabs( items=[ { 'key': f'LLM', 'label': f'LLM', 'children': fac.AntdTable( columns=llm_columns, data=mode_llm_run_data, pagination=False, # 禁用分页 style={ 'cursor': 'pointer', 'width': "100%", 'flex': '1 1 auto', # 分配 flex 比例 'fontSize': '0.8rem', # 减小字体以降低表格行高 }, ) }, { 'key': f'embedding', 'label': f'embedding', 'children': fac.AntdTable( columns=embed_columns, data=mode_embed_run_data, pagination=False, # 禁用分页 style={ 'cursor': 'pointer', 'width': "100%", 'flex': '1 1 auto', # 分配 flex 比例 'fontSize': '0.8rem', # 减小字体以降低表格行高 }, ), }, { 'key': f'rerank', 'label': f'rerank', 'children': fac.AntdTable( columns=rerank_columns, data=mode_rerank_run_data, pagination=False, # 禁用分页 style={ 'cursor': 'pointer', 'width': "100%", 'flex': '1 1 auto', # 分配 flex 比例 'fontSize': '0.8rem', # 减小字体以降低表格行高 }, ), }, ], style={'fontSize': 40}, size = 'large', centered=True, ) ]