style: create images ux
This commit is contained in:
+1
-1
@@ -14,7 +14,7 @@ const isProduction = env === 'production';
|
|||||||
const t = Date.now();
|
const t = Date.now();
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
proxy: {
|
proxy: {
|
||||||
...proxy('http://csvhs44p420c73bdb41g-80.agent.damodel.com')
|
...proxy()
|
||||||
},
|
},
|
||||||
history: {
|
history: {
|
||||||
type: 'hash'
|
type: 'hash'
|
||||||
|
|||||||
+26
-1
@@ -18,10 +18,35 @@ export default function createProxyTable(target?: string) {
|
|||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
secure: false,
|
secure: false,
|
||||||
ws: true,
|
ws: true,
|
||||||
|
buffer: false,
|
||||||
|
selfHandleResponse: false,
|
||||||
pathRewrite: (pth: string) => pth.replace(`/^/${api}`, `/${api}`),
|
pathRewrite: (pth: string) => pth.replace(`/^/${api}`, `/${api}`),
|
||||||
headers: {
|
headers: {
|
||||||
origin: newTarget,
|
origin: newTarget,
|
||||||
Connection: 'keep-alive'
|
Connection: 'keep-alive',
|
||||||
|
'Cache-Control': 'no-cache'
|
||||||
|
},
|
||||||
|
onProxyRes: (proxyRes: any, req: any, res: any) => {
|
||||||
|
// let body = '';
|
||||||
|
// proxyRes.on('data', (chunk) => {
|
||||||
|
// body += chunk;
|
||||||
|
// console.log('Received data from target server::::::::::', chunk);
|
||||||
|
// });
|
||||||
|
|
||||||
|
// proxyRes.on('end', () => {
|
||||||
|
// console.log('Received data from target server=================end');
|
||||||
|
// console.log(body);
|
||||||
|
// });
|
||||||
|
if (req.headers.accept === 'text/event-stream') {
|
||||||
|
res.writeHead(res.statusCode, {
|
||||||
|
'Content-Type': 'text/event-stream',
|
||||||
|
'Cache-Control': 'no-cache',
|
||||||
|
Connection: 'keep-alive',
|
||||||
|
'X-Accel-Buffering': 'no',
|
||||||
|
'Access-Control-Allow-Origin': '*'
|
||||||
|
});
|
||||||
|
proxyRes.pipe(res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return obj;
|
return obj;
|
||||||
|
|||||||
+1
-1
@@ -36,7 +36,7 @@ export default [
|
|||||||
{
|
{
|
||||||
name: 'text2images',
|
name: 'text2images',
|
||||||
title: 'Text2Images',
|
title: 'Text2Images',
|
||||||
path: '/playground/text-to-images',
|
path: '/playground/text-to-image',
|
||||||
key: 'text2images',
|
key: 'text2images',
|
||||||
icon: 'Comment',
|
icon: 'Comment',
|
||||||
component: './playground/images'
|
component: './playground/images'
|
||||||
|
|||||||
@@ -28,16 +28,16 @@ const options: any = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
axisLine: {
|
axisLine: {
|
||||||
show: false,
|
show: true,
|
||||||
lineStyle: {
|
lineStyle: {
|
||||||
color: '#F2F2F2'
|
color: '#DCDCDC'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
axisTick: {
|
axisTick: {
|
||||||
show: false
|
show: false
|
||||||
},
|
},
|
||||||
axisLabel: {
|
axisLabel: {
|
||||||
show: false
|
show: true
|
||||||
},
|
},
|
||||||
boundaryGap: [0.05, 0.05]
|
boundaryGap: [0.05, 0.05]
|
||||||
},
|
},
|
||||||
@@ -54,16 +54,16 @@ const options: any = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
axisLine: {
|
axisLine: {
|
||||||
show: false,
|
show: true,
|
||||||
lineStyle: {
|
lineStyle: {
|
||||||
color: '#F2F2F2'
|
color: '#DCDCDC'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
axisTick: {
|
axisTick: {
|
||||||
show: false
|
show: false
|
||||||
},
|
},
|
||||||
axisLabel: {
|
axisLabel: {
|
||||||
show: false
|
show: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { isHTMLDocumentString } from '@/utils';
|
||||||
import { EyeOutlined } from '@ant-design/icons';
|
import { EyeOutlined } from '@ant-design/icons';
|
||||||
import { Checkbox, Image, Typography } from 'antd';
|
import { Checkbox, Image, Typography } from 'antd';
|
||||||
import { unescape } from 'lodash';
|
import { unescape } from 'lodash';
|
||||||
@@ -198,12 +199,18 @@ const MarkdownViewer: React.FC<MarkdownViewerProps> = ({
|
|||||||
}, [content, generateImgSrc]);
|
}, [content, generateImgSrc]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<>
|
||||||
style={{ height }}
|
{isHTMLDocumentString(content) ? (
|
||||||
className="markdown-viewer custom-scrollbar-horizontal"
|
<div dangerouslySetInnerHTML={{ __html: content }} style={{ height }} />
|
||||||
>
|
) : (
|
||||||
{renderTokens(tokens)}
|
<div
|
||||||
</div>
|
style={{ height }}
|
||||||
|
className="markdown-viewer custom-scrollbar-horizontal"
|
||||||
|
>
|
||||||
|
{renderTokens(tokens)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ export default {
|
|||||||
'playground.toolbar.compare4Model': '4-Model Comparison',
|
'playground.toolbar.compare4Model': '4-Model Comparison',
|
||||||
'playground.toolbar.compare6Model': '6-Model Comparison',
|
'playground.toolbar.compare6Model': '6-Model Comparison',
|
||||||
'playground.input.holder': 'Type <kbd>/</kbd> to input message',
|
'playground.input.holder': 'Type <kbd>/</kbd> to input message',
|
||||||
|
'playground.input.prompt.holder': 'Type <kbd>/</kbd> to input prompt',
|
||||||
'playground.input.keyword.holder': 'Type <kbd>/</kbd> to input your query',
|
'playground.input.keyword.holder': 'Type <kbd>/</kbd> to input your query',
|
||||||
'playground.compare.apply': 'Apply',
|
'playground.compare.apply': 'Apply',
|
||||||
'playground.compare.applytoall': 'Apply to all models',
|
'playground.compare.applytoall': 'Apply to all models',
|
||||||
@@ -61,6 +62,10 @@ export default {
|
|||||||
'playground.params.height': 'Height',
|
'playground.params.height': 'Height',
|
||||||
'playground.params.custom': 'Custom',
|
'playground.params.custom': 'Custom',
|
||||||
'playground.params.empty.tips': 'Generated images will appear here',
|
'playground.params.empty.tips': 'Generated images will appear here',
|
||||||
|
'playground.params.standard': 'Standard',
|
||||||
|
'playground.params.hd': 'HD',
|
||||||
|
'playground.params.style.vivid': 'Vivid',
|
||||||
|
'playground.params.style.natural': 'Natural',
|
||||||
'playground.embedding.documents': 'Documents',
|
'playground.embedding.documents': 'Documents',
|
||||||
'playground.embedding.addtext': 'Add Text',
|
'playground.embedding.addtext': 'Add Text',
|
||||||
'playground.embedding.inputyourtext': 'Input your text',
|
'playground.embedding.inputyourtext': 'Input your text',
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ export default {
|
|||||||
'menu.playground.embedding': '文本嵌入',
|
'menu.playground.embedding': '文本嵌入',
|
||||||
'menu.playground.chat': '对话',
|
'menu.playground.chat': '对话',
|
||||||
'menu.playground.speech': '语音',
|
'menu.playground.speech': '语音',
|
||||||
'menu.playground.text2images': '图片',
|
'menu.playground.text2images': '文生图',
|
||||||
'menu.compare': '多模型对比',
|
'menu.compare': '多模型对比',
|
||||||
'menu.models': '模型',
|
'menu.models': '模型',
|
||||||
'menu.resources': '资源',
|
'menu.resources': '资源',
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ export default {
|
|||||||
'playground.toolbar.compare6Model': '6 模型对比',
|
'playground.toolbar.compare6Model': '6 模型对比',
|
||||||
'playground.input.holder': '按 <kbd>/</kbd> 开始输入',
|
'playground.input.holder': '按 <kbd>/</kbd> 开始输入',
|
||||||
'playground.input.keyword.holder': '按 <kbd>/</kbd> 输入你的查询',
|
'playground.input.keyword.holder': '按 <kbd>/</kbd> 输入你的查询',
|
||||||
|
'playground.input.prompt.holder': '按 <kbd>/</kbd> 输入提示',
|
||||||
'playground.compare.apply': '应用',
|
'playground.compare.apply': '应用',
|
||||||
'playground.compare.applytoall': '应用到所有模型',
|
'playground.compare.applytoall': '应用到所有模型',
|
||||||
'playground.model.noavailable': '无可用模型',
|
'playground.model.noavailable': '无可用模型',
|
||||||
@@ -60,6 +61,10 @@ export default {
|
|||||||
'playground.params.width': '宽度',
|
'playground.params.width': '宽度',
|
||||||
'playground.params.height': '高度',
|
'playground.params.height': '高度',
|
||||||
'playground.params.custom': '自定义',
|
'playground.params.custom': '自定义',
|
||||||
|
'playground.params.standard': '标准',
|
||||||
|
'playground.params.hd': '高清',
|
||||||
|
'playground.params.style.vivid': '生动',
|
||||||
|
'playground.params.style.natural': '自然',
|
||||||
'playground.params.empty.tips': '生成的图片将出现在这里',
|
'playground.params.empty.tips': '生成的图片将出现在这里',
|
||||||
'playground.embedding.documents': '文档',
|
'playground.embedding.documents': '文档',
|
||||||
'playground.embedding.addtext': '添加文本',
|
'playground.embedding.addtext': '添加文本',
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import SealSelect from '@/components/seal-form/seal-select';
|
|||||||
import { PageAction } from '@/config';
|
import { PageAction } from '@/config';
|
||||||
import { PageActionType } from '@/config/types';
|
import { PageActionType } from '@/config/types';
|
||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import { Button, Form, Modal, Select, Tag } from 'antd';
|
import { Button, Form, Modal, Tag } from 'antd';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { createApisKey } from '../apis';
|
import { createApisKey } from '../apis';
|
||||||
@@ -160,17 +160,10 @@ const AddModal: React.FC<AddModalProps> = ({
|
|||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<SealSelect
|
<SealSelect
|
||||||
|
options={expirationOptions}
|
||||||
label={intl.formatMessage({ id: 'apikeys.form.expiretime' })}
|
label={intl.formatMessage({ id: 'apikeys.form.expiretime' })}
|
||||||
required
|
required
|
||||||
>
|
></SealSelect>
|
||||||
{expirationOptions.map((option) => {
|
|
||||||
return (
|
|
||||||
<Select.Option key={option.value} value={option.value}>
|
|
||||||
{intl.formatMessage({ id: option.label })}
|
|
||||||
</Select.Option>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</SealSelect>
|
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item<FormData>
|
<Form.Item<FormData>
|
||||||
name="description"
|
name="description"
|
||||||
|
|||||||
@@ -1,6 +1,26 @@
|
|||||||
export const expirationOptions = [
|
export const expirationOptions = [
|
||||||
{ label: 'apikeys.form.expiration.7days', type: 'day', value: 7 },
|
{
|
||||||
{ label: 'apikeys.form.expiration.1month', type: 'month', value: 1 },
|
label: 'apikeys.form.expiration.7days',
|
||||||
{ label: 'apikeys.form.expiration.6months', type: 'month', value: 6 },
|
type: 'day',
|
||||||
{ label: 'apikeys.form.expiration.never', type: 'never', value: -1 }
|
value: 7,
|
||||||
|
locale: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'apikeys.form.expiration.1month',
|
||||||
|
type: 'month',
|
||||||
|
value: 1,
|
||||||
|
locale: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'apikeys.form.expiration.6months',
|
||||||
|
type: 'month',
|
||||||
|
value: 6,
|
||||||
|
locale: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'apikeys.form.expiration.never',
|
||||||
|
type: 'never',
|
||||||
|
value: -1,
|
||||||
|
locale: true
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ const ModelCard: React.FC<{
|
|||||||
signal: axiosTokenRef.current.signal
|
signal: axiosTokenRef.current.signal
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
console.log('readme++++++++', res);
|
||||||
return res || '';
|
return res || '';
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return '';
|
return '';
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ const extraConfig: ParamsSchema[] = [
|
|||||||
type: 'Select',
|
type: 'Select',
|
||||||
name: 'quality',
|
name: 'quality',
|
||||||
options: [
|
options: [
|
||||||
{ label: 'standard', value: 'standard' },
|
{ label: 'playground.params.standard', value: 'standard', locale: true },
|
||||||
{ label: 'hd', value: 'hd' }
|
{ label: 'playground.params.hd', value: 'hd', locale: true }
|
||||||
],
|
],
|
||||||
label: {
|
label: {
|
||||||
text: 'playground.params.quality',
|
text: 'playground.params.quality',
|
||||||
@@ -65,8 +65,12 @@ const extraConfig: ParamsSchema[] = [
|
|||||||
type: 'Select',
|
type: 'Select',
|
||||||
name: 'style',
|
name: 'style',
|
||||||
options: [
|
options: [
|
||||||
{ label: 'vivid', value: 'vivid' },
|
{ label: 'playground.params.style.vivid', value: 'vivid', locale: true },
|
||||||
{ label: 'natural', value: 'natural' }
|
{
|
||||||
|
label: 'playground.params.style.natural',
|
||||||
|
value: 'natural',
|
||||||
|
locale: true
|
||||||
|
}
|
||||||
],
|
],
|
||||||
label: {
|
label: {
|
||||||
text: 'playground.params.style',
|
text: 'playground.params.style',
|
||||||
@@ -93,42 +97,42 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
progress?: number;
|
progress?: number;
|
||||||
}[]
|
}[]
|
||||||
>([
|
>([
|
||||||
{
|
// {
|
||||||
dataUrl:
|
// dataUrl:
|
||||||
'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
// 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
||||||
height: 'auto',
|
// height: 'auto',
|
||||||
width: 'auto',
|
// width: 'auto',
|
||||||
uid: 0,
|
// uid: 0,
|
||||||
span: 12,
|
// span: 12,
|
||||||
progress: 10
|
// progress: 10
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
dataUrl:
|
// dataUrl:
|
||||||
'https://gw.alipayobjects.com/zos/antfincdn/LlvErxo8H9/photo-1503185912284-5271ff81b9a8.webp',
|
// 'https://gw.alipayobjects.com/zos/antfincdn/LlvErxo8H9/photo-1503185912284-5271ff81b9a8.webp',
|
||||||
height: 'auto',
|
// height: 'auto',
|
||||||
width: 'auto',
|
// width: 'auto',
|
||||||
uid: 1,
|
// uid: 1,
|
||||||
span: 12,
|
// span: 12,
|
||||||
progress: 15
|
// progress: 15
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
dataUrl:
|
// dataUrl:
|
||||||
'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
// 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
||||||
height: 'auto',
|
// height: 'auto',
|
||||||
width: 'auto',
|
// width: 'auto',
|
||||||
uid: 3,
|
// uid: 3,
|
||||||
span: 12,
|
// span: 12,
|
||||||
progress: 10
|
// progress: 10
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
dataUrl:
|
// dataUrl:
|
||||||
'https://gw.alipayobjects.com/zos/antfincdn/LlvErxo8H9/photo-1503185912284-5271ff81b9a8.webp',
|
// 'https://gw.alipayobjects.com/zos/antfincdn/LlvErxo8H9/photo-1503185912284-5271ff81b9a8.webp',
|
||||||
height: 'auto',
|
// height: 'auto',
|
||||||
width: 'auto',
|
// width: 'auto',
|
||||||
uid: 4,
|
// uid: 4,
|
||||||
span: 12,
|
// span: 12,
|
||||||
progress: 15
|
// progress: 15
|
||||||
}
|
// }
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
@@ -252,7 +256,10 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
const result: any = await fetchChunkedData({
|
const result: any = await fetchChunkedData({
|
||||||
data: params,
|
data: params,
|
||||||
url: CREAT_IMAGE_API,
|
url: CREAT_IMAGE_API,
|
||||||
signal: requestToken.current.signal
|
signal: requestToken.current.signal,
|
||||||
|
headers: {
|
||||||
|
accept: 'text/event-stream'
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result?.error) {
|
if (result?.error) {
|
||||||
@@ -462,7 +469,9 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
)}
|
)}
|
||||||
<div className="ground-left-footer">
|
<div className="ground-left-footer">
|
||||||
<MessageInput
|
<MessageInput
|
||||||
placeholer="Type <kbd>/</kbd> to input prompt"
|
placeholer={intl.formatMessage({
|
||||||
|
id: 'playground.input.prompt.holder'
|
||||||
|
})}
|
||||||
actions={[]}
|
actions={[]}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
disabled={!parameters.model}
|
disabled={!parameters.model}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ export const fetchChunkedData = async (params: {
|
|||||||
params?: any;
|
params?: any;
|
||||||
signal?: AbortSignal;
|
signal?: AbortSignal;
|
||||||
method?: string;
|
method?: string;
|
||||||
|
headers?: any;
|
||||||
}) => {
|
}) => {
|
||||||
const method = params.method || 'POST';
|
const method = params.method || 'POST';
|
||||||
let url = params.url;
|
let url = params.url;
|
||||||
@@ -43,7 +44,8 @@ export const fetchChunkedData = async (params: {
|
|||||||
body: method === 'POST' ? JSON.stringify(params.data) : null,
|
body: method === 'POST' ? JSON.stringify(params.data) : null,
|
||||||
signal: params.signal,
|
signal: params.signal,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json',
|
||||||
|
...params.headers
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
|||||||
@@ -127,3 +127,13 @@ export const cosineSimilarity = (vec1: number[], vec2: number[]) => {
|
|||||||
|
|
||||||
return dotProduct / (magnitudeA * magnitudeB);
|
return dotProduct / (magnitudeA * magnitudeB);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const isHTMLDocumentString = (str: string) => {
|
||||||
|
try {
|
||||||
|
const parser = new DOMParser();
|
||||||
|
const doc = parser.parseFromString(str, 'text/html');
|
||||||
|
return doc.documentElement.tagName.toLowerCase() === 'html';
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user