chore: custom table sort

This commit is contained in:
jialin
2024-07-16 18:13:34 +08:00
parent a27fa9d56c
commit b05595f84b
8 changed files with 127 additions and 18 deletions
+6 -6
View File
@@ -110,9 +110,9 @@ const Models: React.FC<ModelsProps> = ({
});
};
const handleTableChange = (pagination: any, filters: any, sorter: any) => {
console.log('handleTableChange=======', pagination, filters, sorter);
setSortOrder(sorter.order);
const handleOnSort = (dataIndex: string, order: any) => {
console.log('handleTableChange=======', dataIndex, order);
setSortOrder(order);
};
const handleAddModal = () => {
@@ -326,7 +326,7 @@ const Models: React.FC<ModelsProps> = ({
rowKey="id"
childParentKey="model_id"
expandable={true}
onChange={handleTableChange}
onSort={handleOnSort}
pollingChildren={false}
watchChildren={true}
loadChildren={getModelInstances}
@@ -384,8 +384,7 @@ const Models: React.FC<ModelsProps> = ({
key="created_at"
defaultSortOrder="descend"
sortOrder={sortOrder}
showSorterTooltip={false}
sorter={true}
sorter={false}
render={(text, row) => {
return dayjs(text).format('YYYY-MM-DD HH:mm:ss');
}}
@@ -394,6 +393,7 @@ const Models: React.FC<ModelsProps> = ({
span={4}
title={intl.formatMessage({ id: 'common.table.operation' })}
key="operation"
dataIndex="operation"
render={(text, record) => {
return !record.transition ? (
<DropdownButtons
@@ -31,7 +31,7 @@ const ViewCodeModal: React.FC<ViewModalProps> = (props) => {
const [codeValue, setCodeValue] = useState('');
const [lang, setLang] = useState('shell');
const BaseURL = `${window.location.origin}/v1-openai/chat/completions`;
const BaseURL = `${window.location.origin}/v1-openai`;
const langOptions = [
{ label: 'Curl', value: 'shell' },
@@ -69,14 +69,14 @@ const ViewCodeModal: React.FC<ViewModalProps> = (props) => {
const systemList = systemMessage
? [{ role: 'system', content: systemMessage }]
: [];
const code = `import OpenAI from "openai";\nconst openai = new OpenAI();\n\nconst baseURL = "${BaseURL}"\n\nasync function main(){\nconst params = ${JSON.stringify(
const code = `const OpenAI = require("openai");\n\nconst openai = new OpenAI({\n"apiKey": $\{GUPSTACK_API_KEY},\n"baseURL": "${BaseURL}"\n});\n\n\nasync function main(){\nconst params = ${JSON.stringify(
{
...parameters,
messages: [...systemList, ...messageList]
},
null,
2
)};\nconst chatCompletion = await openai.chat.completions.create(params);\nfor await (const chunk of chatCompletion) {\n process.stdout.write(chunk.choices[0]?.delta?.content || '');\n}\n}\nmain();`;
)};\nconst chatCompletion = await openai.chat.completions.create(params);\nfor await (const chunk of chatCompletion) {\n process.stdout.write(chunk.choices[0]?.message?.content || '');\n}\n}\nmain();`;
setCodeValue(code);
} else if (lang === 'python') {
const formattedParams = _.keys(parameters).reduce(
@@ -95,7 +95,7 @@ const ViewCodeModal: React.FC<ViewModalProps> = (props) => {
const systemList = systemMessage
? [{ role: 'system', content: systemMessage }]
: [];
const code = `from openai import OpenAI\nclient = OpenAI()\n\nbaseURL = ${BaseURL}\n\ncompletion = client.chat.completions.create(\n${formattedParams} messages=${JSON.stringify([...systemList, ...messageList], null, 2)})\nprint(completion.choices[0].message)`;
const code = `from openai import OpenAI\n\nbaseURL = ${BaseURL}\n\nclient = OpenAI(\nbase_url=baseURL, \napi_key="$\{GUPSTACK_API_KEY}"\n)\n\ncompletion = client.chat.completions.create(\n${formattedParams} messages=${JSON.stringify([...systemList, ...messageList], null, 2)})\nprint(completion.choices[0].message.content)`;
setCodeValue(code);
}
formatCode();
@@ -118,9 +118,10 @@ const ViewCodeModal: React.FC<ViewModalProps> = (props) => {
minimap: {
enabled: false
},
readOnly: true,
formatOnType: true,
formatOnPaste: true,
fontWeight: '700',
fontWeight: 700,
scrollbar: {
verticalSliderSize: 8
}
+1 -1
View File
@@ -137,7 +137,7 @@ const GPUList: React.FC = () => {
dataIndex="temperature"
key="Temperature"
render={(text, record: GPUDeviceItem) => {
return <span>{_.round(text, 1)}</span>;
return <span>{text ? _.round(text, 1) : '-'}</span>;
}}
/>
<Column