diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..487818d2 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +src/components/icon-font/iconfont/iconfont.js \ No newline at end of file diff --git a/config/proxy.ts b/config/proxy.ts index 1915b1c4..1013d6a6 100644 --- a/config/proxy.ts +++ b/config/proxy.ts @@ -18,35 +18,10 @@ export default function createProxyTable(target?: string) { changeOrigin: true, secure: false, ws: true, - buffer: false, - selfHandleResponse: false, pathRewrite: (pth: string) => pth.replace(`/^/${api}`, `/${api}`), headers: { origin: newTarget, - 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); - } + Connection: 'keep-alive' } }; return obj; diff --git a/src/components/icon-font/iconfont/iconfont.css b/src/components/icon-font/iconfont/iconfont.css new file mode 100644 index 00000000..a28a5d2e --- /dev/null +++ b/src/components/icon-font/iconfont/iconfont.css @@ -0,0 +1,155 @@ +@font-face { + font-family: iconfont; /* Project id 4613488 */ + src: + url('iconfont.woff2?t=1732245003614') format('woff2'), + url('iconfont.woff?t=1732245003614') format('woff'), + url('iconfont.ttf?t=1732245003614') format('truetype'); +} + +.iconfont { + font-family: iconfont !important; + font-size: 16px; + font-style: normal; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.icon-stop2::before { + content: '\e8db'; +} + +.icon-stop::before { + content: '\e60b'; +} + +.icon-image::before { + content: '\e62c'; +} + +.icon-stopcircle-fill::before { + content: '\e7cc'; +} + +.icon-playcircle-fill::before { + content: '\e7cd'; +} + +.icon-SpeakerSlash::before { + content: '\e661'; +} + +.icon-SpeakerHigh::before { + content: '\e670'; +} + +.icon-user_voice::before { + content: '\e667'; +} + +.icon-audio::before { + content: '\e985'; +} + +.icon-hard-disk::before { + content: '\eb1d'; +} + +.icon-new::before { + content: '\e612'; +} + +.icon-tu2::before { + content: '\e607'; +} + +.icon-robot::before { + content: '\e634'; +} + +.icon-robot1::before { + content: '\e602'; +} + +.icon-aizhineng::before { + content: '\e672'; +} + +.icon-copy::before { + content: '\e720'; +} + +.icon-AIzhineng::before { + content: '\e608'; +} + +.icon-cols_6::before { + content: '\e651'; +} + +.icon-cols_3::before { + content: '\e650'; +} + +.icon-cols_2::before { + content: '\e64e'; +} + +.icon-cols_4::before { + content: '\e64d'; +} + +.icon-clear::before { + content: '\e60a'; +} + +.icon-keyboard::before { + content: '\e61b'; +} + +.icon-networkerror::before { + content: '\e624'; +} + +.icon-external-link::before { + content: '\e66b'; +} + +.icon-huggingface::before { + content: '\e7d1'; +} + +.icon-ollama::before { + content: '\e601'; +} + +.icon-a-layout6-line::before { + content: '\e9ef'; +} + +.icon-a-Layout5::before { + content: '\e610'; +} + +.icon-English::before { + content: '\e8b3'; +} + +.icon-chinese::before { + content: '\e611'; +} + +.icon-yingguo::before { + content: '\e606'; +} + +.icon-code::before { + content: '\e84f'; +} + +.icon-stop1::before { + content: '\e783'; +} + +.icon-command::before { + content: '\e600'; +} diff --git a/src/components/icon-font/iconfont/iconfont.js b/src/components/icon-font/iconfont/iconfont.js new file mode 100644 index 00000000..06c2b5dc --- /dev/null +++ b/src/components/icon-font/iconfont/iconfont.js @@ -0,0 +1,70 @@ +(window._iconfont_svg_string_4613488 = + ''), + ((h) => { + var a = (l = (l = document.getElementsByTagName('script'))[ + l.length - 1 + ]).getAttribute('data-injectcss'), + l = l.getAttribute('data-disable-injectsvg'); + if (!l) { + var z, + t, + c, + i, + v, + m = function (a, l) { + l.parentNode.insertBefore(a, l); + }; + if (a && !h.__iconfont__svg__cssinject__) { + h.__iconfont__svg__cssinject__ = !0; + try { + document.write( + '' + ); + } catch (a) { + console && console.log(a); + } + } + (z = function () { + var a, + l = document.createElement('div'); + (l.innerHTML = h._iconfont_svg_string_4613488), + (l = l.getElementsByTagName('svg')[0]) && + (l.setAttribute('aria-hidden', 'true'), + (l.style.position = 'absolute'), + (l.style.width = 0), + (l.style.height = 0), + (l.style.overflow = 'hidden'), + (l = l), + (a = document.body).firstChild + ? m(l, a.firstChild) + : a.appendChild(l)); + }), + document.addEventListener + ? ~['complete', 'loaded', 'interactive'].indexOf(document.readyState) + ? setTimeout(z, 0) + : ((t = function () { + document.removeEventListener('DOMContentLoaded', t, !1), z(); + }), + document.addEventListener('DOMContentLoaded', t, !1)) + : document.attachEvent && + ((c = z), + (i = h.document), + (v = !1), + p(), + (i.onreadystatechange = function () { + 'complete' == i.readyState && + ((i.onreadystatechange = null), o()); + })); + } + function o() { + v || ((v = !0), c()); + } + function p() { + try { + i.documentElement.doScroll('left'); + } catch (a) { + return void setTimeout(p, 50); + } + o(); + } + })(window); diff --git a/src/components/icon-font/iconfont/iconfont.json b/src/components/icon-font/iconfont/iconfont.json new file mode 100644 index 00000000..206b0e84 --- /dev/null +++ b/src/components/icon-font/iconfont/iconfont.json @@ -0,0 +1,254 @@ +{ + "id": "4613488", + "name": "gpustack", + "font_family": "iconfont", + "css_prefix_text": "icon-", + "description": "", + "glyphs": [ + { + "icon_id": "15617444", + "name": "stop", + "font_class": "stop2", + "unicode": "e8db", + "unicode_decimal": 59611 + }, + { + "icon_id": "8327181", + "name": "stop", + "font_class": "stop", + "unicode": "e60b", + "unicode_decimal": 58891 + }, + { + "icon_id": "714031", + "name": "image", + "font_class": "image", + "unicode": "e62c", + "unicode_decimal": 58924 + }, + { + "icon_id": "6151140", + "name": "stop circle-fill", + "font_class": "stopcircle-fill", + "unicode": "e7cc", + "unicode_decimal": 59340 + }, + { + "icon_id": "6151141", + "name": "play circle-fill", + "font_class": "playcircle-fill", + "unicode": "e7cd", + "unicode_decimal": 59341 + }, + { + "icon_id": "23563264", + "name": "SpeakerSlash", + "font_class": "SpeakerSlash", + "unicode": "e661", + "unicode_decimal": 58977 + }, + { + "icon_id": "23563318", + "name": "SpeakerHigh", + "font_class": "SpeakerHigh", + "unicode": "e670", + "unicode_decimal": 58992 + }, + { + "icon_id": "41955357", + "name": " user_voice", + "font_class": "user_voice", + "unicode": "e667", + "unicode_decimal": 58983 + }, + { + "icon_id": "29174196", + "name": "audio", + "font_class": "audio", + "unicode": "e985", + "unicode_decimal": 59781 + }, + { + "icon_id": "40073465", + "name": "hard-disk", + "font_class": "hard-disk", + "unicode": "eb1d", + "unicode_decimal": 60189 + }, + { + "icon_id": "12717507", + "name": "new", + "font_class": "new", + "unicode": "e612", + "unicode_decimal": 58898 + }, + { + "icon_id": "36135335", + "name": "mdp-template-modelscope", + "font_class": "tu2", + "unicode": "e607", + "unicode_decimal": 58887 + }, + { + "icon_id": "10710692", + "name": "robot", + "font_class": "robot", + "unicode": "e634", + "unicode_decimal": 58932 + }, + { + "icon_id": "12070718", + "name": "robot", + "font_class": "robot1", + "unicode": "e602", + "unicode_decimal": 58882 + }, + { + "icon_id": "10791813", + "name": "ai智能", + "font_class": "aizhineng", + "unicode": "e672", + "unicode_decimal": 58994 + }, + { + "icon_id": "19418384", + "name": "copy", + "font_class": "copy", + "unicode": "e720", + "unicode_decimal": 59168 + }, + { + "icon_id": "40757798", + "name": "AI智能", + "font_class": "AIzhineng", + "unicode": "e608", + "unicode_decimal": 58888 + }, + { + "icon_id": "41755257", + "name": "cols_6", + "font_class": "cols_6", + "unicode": "e651", + "unicode_decimal": 58961 + }, + { + "icon_id": "41755178", + "name": "cols_3", + "font_class": "cols_3", + "unicode": "e650", + "unicode_decimal": 58960 + }, + { + "icon_id": "41754685", + "name": "cols_2", + "font_class": "cols_2", + "unicode": "e64e", + "unicode_decimal": 58958 + }, + { + "icon_id": "41754565", + "name": "cols_4", + "font_class": "cols_4", + "unicode": "e64d", + "unicode_decimal": 58957 + }, + { + "icon_id": "36263088", + "name": "clear", + "font_class": "clear", + "unicode": "e60a", + "unicode_decimal": 58890 + }, + { + "icon_id": "5297059", + "name": "keyboard", + "font_class": "keyboard", + "unicode": "e61b", + "unicode_decimal": 58907 + }, + { + "icon_id": "11539157", + "name": "network error", + "font_class": "networkerror", + "unicode": "e624", + "unicode_decimal": 58916 + }, + { + "icon_id": "14465073", + "name": "external-link", + "font_class": "external-link", + "unicode": "e66b", + "unicode_decimal": 58987 + }, + { + "icon_id": "38465464", + "name": "huggingface", + "font_class": "huggingface", + "unicode": "e7d1", + "unicode_decimal": 59345 + }, + { + "icon_id": "40568411", + "name": "ollama", + "font_class": "ollama", + "unicode": "e601", + "unicode_decimal": 58881 + }, + { + "icon_id": "24341846", + "name": "layout 6-line", + "font_class": "a-layout6-line", + "unicode": "e9ef", + "unicode_decimal": 59887 + }, + { + "icon_id": "31345353", + "name": "a-Layout5", + "font_class": "a-Layout5", + "unicode": "e610", + "unicode_decimal": 58896 + }, + { + "icon_id": "10031665", + "name": "English", + "font_class": "English", + "unicode": "e8b3", + "unicode_decimal": 59571 + }, + { + "icon_id": "9134244", + "name": "chinese", + "font_class": "chinese", + "unicode": "e611", + "unicode_decimal": 58897 + }, + { + "icon_id": "12176725", + "name": "english", + "font_class": "yingguo", + "unicode": "e606", + "unicode_decimal": 58886 + }, + { + "icon_id": "34453176", + "name": "code", + "font_class": "code", + "unicode": "e84f", + "unicode_decimal": 59471 + }, + { + "icon_id": "12579515", + "name": "stop", + "font_class": "stop1", + "unicode": "e783", + "unicode_decimal": 59267 + }, + { + "icon_id": "1842082", + "name": "command", + "font_class": "command", + "unicode": "e600", + "unicode_decimal": 58880 + } + ] +} diff --git a/src/components/icon-font/iconfont/iconfont.ttf b/src/components/icon-font/iconfont/iconfont.ttf new file mode 100644 index 00000000..133aed60 Binary files /dev/null and b/src/components/icon-font/iconfont/iconfont.ttf differ diff --git a/src/components/icon-font/iconfont/iconfont.woff b/src/components/icon-font/iconfont/iconfont.woff new file mode 100644 index 00000000..6f5237b3 Binary files /dev/null and b/src/components/icon-font/iconfont/iconfont.woff differ diff --git a/src/components/icon-font/iconfont/iconfont.woff2 b/src/components/icon-font/iconfont/iconfont.woff2 new file mode 100644 index 00000000..f68c1e52 Binary files /dev/null and b/src/components/icon-font/iconfont/iconfont.woff2 differ diff --git a/src/components/icon-font/index.tsx b/src/components/icon-font/index.tsx index 2fea3c32..2c4fbc7b 100644 --- a/src/components/icon-font/index.tsx +++ b/src/components/icon-font/index.tsx @@ -1,7 +1,8 @@ import { createFromIconfontCN } from '@ant-design/icons'; +import './iconfont/iconfont.js'; const IconFont = createFromIconfontCN({ - scriptUrl: '//at.alicdn.com/t/c/font_4613488_f5wastzhj2w.js' + scriptUrl: '' }); export default IconFont; diff --git a/src/components/markdown-viewer/index.tsx b/src/components/markdown-viewer/index.tsx index 6b50c4b7..45c9ad99 100644 --- a/src/components/markdown-viewer/index.tsx +++ b/src/components/markdown-viewer/index.tsx @@ -1,4 +1,3 @@ -import { isHTMLDocumentString } from '@/utils'; import { EyeOutlined } from '@ant-design/icons'; import { Checkbox, Image, Typography } from 'antd'; import { unescape } from 'lodash'; @@ -200,16 +199,14 @@ const MarkdownViewer: React.FC = ({ return ( <> - {isHTMLDocumentString(content) ? ( -
- ) : ( -
- {renderTokens(tokens)} -
- )} + ( +
+ {renderTokens(tokens)} +
+ ) ); }; diff --git a/src/locales/en-US/playground.ts b/src/locales/en-US/playground.ts index 2cfed088..2207ff7e 100644 --- a/src/locales/en-US/playground.ts +++ b/src/locales/en-US/playground.ts @@ -74,5 +74,6 @@ export default { 'playground.rerank.query': 'Query', 'playground.rerank.rank': 'Rank', 'playground.rerank.score': 'Score', - 'playground.rerank.query.holder': 'Input your query' + 'playground.rerank.query.holder': 'Input your query', + 'playground.image.prompt': 'Input Prompt' }; diff --git a/src/locales/zh-CN/playground.ts b/src/locales/zh-CN/playground.ts index ffff46ef..789aff9b 100644 --- a/src/locales/zh-CN/playground.ts +++ b/src/locales/zh-CN/playground.ts @@ -74,5 +74,6 @@ export default { 'playground.rerank.query': '查询', 'playground.rerank.rank': '排序', 'playground.rerank.score': '分数', - 'playground.rerank.query.holder': '输入查询' + 'playground.rerank.query.holder': '输入查询', + 'playground.image.prompt': '输入提示' }; diff --git a/src/pages/llmodels/components/update-modal.tsx b/src/pages/llmodels/components/update-modal.tsx index f23e77e0..51550115 100644 --- a/src/pages/llmodels/components/update-modal.tsx +++ b/src/pages/llmodels/components/update-modal.tsx @@ -34,7 +34,6 @@ const SEARCH_SOURCE = [ ]; const UpdateModal: React.FC = (props) => { - console.log('addmodel===='); const { title, action, open, onOk, onCancel } = props || {}; const [form] = Form.useForm(); const intl = useIntl(); @@ -261,6 +260,13 @@ const UpdateModal: React.FC = (props) => { }; const handleOk = (formdata: FormData) => { + let obj = {}; + if (formdata.backend === backendOptionsMap.vllm) { + obj = { + distributed_inference_across_workers: false, + cpu_offloading: false + }; + } if (formdata.scheduleType === 'manual') { const gpu = _.find(gpuOptions, (item: any) => { return item.value === formdata.gpu_selector; @@ -275,12 +281,14 @@ const UpdateModal: React.FC = (props) => { gpu_index: gpu.index, worker_name: gpu.worker_name } - : null + : null, + ...obj }); } else { onOk({ ..._.omit(formdata, ['scheduleType']), - gpu_selector: null + gpu_selector: null, + ...obj }); } }; diff --git a/src/pages/playground/components/ground-images.tsx b/src/pages/playground/components/ground-images.tsx index b2017f1a..8c4dad6d 100644 --- a/src/pages/playground/components/ground-images.tsx +++ b/src/pages/playground/components/ground-images.tsx @@ -480,6 +480,11 @@ const GroundImages: React.FC = forwardRef((props, ref) => { handleAbortFetch={handleStopConversation} shouldResetMessage={false} clearAll={handleClear} + tools={ + + {intl.formatMessage({ id: 'playground.image.prompt' })} + + } />
diff --git a/src/utils/index.ts b/src/utils/index.ts index 8171b543..43e03824 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -128,12 +128,8 @@ export const cosineSimilarity = (vec1: number[], vec2: number[]) => { return dotProduct / (magnitudeA * magnitudeB); }; +const htmlSpecialTags = /^(.|\n|\r)*<\/html>$/i; + 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; - } + return htmlSpecialTags.test(str?.trim()); };