fix: show success message when start model falied
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import AutoTooltip from '@/components/auto-tooltip';
|
||||
import IconFont from '@/components/icon-font';
|
||||
import LabelSelector from '@/components/label-selector';
|
||||
import ListInput from '@/components/list-input';
|
||||
import SealCascader from '@/components/seal-form/seal-cascader';
|
||||
@@ -326,28 +327,35 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
|
||||
<Form.Item name="backend_version">
|
||||
<SealInput.Input
|
||||
label={intl.formatMessage({ id: 'models.form.backendVersion' })}
|
||||
description={intl.formatMessage({
|
||||
id: 'models.form.backendVersion.tips'
|
||||
})}
|
||||
labelExtra={
|
||||
backendParamsTips?.releases && (
|
||||
<span
|
||||
style={{
|
||||
marginLeft: 5
|
||||
}}
|
||||
>
|
||||
(
|
||||
<Typography.Link
|
||||
style={{ lineHeight: 1 }}
|
||||
href={backendParamsTips?.releases}
|
||||
target="_blank"
|
||||
description={intl.formatMessage(
|
||||
{
|
||||
id: 'models.form.backendVersion.tips'
|
||||
},
|
||||
{
|
||||
link: backendParamsTips?.releases && (
|
||||
<span
|
||||
style={{
|
||||
marginLeft: 5
|
||||
}}
|
||||
>
|
||||
{intl.formatMessage({ id: 'models.form.releases' })}
|
||||
</Typography.Link>
|
||||
)
|
||||
</span>
|
||||
)
|
||||
}
|
||||
<Typography.Link
|
||||
className="flex-center"
|
||||
style={{ lineHeight: 1 }}
|
||||
href={backendParamsTips?.releases}
|
||||
target="_blank"
|
||||
>
|
||||
<span>
|
||||
{intl.formatMessage({ id: 'models.form.releases' })}
|
||||
</span>
|
||||
<IconFont
|
||||
type="icon-external-link"
|
||||
className="font-size-14 m-l-4"
|
||||
></IconFont>
|
||||
</Typography.Link>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
)}
|
||||
></SealInput.Input>
|
||||
</Form.Item>
|
||||
|
||||
@@ -367,20 +375,26 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
|
||||
dataList={form.getFieldValue('backend_parameters') || []}
|
||||
onChange={handleBackendParametersChange}
|
||||
options={paramsConfig}
|
||||
labelExtra={
|
||||
backendParamsTips?.link && (
|
||||
<span style={{ marginLeft: 5 }}>
|
||||
(
|
||||
description={
|
||||
backendParamsTips && (
|
||||
<span>
|
||||
{intl.formatMessage(
|
||||
{ id: 'models.form.backend_parameters.vllm.tips' },
|
||||
{ backend: backendParamsTips.backend || '' }
|
||||
)}{' '}
|
||||
<Typography.Link
|
||||
style={{ lineHeight: 1 }}
|
||||
href={backendParamsTips?.link}
|
||||
className="flex-center"
|
||||
href={backendParamsTips.link}
|
||||
target="_blank"
|
||||
>
|
||||
{intl.formatMessage({
|
||||
id: 'models.form.moreparameters'
|
||||
})}
|
||||
<span>
|
||||
{intl.formatMessage({ id: 'common.text.here' })}
|
||||
</span>
|
||||
<IconFont
|
||||
type="icon-external-link"
|
||||
className="font-size-14 m-l-4"
|
||||
></IconFont>
|
||||
</Typography.Link>
|
||||
)
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import TooltipList from '@/components/tooltip-list';
|
||||
import { PageAction } from '@/config';
|
||||
import { PageActionType } from '@/config/types';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Form, Tooltip, Typography } from 'antd';
|
||||
import { Form, Typography } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import React, {
|
||||
forwardRef,
|
||||
@@ -300,25 +300,24 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
|
||||
defaultActiveFirstOption
|
||||
disabled={false}
|
||||
options={ollamaModelOptions}
|
||||
label={
|
||||
<>
|
||||
{intl.formatMessage({ id: 'model.form.ollama.model' })}{' '}
|
||||
description={
|
||||
<span>
|
||||
<span>
|
||||
{intl.formatMessage({ id: 'models.form.ollamalink' })}
|
||||
</span>
|
||||
<Typography.Link
|
||||
className="flex-center"
|
||||
href="https://www.ollama.com/library"
|
||||
target="_blank"
|
||||
>
|
||||
<Tooltip
|
||||
title={intl.formatMessage({ id: 'models.form.ollamalink' })}
|
||||
placement="topRight"
|
||||
>
|
||||
<IconFont
|
||||
type="icon-external-link"
|
||||
className="font-size-14"
|
||||
></IconFont>
|
||||
</Tooltip>
|
||||
<IconFont
|
||||
type="icon-external-link"
|
||||
className="font-size-14"
|
||||
></IconFont>
|
||||
</Typography.Link>
|
||||
</>
|
||||
</span>
|
||||
}
|
||||
label={intl.formatMessage({ id: 'model.form.ollama.model' })}
|
||||
placeholder={intl.formatMessage({ id: 'model.form.ollamaholder' })}
|
||||
required
|
||||
></SealAutoComplete>
|
||||
|
||||
@@ -248,6 +248,7 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
ellipsis={false}
|
||||
message={
|
||||
<span
|
||||
style={{}}
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: intl.formatMessage({
|
||||
id: warningStatus.message
|
||||
|
||||
@@ -403,44 +403,36 @@ const Models: React.FC<ModelsProps> = ({
|
||||
}, []);
|
||||
|
||||
const handleStartModel = async (row: ListItem) => {
|
||||
try {
|
||||
await updateModel({
|
||||
id: row.id,
|
||||
data: {
|
||||
..._.omit(row, [
|
||||
'id',
|
||||
'ready_replicas',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'rowIndex'
|
||||
]),
|
||||
replicas: 1
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
// ingore
|
||||
}
|
||||
await updateModel({
|
||||
id: row.id,
|
||||
data: {
|
||||
..._.omit(row, [
|
||||
'id',
|
||||
'ready_replicas',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'rowIndex'
|
||||
]),
|
||||
replicas: 1
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const handleStopModel = async (row: ListItem) => {
|
||||
try {
|
||||
await updateModel({
|
||||
id: row.id,
|
||||
data: {
|
||||
..._.omit(row, [
|
||||
'id',
|
||||
'ready_replicas',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'rowIndex'
|
||||
]),
|
||||
replicas: 0
|
||||
}
|
||||
});
|
||||
removeExpandedRowKey([row.id]);
|
||||
} catch (error) {
|
||||
// ingore
|
||||
}
|
||||
await updateModel({
|
||||
id: row.id,
|
||||
data: {
|
||||
..._.omit(row, [
|
||||
'id',
|
||||
'ready_replicas',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'rowIndex'
|
||||
]),
|
||||
replicas: 0
|
||||
}
|
||||
});
|
||||
removeExpandedRowKey([row.id]);
|
||||
};
|
||||
|
||||
const handleModalOk = useCallback(
|
||||
@@ -639,32 +631,36 @@ const Models: React.FC<ModelsProps> = ({
|
||||
|
||||
const handleSelect = useCallback(
|
||||
async (val: any, row: ListItem) => {
|
||||
if (val === 'edit') {
|
||||
handleEdit(row);
|
||||
}
|
||||
if (val === 'chat') {
|
||||
handleOpenPlayGround(row);
|
||||
}
|
||||
if (val === 'delete') {
|
||||
handleDelete(row);
|
||||
}
|
||||
if (val === 'start') {
|
||||
await handleStartModel(row);
|
||||
message.success(intl.formatMessage({ id: 'common.message.success' }));
|
||||
updateExpandedRowKeys([row.id, ...expandedRowKeys]);
|
||||
}
|
||||
try {
|
||||
if (val === 'edit') {
|
||||
handleEdit(row);
|
||||
}
|
||||
if (val === 'chat') {
|
||||
handleOpenPlayGround(row);
|
||||
}
|
||||
if (val === 'delete') {
|
||||
handleDelete(row);
|
||||
}
|
||||
if (val === 'start') {
|
||||
await handleStartModel(row);
|
||||
message.success(intl.formatMessage({ id: 'common.message.success' }));
|
||||
updateExpandedRowKeys([row.id, ...expandedRowKeys]);
|
||||
}
|
||||
|
||||
if (val === 'stop') {
|
||||
modalRef.current.show({
|
||||
content: 'models.instances',
|
||||
title: 'common.title.stop.confirm',
|
||||
okText: 'common.button.stop',
|
||||
operation: 'common.stop.single.confirm',
|
||||
name: row.name,
|
||||
async onOk() {
|
||||
await handleStopModel(row);
|
||||
}
|
||||
});
|
||||
if (val === 'stop') {
|
||||
modalRef.current.show({
|
||||
content: 'models.instances',
|
||||
title: 'common.title.stop.confirm',
|
||||
okText: 'common.button.stop',
|
||||
operation: 'common.stop.single.confirm',
|
||||
name: row.name,
|
||||
async onOk() {
|
||||
await handleStopModel(row);
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
// ignore
|
||||
}
|
||||
},
|
||||
[handleEdit, handleOpenPlayGround, handleDelete, expandedRowKeys]
|
||||
@@ -998,45 +994,6 @@ const Models: React.FC<ModelsProps> = ({
|
||||
disabled={!rowSelection.selectedRowKeys.length}
|
||||
onSelect={handleActionSelect}
|
||||
/>
|
||||
{/* <Button
|
||||
icon={<IconFont type="icon-outline-play"></IconFont>}
|
||||
onClick={handleStartBatch}
|
||||
disabled={!rowSelection.selectedRows.length}
|
||||
>
|
||||
<span>
|
||||
{intl?.formatMessage?.({ id: 'common.button.start' })}
|
||||
{rowSelection.selectedRows.length > 0 && (
|
||||
<span>({rowSelection.selectedRows?.length})</span>
|
||||
)}
|
||||
</span>
|
||||
</Button>
|
||||
<Button
|
||||
icon={<IconFont type="icon-stop1"></IconFont>}
|
||||
onClick={handleStopBatch}
|
||||
disabled={!rowSelection.selectedRows.length}
|
||||
>
|
||||
<span>
|
||||
{intl?.formatMessage?.({ id: 'common.button.stop' })}
|
||||
{rowSelection.selectedRows.length > 0 && (
|
||||
<span>({rowSelection.selectedRows?.length})</span>
|
||||
)}
|
||||
</span>
|
||||
</Button>
|
||||
<Access accessible={access.canDelete}>
|
||||
<Button
|
||||
icon={<DeleteOutlined />}
|
||||
danger
|
||||
onClick={handleDeleteBatch}
|
||||
disabled={!rowSelection.selectedRowKeys.length}
|
||||
>
|
||||
<span>
|
||||
{intl?.formatMessage?.({ id: 'common.button.delete' })}
|
||||
{rowSelection.selectedRowKeys.length > 0 && (
|
||||
<span>({rowSelection.selectedRowKeys?.length})</span>
|
||||
)}
|
||||
</span>
|
||||
</Button>
|
||||
</Access> */}
|
||||
</Space>
|
||||
}
|
||||
></PageTools>
|
||||
|
||||
@@ -7,7 +7,7 @@ import SealSelect from '@/components/seal-form/seal-select';
|
||||
import { PageAction } from '@/config';
|
||||
import { PageActionType } from '@/config/types';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Form, Modal, Tooltip, Typography } from 'antd';
|
||||
import { Form, Modal, Typography } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import {
|
||||
@@ -236,25 +236,24 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
|
||||
disabled={false}
|
||||
options={ollamaModelOptions}
|
||||
placeholder={intl.formatMessage({ id: 'model.form.ollamaholder' })}
|
||||
label={
|
||||
<>
|
||||
{intl.formatMessage({ id: 'model.form.ollama.model' })}{' '}
|
||||
description={
|
||||
<span>
|
||||
<span>
|
||||
{intl.formatMessage({ id: 'models.form.ollamalink' })}
|
||||
</span>
|
||||
<Typography.Link
|
||||
className="flex-center"
|
||||
href="https://www.ollama.com/library"
|
||||
target="_blank"
|
||||
>
|
||||
<Tooltip
|
||||
title={intl.formatMessage({ id: 'models.form.ollamalink' })}
|
||||
placement="topRight"
|
||||
>
|
||||
<IconFont
|
||||
type="icon-external-link"
|
||||
className="font-size-14"
|
||||
></IconFont>
|
||||
</Tooltip>
|
||||
<IconFont
|
||||
type="icon-external-link"
|
||||
className="font-size-14"
|
||||
></IconFont>
|
||||
</Typography.Link>
|
||||
</>
|
||||
</span>
|
||||
}
|
||||
label={intl.formatMessage({ id: 'model.form.ollama.model' })}
|
||||
required
|
||||
></SealAutoComplete>
|
||||
</Form.Item>
|
||||
|
||||
Reference in New Issue
Block a user