from dash import dcc, html import feffery_antd_components as fac from flask import session from . import profile from api.user import get_user_list_api from api.dept import get_dept_tree_api from api.modmag import get_models_detail_api from config.global_config import ApiBaseUrlConfig # import callbacks.system_c.user_c.user_c import callbacks.model_c.modmag_c from utils.common import process_string def render(*args, **kwargs): button_perms = kwargs.get('button_perms') dept_params = dict(dept_name='') user_params = dict(page_num=1, page_size=10) model_type_list = ["LLM","embedding","rerank","image","audio"] tree_data,card_data=get_models_detail_api(model_type_list) # tree_info = get_dept_tree_api(dept_params) print(tree_data) # dcc.Store(id='model-infos', data=card_data) return [ dcc.Store(id='model-infos', data=card_data), fac.AntdDrawer( id="side-drawer", title="侧边示例", placement="right", width=700 ), fac.AntdRow( [ fac.AntdCol( [ fac.AntdInput( id='model-input-search', placeholder='请输入名称', autoComplete='off', allowClear=True, prefix=fac.AntdIcon( icon='antd-search' ), style={ 'width': '85%' } ), fac.AntdTree( id='model-tree', treeData=tree_data, # defaultExpandAll=True, showLine=False, height=900, style={ 'margin-top': '10px', 'fontSize': '18px', 'width': '90%' } ) ], span=4 ), fac.AntdCol( [ fac.AntdRow( [ fac.AntdCol( html.Div( [ fac.AntdForm( [ fac.AntdSpace( [ fac.AntdFormItem( fac.AntdInput( id='model-name-input', placeholder='请输入模型名或者描述', autoComplete='off', allowClear=True, style={ 'width': 500 } ), # label='模型名称' ), fac.AntdFormItem( fac.AntdSelect( id='model-ability-select', placeholder='请选择能力', options=[ { 'label': 'generate', 'value': 'generate' }, { 'label': 'chat', 'value': 'chat' }, { 'label': 'vision', 'value': 'vision' } ], style={ 'width': 220 } ), # label='模型能力' ), fac.AntdFormItem( fac.AntdSelect( id='model-status-select', placeholder='请选择状态', options=[ { 'label': '未缓存', 'value': '0' }, { 'label': '已缓存', 'value': '1' } ], style={ 'width': 220 } ), label='模型状态' ), fac.AntdFormItem( fac.AntdButton( '查询', id='model-search', type='primary', icon=fac.AntdIcon( icon='antd-search' ) ) ), ], style={ 'paddingBottom': '10px', # "width": "100%", 'display': 'flex', 'justifyContent': 'flex-end' } ), ], layout='inline', ) ], id='user-search-form-container', hidden=False ), ) ] ), fac.AntdRow( [ fac.AntdCol( fac.AntdCard( title=item.get('model_name'), children=[ fac.AntdSpace( [ html.Div( fac.AntdCompact([ fac.AntdTag(content=tag) for tag in ( (item['model_flag'].get('model_lang') if isinstance(item['model_flag'].get('model_lang'), list) else [item['model_flag'].get('model_lang')]) + (item['model_flag'].get('model_ability') if isinstance(item['model_flag'].get('model_ability'), list) else [item['model_flag'].get('model_ability')]) + ([str(item['model_flag'].get('context_length'))] if item['model_flag'].get('context_length') is not None else []) ) if tag is not None ]) ), html.Div( process_string(item['model_description']), # style={"marginBottom": "5px"} ), html.Div( fac.AntdCompact( [ fac.AntdButton('查询信息', id={ "type": "card-button", "model_name": item['model_name'], "index": "button1", }, style={'backgroundColor': '#f0f0f0', 'border': 'none', 'marginRight': '1px'} ), fac.AntdButton('接口示例', id={ "type": "card-button", "model_name": item['model_name'], "index": "button2", }, style={'backgroundColor': '#f0f0f0', 'border': 'none', 'marginRight': '1px'} ), fac.AntdButton('部署模型', id={ "type": "card-button", "model_name": item['model_name'], "index": "button3", }, style={'backgroundColor': '#f0f0f0', 'border': 'none'} ), ] ) ), ], align='start', direction='vertical', ), ], hoverable=True, style={"marginBottom": "5px", "width": "100%", "height": "210px"}, headStyle={"width": "100%"}, ), span=8, style={ "width": "100%", # "marginTop": "-1px" }, ) for item in card_data ], gutter=[25, 25], id='card-container' ), ], span=20, style={ "height": "700px", "marginTop": "-1px" }, ) ], gutter=5 ), ]