refactor: create image hooks
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
import { ParamsSchema } from './types';
|
||||
|
||||
export interface ImageSizeItem {
|
||||
label: string;
|
||||
value: string;
|
||||
width: number;
|
||||
height: number;
|
||||
locale?: boolean;
|
||||
}
|
||||
export const imageSizeOptions: {
|
||||
label: string;
|
||||
value: string;
|
||||
@@ -145,6 +152,48 @@ export const ImageParamsConfig: ParamsSchema[] = [
|
||||
}
|
||||
];
|
||||
|
||||
export const ImageCountConfig: ParamsSchema[] = [
|
||||
{
|
||||
type: 'InputNumber',
|
||||
name: 'n',
|
||||
label: {
|
||||
text: 'playground.params.counts',
|
||||
isLocalized: true
|
||||
},
|
||||
attrs: {
|
||||
min: 1,
|
||||
max: 4
|
||||
},
|
||||
rules: [
|
||||
{
|
||||
required: false
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
export const ImageSizeConfig: ParamsSchema[] = [
|
||||
{
|
||||
type: 'Select',
|
||||
name: 'size',
|
||||
options: imageSizeOptions,
|
||||
description: {
|
||||
text: 'playground.params.size.description',
|
||||
html: true,
|
||||
isLocalized: true
|
||||
},
|
||||
label: {
|
||||
text: 'playground.params.size',
|
||||
isLocalized: true
|
||||
},
|
||||
rules: [
|
||||
{
|
||||
required: false
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
export const ImageEidtParamsConfig: ParamsSchema[] = [
|
||||
{
|
||||
type: 'InputNumber',
|
||||
@@ -414,6 +463,7 @@ export const ImageAdvancedParamsConfig: ParamsSchema[] = [
|
||||
attrs: {
|
||||
min: 0
|
||||
},
|
||||
dependencies: ['random_seed'],
|
||||
disabledConfig: {
|
||||
depends: ['random_seed'],
|
||||
when: (values: Record<string, any>): boolean => values?.random_seed
|
||||
@@ -431,6 +481,12 @@ export const ImageAdvancedParamsConfig: ParamsSchema[] = [
|
||||
text: 'playground.image.params.randomseed',
|
||||
isLocalized: true
|
||||
},
|
||||
style: {
|
||||
marginBottom: 20
|
||||
},
|
||||
formItemAttrs: {
|
||||
noStyle: true
|
||||
},
|
||||
rules: [
|
||||
{
|
||||
required: false
|
||||
@@ -449,7 +505,7 @@ export const ImageCustomSizeConfig: ParamsSchema[] = [
|
||||
},
|
||||
attrs: {
|
||||
min: 256,
|
||||
max: 3200,
|
||||
max: 1024,
|
||||
step: 64,
|
||||
inputnumber: false
|
||||
},
|
||||
@@ -469,7 +525,7 @@ export const ImageCustomSizeConfig: ParamsSchema[] = [
|
||||
},
|
||||
attrs: {
|
||||
min: 256,
|
||||
max: 3200,
|
||||
max: 1024,
|
||||
step: 64,
|
||||
inputnumber: false
|
||||
},
|
||||
@@ -481,3 +537,119 @@ export const ImageCustomSizeConfig: ParamsSchema[] = [
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
export const ChatParamsConfig: ParamsSchema[] = [
|
||||
{
|
||||
type: 'Slider',
|
||||
name: 'temperature',
|
||||
label: {
|
||||
text: 'Temperature',
|
||||
isLocalized: false
|
||||
},
|
||||
description: {
|
||||
text: 'playground.params.temperature.tips',
|
||||
html: false,
|
||||
isLocalized: true
|
||||
},
|
||||
attrs: {
|
||||
max: 2,
|
||||
step: 0.1,
|
||||
inputnumber: true
|
||||
},
|
||||
rules: [
|
||||
{
|
||||
required: false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'Slider',
|
||||
name: 'max_tokens',
|
||||
label: {
|
||||
text: 'Max Tokens',
|
||||
isLocalized: false
|
||||
},
|
||||
description: {
|
||||
text: 'playground.params.maxtokens.tips',
|
||||
html: false,
|
||||
isLocalized: true
|
||||
},
|
||||
attrs: {
|
||||
max: 1024,
|
||||
step: 1,
|
||||
inputnumber: true
|
||||
},
|
||||
rules: [
|
||||
{
|
||||
required: false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'Slider',
|
||||
name: 'top_p',
|
||||
label: {
|
||||
text: 'Top P',
|
||||
isLocalized: false
|
||||
},
|
||||
description: {
|
||||
text: 'playground.params.topp.tips',
|
||||
html: false,
|
||||
isLocalized: true
|
||||
},
|
||||
attrs: {
|
||||
max: 1,
|
||||
step: 0.1,
|
||||
inputnumber: true
|
||||
},
|
||||
rules: [
|
||||
{
|
||||
required: false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'InputNumber',
|
||||
name: 'seed',
|
||||
label: {
|
||||
text: 'Seed',
|
||||
isLocalized: false
|
||||
},
|
||||
description: {
|
||||
text: 'playground.params.seed.tips',
|
||||
html: false,
|
||||
isLocalized: true
|
||||
},
|
||||
attrs: {
|
||||
min: 0
|
||||
},
|
||||
rules: [
|
||||
{
|
||||
required: false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'Input',
|
||||
name: 'stop',
|
||||
label: {
|
||||
text: 'Stop Sequence',
|
||||
isLocalized: false
|
||||
},
|
||||
description: {
|
||||
text: 'playground.params.stop.tips',
|
||||
html: false,
|
||||
isLocalized: true
|
||||
},
|
||||
attrs: {
|
||||
normalize(value: string) {
|
||||
return value || null;
|
||||
}
|
||||
},
|
||||
rules: [
|
||||
{
|
||||
required: false
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
@@ -33,6 +33,7 @@ export interface ParamsSchema {
|
||||
text: string;
|
||||
isLocalized?: boolean;
|
||||
};
|
||||
dependencies?: string[];
|
||||
style?: React.CSSProperties;
|
||||
options?: Global.BaseOption<string | number | null>[];
|
||||
value?: string | number | boolean | string[];
|
||||
@@ -53,6 +54,7 @@ export interface ParamsSchema {
|
||||
}[];
|
||||
placeholder?: React.ReactNode;
|
||||
attrs?: Record<string, any>;
|
||||
formItemAttrs?: Record<string, any>;
|
||||
description?: {
|
||||
text: string;
|
||||
html?: boolean;
|
||||
|
||||
Reference in New Issue
Block a user