From 16e2ac5b6ca0b369e2e46f9380eecbfb312ef4dd Mon Sep 17 00:00:00 2001 From: jialin Date: Tue, 5 Nov 2024 16:46:58 +0800 Subject: [PATCH] feat: playground embedding --- .gitignore | 2 +- config/routes.ts | 8 + package.json | 1 + pnpm-lock.yaml | 51 ++ src/assets/styles/common.less | 6 + src/components/echarts/bar-chart.tsx | 28 +- src/components/echarts/chart.tsx | 47 +- src/components/echarts/h-bar.tsx | 33 +- src/components/echarts/index.ts | 7 +- src/components/echarts/line-chart.tsx | 30 +- src/components/echarts/scatter.tsx | 189 ++++++++ src/components/echarts/types.ts | 1 + src/global.less | 8 + src/locales/en-US.ts | 1 + src/locales/lang-config-map.tsx | 2 +- src/locales/zh-CN.ts | 1 + src/locales/zh-CN/menu.ts | 3 +- src/pages/playground/apis/index.ts | 16 + .../components/ground-embedding.tsx | 442 ++++++++++++++++++ .../playground/components/ground-left.tsx | 4 +- .../playground/components/ground-reranker.tsx | 37 +- .../components/multiple-chat/model-item.tsx | 4 +- .../playground/components/reranker-params.tsx | 72 ++- .../playground/components/upload-file.tsx | 34 +- .../playground/components/view-code-modal.tsx | 30 +- src/pages/playground/config/embed-data.ts | 430 +++++++++++++++++ src/pages/playground/config/types.ts | 31 +- src/pages/playground/embedding.tsx | 116 +++++ src/pages/playground/index.tsx | 44 +- src/pages/playground/style/file-list.less | 9 +- src/pages/playground/style/ground-left.less | 1 + src/pages/playground/style/play-ground.less | 1 + src/pages/playground/style/rerank.less | 1 + 33 files changed, 1518 insertions(+), 172 deletions(-) create mode 100644 src/components/echarts/scatter.tsx create mode 100644 src/pages/playground/components/ground-embedding.tsx create mode 100644 src/pages/playground/config/embed-data.ts create mode 100644 src/pages/playground/embedding.tsx diff --git a/.gitignore b/.gitignore index b2c0c9ab..1aca2ae4 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,4 @@ /.mfsu .swc .DS_Store -.idea +.idea \ No newline at end of file diff --git a/config/routes.ts b/config/routes.ts index ee6420b5..8a50de9d 100644 --- a/config/routes.ts +++ b/config/routes.ts @@ -25,6 +25,14 @@ export default [ icon: 'Comment', component: './playground/index' }, + { + name: 'embedding', + title: 'embedding', + path: '/playground/embedding', + key: 'embedding', + icon: 'Comment', + component: './playground/embedding' + }, { name: 'rerank', title: 'Rerank', diff --git a/package.json b/package.json index 01dfceca..cc41e7d4 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "react-dom": "^18.2.0", "react-hotkeys-hook": "^4.5.0", "simplebar-react": "^3.2.6", + "umap-js": "^1.4.0", "umi-presets-pro": "^2.0.3", "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 83ae74ad..9d30daff 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -131,6 +131,9 @@ dependencies: simplebar-react: specifier: ^3.2.6 version: 3.2.6(react@18.2.0) + umap-js: + specifier: ^1.4.0 + version: 1.4.0 umi-presets-pro: specifier: ^2.0.3 version: 2.0.3(@babel/core@7.25.7)(@types/react-dom@18.3.0)(@types/react@18.3.1)(antd@5.20.6)(dva@2.5.0-beta.2)(rc-field-form@2.4.0)(react-dom@18.2.0)(react@18.2.0)(umi@4.3.24) @@ -11614,6 +11617,14 @@ packages: is-decimal: 1.0.4 dev: false + /is-any-array@0.1.1: + resolution: {integrity: sha512-qTiELO+kpTKqPgxPYbshMERlzaFu29JDnpB8s3bjg+JkxBpw29/qqSaOdKv2pCdaG92rLGeG/zG2GauX58hfoA==, tarball: https://registry.npmjs.org/is-any-array/-/is-any-array-0.1.1.tgz} + dev: false + + /is-any-array@2.0.1: + resolution: {integrity: sha512-UtilS7hLRu++wb/WBAw9bNuP1Eg04Ivn1vERJck8zJthEvXCBEBpGR/33u/xLKWEQf95803oalHrVDptcAvFdQ==, tarball: https://registry.npmjs.org/is-any-array/-/is-any-array-2.0.1.tgz} + dev: false + /is-arguments@1.1.1: resolution: {integrity: sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==, tarball: https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz} engines: {node: '>= 0.4'} @@ -12922,6 +12933,40 @@ packages: dev: false optional: true + /ml-array-max@1.2.4: + resolution: {integrity: sha512-BlEeg80jI0tW6WaPyGxf5Sa4sqvcyY6lbSn5Vcv44lp1I2GR6AWojfUvLnGTNsIXrZ8uqWmo8VcG1WpkI2ONMQ==, tarball: https://registry.npmjs.org/ml-array-max/-/ml-array-max-1.2.4.tgz} + dependencies: + is-any-array: 2.0.1 + dev: false + + /ml-array-min@1.2.3: + resolution: {integrity: sha512-VcZ5f3VZ1iihtrGvgfh/q0XlMobG6GQ8FsNyQXD3T+IlstDv85g8kfV0xUG1QPRO/t21aukaJowDzMTc7j5V6Q==, tarball: https://registry.npmjs.org/ml-array-min/-/ml-array-min-1.2.3.tgz} + dependencies: + is-any-array: 2.0.1 + dev: false + + /ml-array-rescale@1.3.7: + resolution: {integrity: sha512-48NGChTouvEo9KBctDfHC3udWnQKNKEWN0ziELvY3KG25GR5cA8K8wNVzracsqSW1QEkAXjTNx+ycgAv06/1mQ==, tarball: https://registry.npmjs.org/ml-array-rescale/-/ml-array-rescale-1.3.7.tgz} + dependencies: + is-any-array: 2.0.1 + ml-array-max: 1.2.4 + ml-array-min: 1.2.3 + dev: false + + /ml-levenberg-marquardt@2.1.1: + resolution: {integrity: sha512-2+HwUqew4qFFFYujYlQtmFUrxCB4iJAPqnUYro3P831wj70eJZcANwcRaIMGUVaH9NDKzfYuA4N5u67KExmaRA==, tarball: https://registry.npmjs.org/ml-levenberg-marquardt/-/ml-levenberg-marquardt-2.1.1.tgz} + dependencies: + is-any-array: 0.1.1 + ml-matrix: 6.12.0 + dev: false + + /ml-matrix@6.12.0: + resolution: {integrity: sha512-AGfR+pWaC0GmzjUnB6BfwhndPEUGz0i7QUYdqNuw1zhTov/vSRJ9pP2hs6BoGpaSbtXgrKjZz2zjD1M0xuur6A==, tarball: https://registry.npmjs.org/ml-matrix/-/ml-matrix-6.12.0.tgz} + dependencies: + is-any-array: 2.0.1 + ml-array-rescale: 1.3.7 + dev: false + /mock.js@0.2.0: resolution: {integrity: sha512-DKI8Rh/h7Mma+fg+6aD0uUvwn0QXAjKG6q3s+lTaCboCQ/kvQMBN9IXRBzgEaz4aPiYoRnKU9jVsfZp0mHpWrQ==, tarball: https://registry.npmjs.org/mock.js/-/mock.js-0.2.0.tgz} dev: false @@ -18350,6 +18395,12 @@ packages: resolution: {integrity: sha512-fYmIy7fKTSFAhG3fuPlubeGaMoAd6r0rSnfEsO5nEY55i26KSLt9EH7PLQiiqPUhNqYIJvSkTy1oArIcXAbPbA==, tarball: https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.38.tgz} dev: false + /umap-js@1.4.0: + resolution: {integrity: sha512-xxpviF9wUO6Nxrx+C58SoDgea+h2PnVaRPKDelWv0HotmY6BeWeh0kAPJoumfqUkzUvowGsYfMbnsWI0b9do+A==, tarball: https://registry.npmjs.org/umap-js/-/umap-js-1.4.0.tgz} + dependencies: + ml-levenberg-marquardt: 2.1.1 + dev: false + /umi-presets-pro@2.0.3(@babel/core@7.25.7)(@types/react-dom@18.3.0)(@types/react@18.3.1)(antd@5.20.6)(dva@2.5.0-beta.2)(rc-field-form@2.4.0)(react-dom@18.2.0)(react@18.2.0)(umi@4.3.24): resolution: {integrity: sha512-sHKynw/fi7UeUftzTRPRsrV5GHV4BWvWYhyvwkg8s+shmt0ROPW/52y4gxBziEvetxl8yWMKUCWk50OUDOcrww==, tarball: https://registry.npmjs.org/umi-presets-pro/-/umi-presets-pro-2.0.3.tgz} dependencies: diff --git a/src/assets/styles/common.less b/src/assets/styles/common.less index fac3c66d..bf2fae3f 100644 --- a/src/assets/styles/common.less +++ b/src/assets/styles/common.less @@ -77,6 +77,7 @@ .flex { display: flex; } + // space-between .flex-between { display: flex; @@ -87,6 +88,7 @@ display: flex; justify-content: center; } + // align-items: center .flex-center { display: flex; @@ -168,6 +170,10 @@ margin-bottom: 0; } +.m-b-16 { + margin-bottom: 16px; +} + .font-400 { font-weight: var(--font-weight-normal); } diff --git a/src/components/echarts/bar-chart.tsx b/src/components/echarts/bar-chart.tsx index 21bd6e57..f55abfed 100644 --- a/src/components/echarts/bar-chart.tsx +++ b/src/components/echarts/bar-chart.tsx @@ -10,7 +10,7 @@ import { } from '@/components/echarts/config'; import EmptyData from '@/components/empty-data'; import _ from 'lodash'; -import { memo } from 'react'; +import { memo, useMemo } from 'react'; import { ChartProps } from './types'; const BarChart: React.FC = (props) => { @@ -24,10 +24,6 @@ const BarChart: React.FC = (props) => { title } = props; - if (!seriesData.length) { - return ; - } - const options = { title: { text: '' @@ -55,7 +51,7 @@ const BarChart: React.FC = (props) => { series: [] }; - const setDataOptions = () => { + const dataOptions = useMemo((): any => { const data = _.map(seriesData, (item: any) => { return { ...item, @@ -82,16 +78,20 @@ const BarChart: React.FC = (props) => { }, series: data }; - }; - - const dataOptions: any = setDataOptions(); + }, [seriesData, xAxisData, title]); return ( - + <> + {!seriesData.length ? ( + + ) : ( + + )} + ); }; diff --git a/src/components/echarts/chart.tsx b/src/components/echarts/chart.tsx index af1ba152..bc2acd04 100644 --- a/src/components/echarts/chart.tsx +++ b/src/components/echarts/chart.tsx @@ -1,17 +1,30 @@ import { throttle } from 'lodash'; -import { useCallback, useEffect, useRef } from 'react'; +import { + forwardRef, + useCallback, + useEffect, + useImperativeHandle, + useRef +} from 'react'; import echarts, { ECOption } from '.'; const Chart: React.FC<{ options: ECOption; height: number | string; width: number | string; -}> = ({ options, width, height }) => { + ref?: any; +}> = forwardRef(({ options, width, height }, ref) => { const container = useRef(null); const chart = useRef(); const resizeable = useRef(false); const resizeObserver = useRef(); + useImperativeHandle(ref, () => { + return { + chart: chart.current + }; + }); + const init = useCallback(() => { if (container.current) { chart.current?.clear(); @@ -44,18 +57,9 @@ const Chart: React.FC<{ resizeable.current = false; resize(); setOption(options); + resizeable.current = true; }, [options]); - useEffect(() => { - let timer: any = null; - timer = setTimeout(() => { - resizeable.current = true; - }, 300); - return () => { - clearTimeout(timer); - }; - }, []); - useEffect(() => { const handleResize = throttle(() => { if (resizeable.current) { @@ -75,7 +79,22 @@ const Chart: React.FC<{ }; }, []); - return
; -}; + // resize on window resize + // useEffect(() => { + // const handleResize = throttle(() => { + // chart.current?.resize(); + // }, 100); + // window.addEventListener('resize', handleResize); + // return () => { + // window.removeEventListener('resize', handleResize); + // }; + // }, []); + + return ( +
+
+
+ ); +}); export default Chart; diff --git a/src/components/echarts/h-bar.tsx b/src/components/echarts/h-bar.tsx index 981c01cd..0f883446 100644 --- a/src/components/echarts/h-bar.tsx +++ b/src/components/echarts/h-bar.tsx @@ -9,7 +9,7 @@ import { } from '@/components/echarts/config'; import EmptyData from '@/components/empty-data'; import _ from 'lodash'; -import { memo } from 'react'; +import { memo, useMemo } from 'react'; import { ChartProps } from './types'; const BarChart: React.FC = (props) => { @@ -22,12 +22,12 @@ const BarChart: React.FC = (props) => { legendData, title } = props; - if (!seriesData.length) { - return ; - } const options = { - title: titleConfig, + title: { + ...titleConfig, + left: 'start' + }, grid, tooltip: { ...tooltip @@ -48,7 +48,7 @@ const BarChart: React.FC = (props) => { series: [] }; - const setDataOptions = () => { + const dataOptions = useMemo((): any => { const data = _.map(seriesData, (item: any) => { return { ...item, @@ -69,7 +69,6 @@ const BarChart: React.FC = (props) => { animation: false, title: { ...options.title, - left: 'start', text: title }, yAxis: { @@ -103,16 +102,20 @@ const BarChart: React.FC = (props) => { }, series: data }; - }; - - const dataOptions: any = setDataOptions(); + }, [seriesData, xAxisData, title]); return ( - + <> + {!seriesData.length ? ( + + ) : ( + + )} + ); }; diff --git a/src/components/echarts/index.ts b/src/components/echarts/index.ts index 7744d9ed..cf15aa39 100644 --- a/src/components/echarts/index.ts +++ b/src/components/echarts/index.ts @@ -1,9 +1,10 @@ import type { BarSeriesOption, GaugeSeriesOption, - LineSeriesOption + LineSeriesOption, + ScatterSeriesOption } from 'echarts/charts'; -import { BarChart, GaugeChart, LineChart } from 'echarts/charts'; +import { BarChart, GaugeChart, LineChart, ScatterChart } from 'echarts/charts'; import type { DatasetComponentOption, GridComponentOption, @@ -32,6 +33,7 @@ type ECOption = ComposeOption< | GridComponentOption | DatasetComponentOption | GaugeSeriesOption + | ScatterSeriesOption >; // register components and charts @@ -44,6 +46,7 @@ echarts.use([ TransformComponent, BarChart, LineChart, + ScatterChart, GaugeChart, LabelLayout, UniversalTransition, diff --git a/src/components/echarts/line-chart.tsx b/src/components/echarts/line-chart.tsx index 075b6103..e09e5025 100644 --- a/src/components/echarts/line-chart.tsx +++ b/src/components/echarts/line-chart.tsx @@ -10,7 +10,7 @@ import { } from '@/components/echarts/config'; import EmptyData from '@/components/empty-data'; import _ from 'lodash'; -import { memo } from 'react'; +import { memo, useMemo } from 'react'; import { ChartProps } from './types'; const LineChart: React.FC = (props) => { @@ -26,9 +26,6 @@ const LineChart: React.FC = (props) => { smooth, title } = props; - if (!seriesData.length) { - return ; - } const options = { title: { @@ -59,7 +56,7 @@ const LineChart: React.FC = (props) => { series: [] }; - const generateOptions = (): any => { + const dataOptions = useMemo((): any => { const data = _.map(seriesData, (item: any) => { return { ...item, @@ -75,7 +72,7 @@ const LineChart: React.FC = (props) => { } }; }); - const optionsConfig = { + return { ...options, animation: false, title: { @@ -92,15 +89,20 @@ const LineChart: React.FC = (props) => { }, series: data }; - return optionsConfig; - }; - const dataOptions = generateOptions(); + }, [seriesData, xAxisData, yAxisName, title, smooth, legendData]); + return ( - + <> + {!seriesData.length ? ( + + ) : ( + + )} + ); }; diff --git a/src/components/echarts/scatter.tsx b/src/components/echarts/scatter.tsx new file mode 100644 index 00000000..a962398f --- /dev/null +++ b/src/components/echarts/scatter.tsx @@ -0,0 +1,189 @@ +import Chart from '@/components/echarts/chart'; +import { grid, title as titleConfig } from '@/components/echarts/config'; +import EmptyData from '@/components/empty-data'; +import _ from 'lodash'; +import { memo, useCallback, useMemo, useRef } from 'react'; +import { ChartProps } from './types'; + +const options: any = { + animation: false, + grid: { + ...grid, + right: -1, + top: -1, + bottom: -1, + left: -1, + containLabel: true + }, + xAxis: { + slient: true, + splitNumber: 15, + splitLine: { + lineStyle: { + color: 'rgba(5,5,5,0.06)' + } + }, + axisLine: { + show: false + }, + axisTick: { + show: false + }, + axisLabel: { + show: false + } + }, + yAxis: { + slient: true, + splitNumber: 10, + splitLine: { + lineStyle: { + color: 'rgba(5,5,5,0.06)' + } + }, + axisLine: { + show: false + }, + axisTick: { + show: false + }, + axisLabel: { + show: false + } + }, + symbol: 'roundRect', + label: { + show: true, + shadowColor: 'none', + textBorderColor: 'none', + formatter: (params: any) => { + return params.name; + } + }, + series: [] +}; + +const Scatter: React.FC = (props) => { + const { + seriesData, + xAxisData, + height, + width, + showEmpty, + labelFormatter, + legendData, + title + } = props; + + const chart = useRef(null); + + const findOverlappingPoints = useCallback( + (data: any[], currentPoint: any) => { + const overlappingPoints = []; + const symbolRadius = 16; + + const [x1, y1] = chart.current.chart?.convertToPixel( + 'grid', + currentPoint.value + ); + + const pixelPoints = data.map((point) => { + return { + ...point, + value: chart.current.chart?.convertToPixel('grid', point.value) + }; + }); + + for (let j = 0; j < pixelPoints.length; j++) { + if (currentPoint.name === pixelPoints[j].name) { + overlappingPoints.push({ ...pixelPoints[j] }); + continue; + } + const [x2, y2] = pixelPoints[j].value; + + const distance = Math.sqrt( + Math.pow(_.round(x2 - x1, 2), 2) + Math.pow(_.round(y2 - y1, 2), 2) + ); + + if (distance <= symbolRadius) { + overlappingPoints.push({ ...pixelPoints[j] }); + } + } + + return overlappingPoints; + }, + [] + ); + + const dataOptions = useMemo((): any => { + if (!seriesData.length) { + options.xAxis.min = 0; + options.xAxis.max = 1; + options.yAxis.min = 0; + options.yAxis.max = 1; + } else { + options.xAxis.min = null; + options.xAxis.max = null; + options.yAxis.min = null; + options.yAxis.max = null; + } + const seriseDataList = seriesData.map((item: any, index: number) => { + return { + ...item, + itemStyle: { + color: '#5470c6' + }, + symbolSize: 16 + }; + }); + return { + ...options, + tooltip: { + trigger: 'item', + borderWidth: 0, + formatter(params: any, callback?: (val: any) => any) { + const dataList = findOverlappingPoints(seriseDataList, params.data); + let result = ''; + dataList.forEach((item: any) => { + result += ` + + + ${item.name} + + ${item.text} + `; + }); + return `
${result}
`; + } + }, + title: { + ...titleConfig, + text: title + }, + series: { + type: 'scatter', + data: seriseDataList + } + }; + }, [seriesData, xAxisData, title, findOverlappingPoints]); + + return ( + <> + {!seriesData.length && showEmpty ? ( + + ) : ( + + )} + + ); +}; + +export default memo(Scatter); diff --git a/src/components/echarts/types.ts b/src/components/echarts/types.ts index 839100e9..0b82ef47 100644 --- a/src/components/echarts/types.ts +++ b/src/components/echarts/types.ts @@ -1,5 +1,6 @@ export interface ChartProps { seriesData: any[]; + showEmpty?: boolean; xAxisData: string[]; legendData?: string[]; labelFormatter?: (val?: any) => string; diff --git a/src/global.less b/src/global.less index 34d210b7..323d19cc 100644 --- a/src/global.less +++ b/src/global.less @@ -255,6 +255,7 @@ body { } } } + // input .ant-input-css-var.ant-input { height: 40px; @@ -278,6 +279,7 @@ body { border: none; box-shadow: none; } + // input number .ant-input-number-outlined.ant-input-number-status-error:not( .ant-input-number-disabled @@ -436,6 +438,7 @@ body { } } } + // ======== menu style end ============ .ant-menu-submenu-popup { .ant-menu-sub { @@ -524,6 +527,7 @@ body { .ant-menu-submenu-popup > .ant-menu { border-radius: var(--menu-border-radius-base); } + // ======== monaco editor style ============ .monaco-editor { border-radius: 8px; @@ -686,6 +690,7 @@ body { .ant-segmented .ant-segmented-item::after { border-radius: var(--border-radius-mini); } + // =============== segment end =============== .background { @@ -769,6 +774,7 @@ body { font-size: 11px; background-color: rgba(255, 255, 255, 80%); min-width: 100px; + max-width: 360px; .tooltip-x-name { font-size: var(--font-size-base); @@ -788,6 +794,8 @@ body { .tooltip-value { margin-left: 10px; color: var(--ant-color-text); + text-overflow: ellipsis; + overflow: hidden; } } } diff --git a/src/locales/en-US.ts b/src/locales/en-US.ts index d81ebb08..0e2cc473 100644 --- a/src/locales/en-US.ts +++ b/src/locales/en-US.ts @@ -3,6 +3,7 @@ * @example Directories like 'en-US' or 'zh-CN' should correspond exactly to the configuration names in lang-config-map.ts. */ +// @ts-ignore const requireContext = require.context(`./en-US`, false, /\.ts$/); let languageConfig: Record = {}; diff --git a/src/locales/lang-config-map.tsx b/src/locales/lang-config-map.tsx index 25d496b7..2d762ba5 100644 --- a/src/locales/lang-config-map.tsx +++ b/src/locales/lang-config-map.tsx @@ -3,7 +3,7 @@ import IconFont from '@/components/icon-font'; /** * Language configuration map * Warning: The key of the map must be the same as the directory name in the locales directory - * Do not modify the key of the map + * Do not modify the key of the map !!! * */ const langConfigMap = { diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index 7c42cbd6..98e8d08f 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -3,6 +3,7 @@ * @example Directories like 'en-US' or 'zh-CN' should correspond exactly to the configuration names in lang-config-map.ts. */ +// @ts-ignore const requireContext = require.context(`./zh-CN`, false, /\.ts$/); let languageConfig: Record = {}; diff --git a/src/locales/zh-CN/menu.ts b/src/locales/zh-CN/menu.ts index 3963bca3..ef313f7a 100644 --- a/src/locales/zh-CN/menu.ts +++ b/src/locales/zh-CN/menu.ts @@ -1,7 +1,8 @@ export default { 'menu.dashboard': '概览', 'menu.playground': '试验场', - 'menu.playground.rerank': 'Rerank', + 'menu.playground.rerank': '重排', + 'menu.playground.embedding': '文本嵌入', 'menu.playground.chat': '对话', 'menu.compare': '多模型对比', 'menu.models': '模型', diff --git a/src/pages/playground/apis/index.ts b/src/pages/playground/apis/index.ts index c2c2d3ee..8b4703c5 100644 --- a/src/pages/playground/apis/index.ts +++ b/src/pages/playground/apis/index.ts @@ -2,6 +2,8 @@ import { request } from '@umijs/max'; export const CHAT_API = '/v1-openai/chat/completions'; +export const EMBEDDING_API = '/v1-openai/embeddings'; + export const OPENAI_MODELS = '/v1-openai/models'; export const RERANKER_API = '/rerank'; @@ -35,3 +37,17 @@ export const rerankerQuery = async ( cancelToken: options?.cancelToken }); }; + +export const handleEmbedding = async ( + params: { + model: string; + input: string[]; + }, + options?: any +) => { + return request(`${EMBEDDING_API}`, { + method: 'POST', + data: params, + cancelToken: options?.cancelToken + }); +}; diff --git a/src/pages/playground/components/ground-embedding.tsx b/src/pages/playground/components/ground-embedding.tsx new file mode 100644 index 00000000..c2755b27 --- /dev/null +++ b/src/pages/playground/components/ground-embedding.tsx @@ -0,0 +1,442 @@ +import ScatterChart from '@/components/echarts/scatter'; +import useOverlayScroller from '@/hooks/use-overlay-scroller'; +import useRequestToken from '@/hooks/use-request-token'; +import { + ClearOutlined, + LoadingOutlined, + PlusOutlined, + ThunderboltOutlined, + UploadOutlined +} from '@ant-design/icons'; +import { useIntl, useSearchParams } from '@umijs/max'; +import { Button, Tooltip } from 'antd'; +import classNames from 'classnames'; +import 'overlayscrollbars/overlayscrollbars.css'; +import { + forwardRef, + memo, + useEffect, + useImperativeHandle, + useMemo, + useRef, + useState +} from 'react'; +import { UMAP } from 'umap-js'; +import { handleEmbedding } from '../apis'; +import { MessageItem, ParamsSchema } from '../config/types'; +import '../style/ground-left.less'; +import '../style/rerank.less'; +import '../style/system-message-wrap.less'; +import FileList from './file-list'; +import InputList from './input-list'; +import RerankerParams from './reranker-params'; +import UploadFile from './upload-file'; +import ViewCodeModal from './view-code-modal'; + +interface MessageProps { + modelList: Global.BaseOption[]; + loaded?: boolean; + ref?: any; +} + +const paramsConfig: ParamsSchema[] = [ + { + type: 'Select', + name: 'truncate', + label: { + text: 'Truncate', + isLocalized: false + }, + options: [ + { + label: 'None', + value: 'none' + }, + { + label: 'Start', + value: 'start' + }, + { + label: 'End', + value: 'end' + } + ], + rules: [ + { + required: true, + message: 'Please select truncate' + } + ] + } +]; + +const initialValues = { + truncate: 'none' +}; + +const GroundReranker: React.FC = forwardRef((props, ref) => { + const { modelList } = props; + const acceptType = + '.txt, .doc, .docx, .xls, .xlsx, .csv, .md, .pdf, .eml, .msg, .ppt, .pptx, .xml, .epub, .html'; + const messageId = useRef(0); + const [messageList, setMessageList] = useState([]); + + const intl = useIntl(); + const requestSource = useRequestToken(); + const [searchParams] = useSearchParams(); + const selectModel = searchParams.get('model') || ''; + const [parameters, setParams] = useState({}); + const [show, setShow] = useState(false); + const [loading, setLoading] = useState(false); + const [tokenResult, setTokenResult] = useState(null); + const [collapse, setCollapse] = useState(false); + const contentRef = useRef(''); + const scroller = useRef(null); + const inputListRef = useRef(null); + const paramsRef = useRef(null); + const messageListLengthCache = useRef(0); + const requestToken = useRef(null); + const [fileList, setFileList] = useState< + { text: string; name: string; uid: number | string }[] + >([]); + + const [textList, setTextList] = useState< + { text: string; uid: number | string; name: string }[] + >([ + { + text: '', + uid: -1, + name: '' + }, + { + text: '', + uid: -2, + name: '' + } + ]); + + const [scatterData, setScatterData] = useState([]); + + const { initialize, updateScrollerPosition } = useOverlayScroller(); + const { + initialize: innitializeParams, + updateScrollerPosition: updateDocumentScrollerPosition + } = useOverlayScroller(); + + useImperativeHandle(ref, () => { + return { + viewCode() { + setShow(true); + }, + setCollapse() { + setCollapse(!collapse); + } + }; + }); + + const inputEmpty = useMemo(() => { + const list = [...textList, ...fileList].filter((item) => item.text); + return list.length < 2; + }, [textList, fileList]); + + const generateEmbedding = (embeddings: any[]) => { + try { + const umap = new UMAP({ + // random() { + // return 0.1; + // }, + // minDist: 0.1, + nComponents: 2, + nNeighbors: 1 + }); + + const dataList = embeddings.map((item) => { + return item.embedding; + }); + + const embedding = umap.fit([...dataList, ...dataList]); + + const list = embedding.map((item: number[], index: number) => { + return { + value: item, + name: index + 1, + text: `test test test test test` + }; + }); + setScatterData(list); + } catch (e) { + // console.log('error:', e); + } + }; + + const setMessageId = () => { + messageId.current = messageId.current + 1; + }; + + const handleStopConversation = () => { + requestToken.current?.cancel?.(); + setLoading(false); + }; + + const submitMessage = async (current?: { role: string; content: string }) => { + if (!parameters.model) return; + try { + setLoading(true); + setMessageId(); + setTokenResult(null); + + requestToken.current?.cancel?.(); + requestToken.current = requestSource(); + + contentRef.current = current?.content || ''; + + const result: any = await handleEmbedding( + { + model: parameters.model, + input: [ + ...textList.map((item) => item.text), + ...fileList.map((item) => item.text) + ] + }, + { + token: requestToken.current.token + } + ); + console.log('result:', result); + + setTokenResult(result.usage); + + const embeddingsList = result.data || []; + + console.log('embeddings:', embeddingsList); + + generateEmbedding(embeddingsList); + } catch (error: any) { + console.log('error========', error); + setTokenResult({ + error: true, + errorMessage: error.response?.data?.error?.message + }); + } finally { + setLoading(false); + } + }; + const handleClear = () => { + if (!messageList.length) { + return; + } + setMessageId(); + setScatterData([]); + setTokenResult(null); + }; + + const handleSendMessage = () => { + submitMessage(); + }; + + const handleCloseViewCode = () => { + setShow(false); + }; + + const handleUpdateFileList = ( + files: { text: string; name: string; uid: number | string }[] + ) => { + console.log('files:', files); + setFileList((preList) => { + return [...preList, ...files]; + }); + }; + + const handleDeleteFile = (uid: number | string) => { + setFileList((preList) => { + return preList.filter((item) => item.uid !== uid); + }); + }; + const handleAddText = () => { + inputListRef.current?.handleAdd(); + }; + + const handleTextListChange = ( + list: { text: string; uid: number | string; name: string }[] + ) => { + setTextList(list); + }; + + const handleClearDocuments = () => { + setTextList([ + { + text: '', + uid: -1, + name: '' + }, + { + text: '', + uid: -2, + name: '' + } + ]); + setFileList([]); + setScatterData([]); + }; + + useEffect(() => { + setMessageId(); + setScatterData([]); + setTokenResult(null); + }, [parameters.model]); + + useEffect(() => { + if (scroller.current) { + initialize(scroller.current); + } + }, [scroller.current, initialize]); + + useEffect(() => { + if (paramsRef.current) { + innitializeParams(paramsRef.current); + } + }, [paramsRef.current, innitializeParams]); + + useEffect(() => { + updateScrollerPosition(); + }, [messageList]); + + useEffect(() => { + if (textList.length + fileList.length > messageListLengthCache.current) { + updateDocumentScrollerPosition(); + } + messageListLengthCache.current = textList.length + fileList.length; + }, [textList.length, fileList.length]); + + return ( +
+
+
+
+
+

+ Documents +

+
+ + Support: {acceptType}}> + + + + + + +
+
+
+ +
+ +
+
+
+
+ +
+

+ Output +

+
+ +
+
+
+
+
+ +
+
+ + item.text), + ...fileList.map((item) => item.text) + ].filter((text) => text) + }} + parameters={{ + ...parameters + }} + onCancel={handleCloseViewCode} + title={intl.formatMessage({ id: 'playground.viewcode' })} + > +
+ ); +}); + +export default memo(GroundReranker); diff --git a/src/pages/playground/components/ground-left.tsx b/src/pages/playground/components/ground-left.tsx index 0d923dfb..3c51603e 100644 --- a/src/pages/playground/components/ground-left.tsx +++ b/src/pages/playground/components/ground-left.tsx @@ -330,7 +330,9 @@ const GroundLeft: React.FC = forwardRef((props, ref) => { = forwardRef((props, ref) => { const { modelList } = props; const acceptType = @@ -145,7 +169,7 @@ const GroundReranker: React.FC = forwardRef((props, ref) => { content: result.results?.map((item: any) => { return { uid: item.index, - text: `${item.document?.slice(0, 500) || ''}`, + text: `${item.document?.text?.slice(0, 500) || ''}`, docIndex: item.index, title: documentList[item.index]?.name || '', score: item.relevance_score, @@ -287,7 +311,7 @@ const GroundReranker: React.FC = forwardRef((props, ref) => {

Documents

-
+
{/* = forwardRef((props, ref) => { Add Text + > + {intl.formatMessage({ id: 'common.button.clear' })} +
@@ -366,6 +391,8 @@ const GroundReranker: React.FC = forwardRef((props, ref) => { diff --git a/src/pages/playground/components/multiple-chat/model-item.tsx b/src/pages/playground/components/multiple-chat/model-item.tsx index 55fc42b4..a1d55436 100644 --- a/src/pages/playground/components/multiple-chat/model-item.tsx +++ b/src/pages/playground/components/multiple-chat/model-item.tsx @@ -466,7 +466,9 @@ const ModelItem: React.FC = forwardRef(
; model?: string; modelList: Global.BaseOption[]; onValuesChange?: (changeValues: any, value: Record) => void; setParams: (params: any) => void; - globalParams?: ParamsSettingsFormProps; + globalParams?: Record; + paramsConfig?: ParamsSchema[]; + initialValues?: Record; }; const ParamsSettings: React.FC = ({ - selectedModel, setParams, - globalParams, onValuesChange, + selectedModel, + globalParams, + initialValues, + paramsConfig, modelList, showModelSelector = true }) => { const intl = useIntl(); - const initialValues = { - top_n: 1 - }; const [form] = Form.useForm(); const formId = useId(); @@ -59,7 +61,7 @@ const ParamsSettings: React.FC = ({ ...initialValues }); } - }, [modelList, showModelSelector, selectedModel]); + }, [modelList, showModelSelector, selectedModel, initialValues]); const handleOnFinish = (values: any) => { console.log('handleOnFinish', values); @@ -102,6 +104,45 @@ const ParamsSettings: React.FC = ({ form.setFieldsValue(globalParams); }, [globalParams]); + const renderFields = useCallback(() => { + console.log('paramsConfig:', paramsConfig); + if (!paramsConfig?.length) { + return null; + } + return paramsConfig.map((item: ParamsSchema) => { + if (item.type === 'InputNumber') { + return ( + + + + ); + } + if (item.type === 'Select') { + return ( + + + + ); + } + return null; + }); + }, [paramsConfig]); + const renderLabel = (args: { field: string; label: string; @@ -148,7 +189,9 @@ const ParamsSettings: React.FC = ({
{ <> -

Parameters

+

+ {intl.formatMessage({ id: 'playground.parameters' })} +

name="model" rules={[ @@ -171,16 +214,7 @@ const ParamsSettings: React.FC = ({ } - - name="top_n" - rules={[{ required: true }]} - > - - + {renderFields()}
); diff --git a/src/pages/playground/components/upload-file.tsx b/src/pages/playground/components/upload-file.tsx index 1feb0d46..a71b663e 100644 --- a/src/pages/playground/components/upload-file.tsx +++ b/src/pages/playground/components/upload-file.tsx @@ -56,39 +56,19 @@ const UploadImg: React.FC = ({ const newFileList = await Promise.all( fileList.map(async (item: UploadFile) => { if (wordReg.test(item.name)) { - const context = await readWordContent( - item.originFileObj as RcFile - ); - - item.url = context; + item.url = await readWordContent(item.originFileObj as RcFile); } else if (excelReg.test(item.name)) { - const context = await readExcelContent( - item.originFileObj as RcFile - ); - item.url = context; + item.url = await readExcelContent(item.originFileObj as RcFile); } else if (epubReg.test(item.name)) { - const context = await readEpubContent( - item.originFileObj as RcFile - ); - item.url = context; + item.url = await readEpubContent(item.originFileObj as RcFile); } else if (pdfReg.test(item.name)) { - const context = await readPDFContent( - item.originFileObj as RcFile - ); - item.url = context; + item.url = await readPDFContent(item.originFileObj as RcFile); } else if (pptReg.test(item.name)) { - const context = await readPptxContent( - item.originFileObj as RcFile - ); - item.url = context; + item.url = await readPptxContent(item.originFileObj as RcFile); } else if (htmlReg.test(item.name)) { - const context = await readHtmlContent( - item.originFileObj as RcFile - ); - item.url = context; + item.url = await readHtmlContent(item.originFileObj as RcFile); } else { - const context = await readBlob(item.originFileObj as RcFile); - item.url = context; + item.url = await readBlob(item.originFileObj as RcFile); } return item; }) diff --git a/src/pages/playground/components/view-code-modal.tsx b/src/pages/playground/components/view-code-modal.tsx index 0c7eec1a..49f23cf8 100644 --- a/src/pages/playground/components/view-code-modal.tsx +++ b/src/pages/playground/components/view-code-modal.tsx @@ -8,7 +8,8 @@ import React, { useMemo, useState } from 'react'; type ViewModalProps = { systemMessage?: string; - messageList: any[]; + messageList?: any[]; + payLoad: Record; parameters: any; title: string; open: boolean; @@ -34,6 +35,7 @@ const ViewCodeModal: React.FC = (props) => { open, onCancel, messageList, + payLoad, parameters = {}, apiType = 'chat' } = props || {}; @@ -47,13 +49,26 @@ const ViewCodeModal: React.FC = (props) => { const logcommand = apiType === 'chat' ? 'choices[0].message.content' : 'data[0].embedding'; + const formatPyParams = (params: any) => { + return _.keys(params).reduce((acc: string, key: string) => { + if (params[key] === null) { + return acc; + } + const value = + typeof params[key] === 'object' + ? JSON.stringify(params[key], null, 2) + : `"${params[key]}"`; + return acc + ` ${key}=${value},\n`; + }, ''); + }; + const codeValue = useMemo(() => { if (lang === langMap.shell) { const messages = messageList; const code = `curl ${window.location.origin}/v1-openai/${api} \\\n-H "Content-Type: application/json" \\\n-H "Authorization: Bearer $\{YOUR_GPUSTACK_API_KEY}" \\\n-d '${JSON.stringify( { ...parameters, - ...(messages.length > 0 ? { messages } : {}) + ...payLoad }, null, 2 @@ -65,7 +80,7 @@ const ViewCodeModal: React.FC = (props) => { const code = `const OpenAI = require("openai");\n\nconst openai = new OpenAI({\n "apiKey": "YOUR_GPUSTACK_API_KEY",\n "baseURL": "${BaseURL}"\n});\n\nasync function main(){\n const params = ${JSON.stringify( { ...parameters, - ...(messages.length > 0 ? { messages } : {}) + ...payLoad }, null, 4 @@ -87,15 +102,12 @@ const ViewCodeModal: React.FC = (props) => { }, '' ); - const messages = - apiType === 'chat' - ? `messages=${JSON.stringify(messageList, null, 2)}` - : ''; - const code = `from openai import OpenAI\n\nclient = OpenAI(\n base_url="${BaseURL}", \n api_key="YOUR_GPUSTACK_API_KEY"\n)\n\nresponse = client.${ClientType}.create(\n${formattedParams} ${messages})\nprint(response.${logcommand})`; + const params = apiType === 'chat' ? formatPyParams(payLoad) : ''; + const code = `from openai import OpenAI\n\nclient = OpenAI(\n base_url="${BaseURL}", \n api_key="YOUR_GPUSTACK_API_KEY"\n)\n\nresponse = client.${ClientType}.create(\n${formattedParams} ${params})\nprint(response.${logcommand})`; return code; } return ''; - }, [lang, messageList, parameters]); + }, [lang, payLoad, parameters]); const handleOnChangeLang = (value: string) => { setLang(value); diff --git a/src/pages/playground/config/embed-data.ts b/src/pages/playground/config/embed-data.ts new file mode 100644 index 00000000..668f7f7b --- /dev/null +++ b/src/pages/playground/config/embed-data.ts @@ -0,0 +1,430 @@ +const data = { + id: '6d532ab7-ee33-485a-bda4-cc8bea2c3f3d', + texts: ['rtertertterter', 'rtertertterter'], + embeddings: [ + [ + 0.050720215, -0.025253296, 0.018859863, -0.060180664, -0.008003235, + 0.02192688, -0.020126343, 0.0068893433, 0.040252686, 0.08441162, + 0.025665283, 0.0036411285, 0.03982544, -0.0021705627, -0.035705566, + 0.01020813, 0.025894165, 0.018508911, 0.01966858, -0.026672363, + 0.017089844, -0.010887146, 0.0019197464, 0.009437561, -0.015419006, + 0.06439209, 0.04019165, -0.015975952, -0.02067566, -0.016555786, + -0.0010957718, -0.01838684, 0.045898438, 0.0023231506, -0.022155762, + 0.011688232, -0.020401001, -0.026412964, -0.02255249, 0.0013628006, + -0.026275635, 0.018966675, -0.010017395, -0.049316406, -0.07763672, + 0.0066070557, -0.039245605, 0.04776001, 0.039733887, -0.019332886, + 0.0005726814, 0.017242432, 0.0050201416, -0.017471313, -0.015403748, + 0.02255249, 0.001572609, -0.03491211, 0.02078247, 0.011054993, + 0.006095886, 0.0012397766, 0.023040771, 0.025466919, 0.027023315, + 0.035583496, 0.08203125, 0.011604309, 0.022216797, -0.026992798, + -0.04067993, -0.0070381165, 0.03677368, -0.02748108, -0.0335083, + 0.025543213, 0.005680084, 0.0107803345, 0.035949707, -0.04876709, + 0.095825195, 0.0022659302, 0.07824707, 0.012763977, -0.005420685, + 0.011138916, 0.029067993, -0.03390503, -0.011413574, -0.013313293, + -0.019592285, 0.042510986, -0.042785645, 0.030960083, -0.016403198, + 0.0018463135, 0.022537231, -0.0011920929, -0.044311523, -0.018127441, + 0.01953125, -0.029327393, 0.021957397, -0.011230469, 0.0149002075, + 0.035949707, -0.012054443, 0.070495605, 0.07702637, 0.020904541, + 0.008781433, 0.049804688, -0.027801514, 0.008415222, -0.030349731, + 0.02470398, -0.042541504, -0.0023899078, -0.0049552917, -0.0027923584, + -0.02558899, 0.025939941, 0.012519836, -0.090270996, -0.0047836304, + -0.02619934, -0.017822266, -0.016662598, 0.022766113, 0.012741089, + -0.0014429092, 0.040161133, 0.0011053085, -0.019882202, -0.039733887, + 0.013244629, 0.022369385, 0.032043457, 0.009048462, 0.046539307, + 0.019546509, -0.03488159, 0.022445679, 0.0027885437, 0.002456665, + 0.035339355, 0.036834717, -0.018630981, -0.030380249, -0.004989624, + -0.042114258, 0.0056419373, 0.016189575, 0.011451721, -0.034851074, + -0.0005874634, -0.06793213, 0.0044517517, 0.010971069, 0.006412506, + 0.014167786, -0.007965088, -0.04449463, -0.029205322, -0.076660156, + 0.0044059753, 0.047851562, 0.025344849, 0.00012153387, 0.07354736, + -0.044189453, 0.043395996, 0.025848389, 0.049072266, -0.0019721985, + -0.0046691895, -0.0004079342, 0.006008148, 0.027114868, -0.042541504, + -0.04498291, -0.049926758, 0.020126343, -0.0037727356, -0.025283813, + 0.009117126, -0.027618408, 0.0058937073, 0.068847656, -0.006713867, + -0.017364502, -0.026062012, 0.06549072, -0.021942139, 0.0008788109, + -0.057128906, -0.023498535, 0.014709473, -0.02331543, -0.0158844, + 0.008895874, 0.040802002, -0.03564453, -0.00333786, -0.038757324, + -0.030136108, -0.0037994385, 0.030578613, -0.012077332, -0.001540184, + 0.023529053, -0.034606934, -0.02178955, 0.023590088, -0.017700195, + -0.04168701, 0.0072021484, -0.018508911, -0.0042686462, -0.046661377, + 0.03805542, 0.039154053, 0.0031318665, 0.07269287, 0.018325806, + 0.021957397, -0.02003479, 0.028549194, 0.04058838, 0.03149414, + -0.012687683, -0.024353027, 0.01612854, 0.02494812, -0.035095215, + 0.017822266, 0.021865845, 0.0592041, -0.015838623, -0.0044555664, + 0.010139465, 0.0021953583, -0.04309082, 0.021942139, -0.005607605, + -0.056671143, -0.013801575, 0.03338623, -0.00020134449, 0.09112549, + 0.022399902, 0.016906738, -0.0017642975, -0.012428284, -0.0362854, + 0.022735596, 0.013328552, -0.0066070557, -0.033294678, 0.01398468, + 0.0057754517, 0.005077362, -0.037017822, 0.013420105, 0.08148193, + -0.03665161, 0.024368286, -0.0016231537, -0.02973938, 0.0023231506, + 0.029296875, -0.035705566, -0.00680542, 0.051330566, 0.019592285, + -0.042633057, -0.030792236, 0.008384705, 0.0121536255, 0.014945984, + -0.009254456, 0.009719849, -0.029510498, -0.02015686, 0.05722046, + 0.02319336, -0.021194458, -0.050933838, -0.021987915, 0.026473999, + 0.03729248, 0.043640137, 0.022491455, -0.018341064, 0.029937744, + 0.004016876, 0.10595703, 0.014282227, 0.0027809143, 0.010871887, + 0.022613525, 0.049621582, 0.041229248, -0.029891968, -0.003320694, + -0.011787415, 0.004383087, 0.016998291, -0.010032654, -0.008041382, + -0.03692627, 0.031036377, 0.0129470825, -0.014122009, -0.019683838, + -0.05117798, -0.012664795, -0.020492554, -0.06341553, -0.030059814, + 0.050567627, -0.03253174, -0.010299683, 0.035095215, -0.023651123, + -0.011520386, 0.072143555, 0.0026130676, -0.028778076, 0.04336548, + 0.06500244, 0.049957275, 0.008773804, -0.010055542, 0.008117676, + 0.016036987, 0.013168335, -0.023147583, -0.023757935, -0.0026760101, + 0.006137848, -0.05105591, 0.00415802, -0.027130127, -0.027694702, + 0.024108887, -0.046569824, 0.009689331, 0.034698486, -0.0017528534, + -0.029556274, -0.018173218, -0.021865845, 0.0023612976, 0.024719238, + -0.026412964, -0.02180481, 0.03765869, 0.026000977, -0.04714966, + -0.016921997, -0.05758667, -0.054748535, 0.024841309, 0.012245178, + 0.007209778, -0.011512756, 0.024383545, -0.017684937, 0.03744507, + 0.029449463, -0.026687622, -0.0030841827, -0.029632568, -0.04284668, + -0.016342163, -0.014312744, -0.050567627, -0.022583008, -0.02734375, + -0.019989014, -0.035064697, 0.05279541, -0.0027122498, -0.02053833, + 0.057525635, 0.007511139, -0.0078125, 0.045898438, -0.0032424927, + 0.031051636, 0.035308838, -0.0138549805, -0.0050201416, -0.016052246, + -0.026550293, 0.02520752, 0.036895752, -0.053710938, 0.0058937073, + 0.026107788, 0.011451721, -0.017547607, -0.013244629, 0.02998352, + -0.017974854, 0.041381836, -0.030639648, 0.0073928833, -0.047302246, + 0.023864746, -0.034423828, -0.003648758, -0.05065918, 0.011138916, + -0.04852295, 0.0055122375, -0.016189575, -0.0057640076, 0.0034179688, + 0.03491211, -0.012741089, 0.01234436, 0.023269653, 0.010360718, + 0.008384705, -0.021636963, -0.014778137, 0.026123047, 0.040008545, + 0.012611389, 0.0022697449, 0.012626648, 0.041900635, -0.051696777, + 0.048339844, -0.019607544, -0.026443481, 0.011444092, -0.087524414, + 0.03894043, 0.030303955, 0.0050468445, 0.01423645, -0.03149414, + 0.027404785, 0.035705566, 0.02192688, -0.033203125, -0.017684937, + -0.020599365, -0.0021133423, 0.024536133, 0.04272461, 0.013031006, + 0.06451416, -0.020019531, 0.02520752, 0.04586792, -0.009757996, + 0.014183044, -0.001783371, -0.036743164, 0.0028133392, 0.0010175705, + -0.00422287, 0.041503906, -0.005466461, -0.013252258, 0.008262634, + -0.0030021667, -0.0049324036, -0.013511658, -0.03164673, 0.037475586, + 0.0029945374, 0.00015115738, -0.010971069, -0.022445679, -0.020614624, + -0.01626587, 0.0262146, -0.0037288666, -0.057128906, -0.06072998, + 0.014945984, -0.05984497, -0.0059280396, -0.016662598, 0.019958496, + -0.03164673, 0.021148682, 0.02230835, -0.03527832, -0.014122009, + 0.021911621, 0.032958984, -0.088012695, 0.0036849976, -0.011276245, + -0.06100464, 0.031280518, -0.008308411, -0.009002686, 0.033081055, + -0.029373169, 0.040161133, 0.035125732, 0.021850586, 0.04827881, + 0.034210205, 0.02708435, 0.018005371, 0.010238647, -0.02041626, + -0.026260376, 0.052246094, -0.014007568, -0.017105103, -0.014526367, + -0.018463135, -0.011711121, -0.026062012, 0.017852783, 0.054138184, + 0.012672424, -0.035980225, 0.043273926, -0.024230957, -0.008758545, + -0.018615723, 0.01676941, -0.018859863, -0.0209198, 0.035064697, + -0.014350891, -0.020828247, 0.008285522, -0.003068924, -0.016143799, + -0.032165527, -0.022262573, 0.049102783, 0.00712204, 0.0054626465, + -0.004009247, 0.028030396, -0.003145218, 0.028076172, -0.05593872, + 0.01663208, 0.03466797, -0.0049934387, -0.01928711, -0.043029785, + 0.0158844, -0.036102295, 0.017303467, 0.021011353, 0.0009908676, + -0.038208008, 0.042633057, -0.07446289, 0.054840088, -0.04711914, + -0.0021762848, 0.049926758, 0.028167725, 0.053741455, -0.023956299, + -0.023895264, -0.05178833, 0.0007777214, -0.03994751, -0.011856079, + -0.016799927, 0.008026123, 0.009979248, 0.01687622, 0.032714844, + -0.03186035, 0.023513794, 0.009979248, 0.029571533, 0.03010559, + -0.02508545, -0.057891846, 0.03842163, -0.015686035, -0.024414062, + 0.016281128, -0.027252197, 0.021057129, -0.019195557, -0.006385803, + -0.049987793, -0.019958496, -0.02558899, 0.032287598, -0.013839722, + 0.005065918, 0.02394104, 0.01084137, -0.029052734, 0.028717041, + 0.0074882507, 0.0003876686, 0.03640747, 0.0023765564, -0.012466431, + 0.020553589, -0.014602661, -0.028244019, 0.02458191, -0.032348633, + -0.0647583, -0.014434814, 0.027313232, 0.04977417, -0.026382446, + 0.027618408, 0.016967773, 0.004673004, 0.03100586, -0.046295166, + 0.0013895035, 0.062805176, -0.014640808, -0.049987793, 0.01701355, + -0.04397583, 0.0052719116, -0.01637268, -0.029434204, 0.031341553, + 0.045440674, -0.013305664, 0.021118164, -0.044189453, -0.03878784, + 0.024749756, -0.014762878, -0.061187744, -0.006828308, 0.011177063, + 0.01235199, -0.002626419, -0.024658203, 0.000019192696, -0.0031490326, + 0.050872803, 0.023254395, -0.015792847, -0.0035362244, 0.026229858, + 0.0042266846, 0.0102005005, 0.066711426, -0.023757935, 0.012107849, + 0.009933472, 0.06274414, -0.013458252, -0.028686523, -0.034606934, + 0.0041618347, 0.016479492, 0.053131104, -0.025756836, -0.026611328, + 0.012031555, -0.007835388, -0.017440796, -0.055755615, 0.022537231, + 0.016082764, 0.0038070679, 0.03378296, 0.0309906, -0.07714844, + -0.011024475, -0.018066406, -0.015197754, 0.045410156, -0.022125244, + 0.024719238, -0.008857727, 0.010612488, 0.016296387, -0.022399902, + -0.06121826, -0.074645996, -0.008956909, -0.123046875, 0.010215759, + -0.022476196, -0.09185791, 0.017440796, 0.043121338, 0.010696411, + -0.050598145, -0.0027599335, -0.015457153, -0.014411926, 0.04473877, + 0.0181427, -0.015945435, -0.04232788, 0.052734375, -0.0022201538, + -0.019012451, 0.05255127, -0.009086609, 0.0041046143, 0.0020389557, + -0.009750366, 0.015731812, -0.038208008, -0.015701294, 0.051116943, + -0.010101318, -0.09564209, -0.017471313, 0.028518677, -0.00011640787, + -0.051361084, -0.0032081604, 0.008171082, -0.0067749023, -0.045318604, + 0.040863037, -0.03488159, -0.036895752, 0.0020503998, 0.0017614365, + -0.0036849976, 0.04119873, 0.016067505, 0.05102539, -0.0491333, + -0.026382446, -0.0073547363, 0.06097412, -0.002023697, 0.0009775162, + 0.02268982, 0.013671875, 0.054626465, -0.0003399849, -0.0050315857, + 0.019973755, 0.0138549805, -0.005508423, -0.0004553795, 0.05496216, + -0.013442993, -0.031829834, -0.005458832, 0.01272583, 0.0056495667, + -0.029373169, -0.021102905, -0.025268555, 0.04776001, -0.04849243, + 0.009857178, 0.012306213, -0.033996582, -0.03717041, -0.010063171, + -0.019165039, 0.07092285, -0.01259613, 0.00023555756, -0.028305054, + -0.038513184, 0.00868988, 0.010032654, -0.009246826, 0.013023376, + -0.008224487, 0.07287598, -0.042419434, 0.00054454803, -0.010986328, + -0.0024337769, 0.03152466, 0.00422287, -0.0021686554, 0.024139404, + 0.0060310364, 0.013374329, 0.040039062, 0.013916016, 0.02243042, + -0.018493652, 0.015960693, 0.020614624, 0.013214111, -0.02633667, + -0.03262329, -0.04510498, -0.005256653, 0.021316528, 0.0034618378, + 0.053222656, 0.03540039, -0.034118652, -0.000050604343, 0.04309082, + -0.006801605, -0.014389038, -0.053619385, -0.035491943, -0.034820557, + 0.00843811, 0.017333984, 0.039489746, -0.06512451, -0.08959961, + 0.016235352, 0.039031982, -0.016174316, 0.016616821, -0.026489258, + 0.00040388107, 0.009437561, -0.03869629, 0.014427185, 0.008460999, + 0.0027809143, -0.012451172, 0.015144348, 0.049926758, 0.030151367, + -0.011665344, -0.030014038, 0.06109619, -0.009292603, 0.00025629997, + 0.016540527, 0.027404785, -0.019958496, -0.019210815, 0.049713135, + -0.028930664, 0.01222229, -0.011878967, -0.009170532, 0.006866455, + 0.04916382, -0.013084412, 0.025558472, -0.032226562, 0.018692017, + -0.047424316, 0.045074463, -0.046875, -0.01939392, 0.012382507, + -0.0030975342, -0.0060691833, -0.025848389, -0.016235352, -0.0043678284, + -0.040405273, -0.03677368, 0.03475952, -0.045288086, 0.04046631, + 0.03353882, -0.038360596, -0.014350891, -0.039489746, -0.029663086, + -0.011779785, 0.012458801, 0.01423645, 0.013343811, 0.011833191, + 0.041381836, 0.026473999, 0.11871338, 0.027236938, 0.052856445, + -0.055145264, 0.04748535, 0.018859863, 0.015701294, -0.021453857, + 0.00687027, -0.011810303, 0.022766113, 0.026626587, -0.021392822, + -0.011657715, 0.0008201599, 0.011108398, -0.0056877136, -0.012550354, + 0.01600647, -0.020309448, 0.007587433, 0.00007736683, 0.026550293, + 0.007545471, 0.03955078, -0.05050659, -0.012161255, -0.04019165, + -0.002002716, -0.014381409, -0.0032672882, 0.0619812, -0.01638794, + -0.030532837, -0.025009155, 0.01826477, 0.02192688, -0.049346924, + -0.022613525, 0.036590576, 0.0009851456, -0.03062439, -0.08404541, + -0.018844604, -0.008270264, 0.009033203, -0.028656006, 0.00077199936, + 0.010955811, -0.013267517, 0.024795532, 0.006126404, 0.02519226, + -0.0067825317, 0.033050537, 0.040405273, -0.0017957687, 0.019989014, + 0.0055160522, -0.0289917, 0.0043029785, -0.038024902, -0.021331787, + 0.000076293945, 0.07116699, -0.04071045, -0.0036392212, -0.034301758, + -0.0039024353, -0.027938843, -0.08569336, 0.025802612, -0.025100708, + -0.011383057, -0.014770508, -0.005870819, 0.04083252, 0.031921387, + 0.0066452026, 0.0017795563, 0.020889282, 0.008766174, -0.04321289, + -0.0031108856, -0.02772522, 0.0066604614, -0.06689453, -0.033111572, + 0.029876709, -0.024414062, 0.0031051636, -0.08502197, 0.0021133423, + 0.0027370453, 0.0005173683, -0.0023441315, 0.0076828003, -0.046783447, + -0.018814087, -0.016342163, -0.043304443, -0.047943115, 0.039245605, + 0.07208252, -0.053100586, 0.013511658, -0.0033283234, -0.031402588, + 0.06463623, -0.030059814, -0.050231934, 0.023971558, -0.014717102, + -0.0073432922, -0.01171875, -0.02760315, -0.00058841705, 0.037109375, + -0.02684021, -0.018463135, -0.0025234222, -0.027053833, 0.050689697, + -0.026046753, -0.0067825317, 0.052337646, -0.04260254, 0.018539429, + -0.03692627, 0.022369385, -0.025039673, 0.01525116, 0.032165527, + -0.00422287, 0.0059661865, -0.0073280334, 0.017303467, -0.012710571, + -0.03338623, -0.03137207, -0.01789856, 0.005458832 + ], + [ + 0.050720215, -0.025253296, 0.018859863, -0.060180664, -0.008003235, + 0.02192688, -0.020126343, 0.0068893433, 0.040252686, 0.08441162, + 0.025665283, 0.0036411285, 0.03982544, -0.0021705627, -0.035705566, + 0.01020813, 0.025894165, 0.018508911, 0.01966858, -0.026672363, + 0.017089844, -0.010887146, 0.0019197464, 0.009437561, -0.015419006, + 0.06439209, 0.04019165, -0.015975952, -0.02067566, -0.016555786, + -0.0010957718, -0.01838684, 0.045898438, 0.0023231506, -0.022155762, + 0.011688232, -0.020401001, -0.026412964, -0.02255249, 0.0013628006, + -0.026275635, 0.018966675, -0.010017395, -0.049316406, -0.07763672, + 0.0066070557, -0.039245605, 0.04776001, 0.039733887, -0.019332886, + 0.0005726814, 0.017242432, 0.0050201416, -0.017471313, -0.015403748, + 0.02255249, 0.001572609, -0.03491211, 0.02078247, 0.011054993, + 0.006095886, 0.0012397766, 0.023040771, 0.025466919, 0.027023315, + 0.035583496, 0.08203125, 0.011604309, 0.022216797, -0.026992798, + -0.04067993, -0.0070381165, 0.03677368, -0.02748108, -0.0335083, + 0.025543213, 0.005680084, 0.0107803345, 0.035949707, -0.04876709, + 0.095825195, 0.0022659302, 0.07824707, 0.012763977, -0.005420685, + 0.011138916, 0.029067993, -0.03390503, -0.011413574, -0.013313293, + -0.019592285, 0.042510986, -0.042785645, 0.030960083, -0.016403198, + 0.0018463135, 0.022537231, -0.0011920929, -0.044311523, -0.018127441, + 0.01953125, -0.029327393, 0.021957397, -0.011230469, 0.0149002075, + 0.035949707, -0.012054443, 0.070495605, 0.07702637, 0.020904541, + 0.008781433, 0.049804688, -0.027801514, 0.008415222, -0.030349731, + 0.02470398, -0.042541504, -0.0023899078, -0.0049552917, -0.0027923584, + -0.02558899, 0.025939941, 0.012519836, -0.090270996, -0.0047836304, + -0.02619934, -0.017822266, -0.016662598, 0.022766113, 0.012741089, + -0.0014429092, 0.040161133, 0.0011053085, -0.019882202, -0.039733887, + 0.013244629, 0.022369385, 0.032043457, 0.009048462, 0.046539307, + 0.019546509, -0.03488159, 0.022445679, 0.0027885437, 0.002456665, + 0.035339355, 0.036834717, -0.018630981, -0.030380249, -0.004989624, + -0.042114258, 0.0056419373, 0.016189575, 0.011451721, -0.034851074, + -0.0005874634, -0.06793213, 0.0044517517, 0.010971069, 0.006412506, + 0.014167786, -0.007965088, -0.04449463, -0.029205322, -0.076660156, + 0.0044059753, 0.047851562, 0.025344849, 0.00012153387, 0.07354736, + -0.044189453, 0.043395996, 0.025848389, 0.049072266, -0.0019721985, + -0.0046691895, -0.0004079342, 0.006008148, 0.027114868, -0.042541504, + -0.04498291, -0.049926758, 0.020126343, -0.0037727356, -0.025283813, + 0.009117126, -0.027618408, 0.0058937073, 0.068847656, -0.006713867, + -0.017364502, -0.026062012, 0.06549072, -0.021942139, 0.0008788109, + -0.057128906, -0.023498535, 0.014709473, -0.02331543, -0.0158844, + 0.008895874, 0.040802002, -0.03564453, -0.00333786, -0.038757324, + -0.030136108, -0.0037994385, 0.030578613, -0.012077332, -0.001540184, + 0.023529053, -0.034606934, -0.02178955, 0.023590088, -0.017700195, + -0.04168701, 0.0072021484, -0.018508911, -0.0042686462, -0.046661377, + 0.03805542, 0.039154053, 0.0031318665, 0.07269287, 0.018325806, + 0.021957397, -0.02003479, 0.028549194, 0.04058838, 0.03149414, + -0.012687683, -0.024353027, 0.01612854, 0.02494812, -0.035095215, + 0.017822266, 0.021865845, 0.0592041, -0.015838623, -0.0044555664, + 0.010139465, 0.0021953583, -0.04309082, 0.021942139, -0.005607605, + -0.056671143, -0.013801575, 0.03338623, -0.00020134449, 0.09112549, + 0.022399902, 0.016906738, -0.0017642975, -0.012428284, -0.0362854, + 0.022735596, 0.013328552, -0.0066070557, -0.033294678, 0.01398468, + 0.0057754517, 0.005077362, -0.037017822, 0.013420105, 0.08148193, + -0.03665161, 0.024368286, -0.0016231537, -0.02973938, 0.0023231506, + 0.029296875, -0.035705566, -0.00680542, 0.051330566, 0.019592285, + -0.042633057, -0.030792236, 0.008384705, 0.0121536255, 0.014945984, + -0.009254456, 0.009719849, -0.029510498, -0.02015686, 0.05722046, + 0.02319336, -0.021194458, -0.050933838, -0.021987915, 0.026473999, + 0.03729248, 0.043640137, 0.022491455, -0.018341064, 0.029937744, + 0.004016876, 0.10595703, 0.014282227, 0.0027809143, 0.010871887, + 0.022613525, 0.049621582, 0.041229248, -0.029891968, -0.003320694, + -0.011787415, 0.004383087, 0.016998291, -0.010032654, -0.008041382, + -0.03692627, 0.031036377, 0.0129470825, -0.014122009, -0.019683838, + -0.05117798, -0.012664795, -0.020492554, -0.06341553, -0.030059814, + 0.050567627, -0.03253174, -0.010299683, 0.035095215, -0.023651123, + -0.011520386, 0.072143555, 0.0026130676, -0.028778076, 0.04336548, + 0.06500244, 0.049957275, 0.008773804, -0.010055542, 0.008117676, + 0.016036987, 0.013168335, -0.023147583, -0.023757935, -0.0026760101, + 0.006137848, -0.05105591, 0.00415802, -0.027130127, -0.027694702, + 0.024108887, -0.046569824, 0.009689331, 0.034698486, -0.0017528534, + -0.029556274, -0.018173218, -0.021865845, 0.0023612976, 0.024719238, + -0.026412964, -0.02180481, 0.03765869, 0.026000977, -0.04714966, + -0.016921997, -0.05758667, -0.054748535, 0.024841309, 0.012245178, + 0.007209778, -0.011512756, 0.024383545, -0.017684937, 0.03744507, + 0.029449463, -0.026687622, -0.0030841827, -0.029632568, -0.04284668, + -0.016342163, -0.014312744, -0.050567627, -0.022583008, -0.02734375, + -0.019989014, -0.035064697, 0.05279541, -0.0027122498, -0.02053833, + 0.057525635, 0.007511139, -0.0078125, 0.045898438, -0.0032424927, + 0.031051636, 0.035308838, -0.0138549805, -0.0050201416, -0.016052246, + -0.026550293, 0.02520752, 0.036895752, -0.053710938, 0.0058937073, + 0.026107788, 0.011451721, -0.017547607, -0.013244629, 0.02998352, + -0.017974854, 0.041381836, -0.030639648, 0.0073928833, -0.047302246, + 0.023864746, -0.034423828, -0.003648758, -0.05065918, 0.011138916, + -0.04852295, 0.0055122375, -0.016189575, -0.0057640076, 0.0034179688, + 0.03491211, -0.012741089, 0.01234436, 0.023269653, 0.010360718, + 0.008384705, -0.021636963, -0.014778137, 0.026123047, 0.040008545, + 0.012611389, 0.0022697449, 0.012626648, 0.041900635, -0.051696777, + 0.048339844, -0.019607544, -0.026443481, 0.011444092, -0.087524414, + 0.03894043, 0.030303955, 0.0050468445, 0.01423645, -0.03149414, + 0.027404785, 0.035705566, 0.02192688, -0.033203125, -0.017684937, + -0.020599365, -0.0021133423, 0.024536133, 0.04272461, 0.013031006, + 0.06451416, -0.020019531, 0.02520752, 0.04586792, -0.009757996, + 0.014183044, -0.001783371, -0.036743164, 0.0028133392, 0.0010175705, + -0.00422287, 0.041503906, -0.005466461, -0.013252258, 0.008262634, + -0.0030021667, -0.0049324036, -0.013511658, -0.03164673, 0.037475586, + 0.0029945374, 0.00015115738, -0.010971069, -0.022445679, -0.020614624, + -0.01626587, 0.0262146, -0.0037288666, -0.057128906, -0.06072998, + 0.014945984, -0.05984497, -0.0059280396, -0.016662598, 0.019958496, + -0.03164673, 0.021148682, 0.02230835, -0.03527832, -0.014122009, + 0.021911621, 0.032958984, -0.088012695, 0.0036849976, -0.011276245, + -0.06100464, 0.031280518, -0.008308411, -0.009002686, 0.033081055, + -0.029373169, 0.040161133, 0.035125732, 0.021850586, 0.04827881, + 0.034210205, 0.02708435, 0.018005371, 0.010238647, -0.02041626, + -0.026260376, 0.052246094, -0.014007568, -0.017105103, -0.014526367, + -0.018463135, -0.011711121, -0.026062012, 0.017852783, 0.054138184, + 0.012672424, -0.035980225, 0.043273926, -0.024230957, -0.008758545, + -0.018615723, 0.01676941, -0.018859863, -0.0209198, 0.035064697, + -0.014350891, -0.020828247, 0.008285522, -0.003068924, -0.016143799, + -0.032165527, -0.022262573, 0.049102783, 0.00712204, 0.0054626465, + -0.004009247, 0.028030396, -0.003145218, 0.028076172, -0.05593872, + 0.01663208, 0.03466797, -0.0049934387, -0.01928711, -0.043029785, + 0.0158844, -0.036102295, 0.017303467, 0.021011353, 0.0009908676, + -0.038208008, 0.042633057, -0.07446289, 0.054840088, -0.04711914, + -0.0021762848, 0.049926758, 0.028167725, 0.053741455, -0.023956299, + -0.023895264, -0.05178833, 0.0007777214, -0.03994751, -0.011856079, + -0.016799927, 0.008026123, 0.009979248, 0.01687622, 0.032714844, + -0.03186035, 0.023513794, 0.009979248, 0.029571533, 0.03010559, + -0.02508545, -0.057891846, 0.03842163, -0.015686035, -0.024414062, + 0.016281128, -0.027252197, 0.021057129, -0.019195557, -0.006385803, + -0.049987793, -0.019958496, -0.02558899, 0.032287598, -0.013839722, + 0.005065918, 0.02394104, 0.01084137, -0.029052734, 0.028717041, + 0.0074882507, 0.0003876686, 0.03640747, 0.0023765564, -0.012466431, + 0.020553589, -0.014602661, -0.028244019, 0.02458191, -0.032348633, + -0.0647583, -0.014434814, 0.027313232, 0.04977417, -0.026382446, + 0.027618408, 0.016967773, 0.004673004, 0.03100586, -0.046295166, + 0.0013895035, 0.062805176, -0.014640808, -0.049987793, 0.01701355, + -0.04397583, 0.0052719116, -0.01637268, -0.029434204, 0.031341553, + 0.045440674, -0.013305664, 0.021118164, -0.044189453, -0.03878784, + 0.024749756, -0.014762878, -0.061187744, -0.006828308, 0.011177063, + 0.01235199, -0.002626419, -0.024658203, 0.000019192696, -0.0031490326, + 0.050872803, 0.023254395, -0.015792847, -0.0035362244, 0.026229858, + 0.0042266846, 0.0102005005, 0.066711426, -0.023757935, 0.012107849, + 0.009933472, 0.06274414, -0.013458252, -0.028686523, -0.034606934, + 0.0041618347, 0.016479492, 0.053131104, -0.025756836, -0.026611328, + 0.012031555, -0.007835388, -0.017440796, -0.055755615, 0.022537231, + 0.016082764, 0.0038070679, 0.03378296, 0.0309906, -0.07714844, + -0.011024475, -0.018066406, -0.015197754, 0.045410156, -0.022125244, + 0.024719238, -0.008857727, 0.010612488, 0.016296387, -0.022399902, + -0.06121826, -0.074645996, -0.008956909, -0.123046875, 0.010215759, + -0.022476196, -0.09185791, 0.017440796, 0.043121338, 0.010696411, + -0.050598145, -0.0027599335, -0.015457153, -0.014411926, 0.04473877, + 0.0181427, -0.015945435, -0.04232788, 0.052734375, -0.0022201538, + -0.019012451, 0.05255127, -0.009086609, 0.0041046143, 0.0020389557, + -0.009750366, 0.015731812, -0.038208008, -0.015701294, 0.051116943, + -0.010101318, -0.09564209, -0.017471313, 0.028518677, -0.00011640787, + -0.051361084, -0.0032081604, 0.008171082, -0.0067749023, -0.045318604, + 0.040863037, -0.03488159, -0.036895752, 0.0020503998, 0.0017614365, + -0.0036849976, 0.04119873, 0.016067505, 0.05102539, -0.0491333, + -0.026382446, -0.0073547363, 0.06097412, -0.002023697, 0.0009775162, + 0.02268982, 0.013671875, 0.054626465, -0.0003399849, -0.0050315857, + 0.019973755, 0.0138549805, -0.005508423, -0.0004553795, 0.05496216, + -0.013442993, -0.031829834, -0.005458832, 0.01272583, 0.0056495667, + -0.029373169, -0.021102905, -0.025268555, 0.04776001, -0.04849243, + 0.009857178, 0.012306213, -0.033996582, -0.03717041, -0.010063171, + -0.019165039, 0.07092285, -0.01259613, 0.00023555756, -0.028305054, + -0.038513184, 0.00868988, 0.010032654, -0.009246826, 0.013023376, + -0.008224487, 0.07287598, -0.042419434, 0.00054454803, -0.010986328, + -0.0024337769, 0.03152466, 0.00422287, -0.0021686554, 0.024139404, + 0.0060310364, 0.013374329, 0.040039062, 0.013916016, 0.02243042, + -0.018493652, 0.015960693, 0.020614624, 0.013214111, -0.02633667, + -0.03262329, -0.04510498, -0.005256653, 0.021316528, 0.0034618378, + 0.053222656, 0.03540039, -0.034118652, -0.000050604343, 0.04309082, + -0.006801605, -0.014389038, -0.053619385, -0.035491943, -0.034820557, + 0.00843811, 0.017333984, 0.039489746, -0.06512451, -0.08959961, + 0.016235352, 0.039031982, -0.016174316, 0.016616821, -0.026489258, + 0.00040388107, 0.009437561, -0.03869629, 0.014427185, 0.008460999, + 0.0027809143, -0.012451172, 0.015144348, 0.049926758, 0.030151367, + -0.011665344, -0.030014038, 0.06109619, -0.009292603, 0.00025629997, + 0.016540527, 0.027404785, -0.019958496, -0.019210815, 0.049713135, + -0.028930664, 0.01222229, -0.011878967, -0.009170532, 0.006866455, + 0.04916382, -0.013084412, 0.025558472, -0.032226562, 0.018692017, + -0.047424316, 0.045074463, -0.046875, -0.01939392, 0.012382507, + -0.0030975342, -0.0060691833, -0.025848389, -0.016235352, -0.0043678284, + -0.040405273, -0.03677368, 0.03475952, -0.045288086, 0.04046631, + 0.03353882, -0.038360596, -0.014350891, -0.039489746, -0.029663086, + -0.011779785, 0.012458801, 0.01423645, 0.013343811, 0.011833191, + 0.041381836, 0.026473999, 0.11871338, 0.027236938, 0.052856445, + -0.055145264, 0.04748535, 0.018859863, 0.015701294, -0.021453857, + 0.00687027, -0.011810303, 0.022766113, 0.026626587, -0.021392822, + -0.011657715, 0.0008201599, 0.011108398, -0.0056877136, -0.012550354, + 0.01600647, -0.020309448, 0.007587433, 0.00007736683, 0.026550293, + 0.007545471, 0.03955078, -0.05050659, -0.012161255, -0.04019165, + -0.002002716, -0.014381409, -0.0032672882, 0.0619812, -0.01638794, + -0.030532837, -0.025009155, 0.01826477, 0.02192688, -0.049346924, + -0.022613525, 0.036590576, 0.0009851456, -0.03062439, -0.08404541, + -0.018844604, -0.008270264, 0.009033203, -0.028656006, 0.00077199936, + 0.010955811, -0.013267517, 0.024795532, 0.006126404, 0.02519226, + -0.0067825317, 0.033050537, 0.040405273, -0.0017957687, 0.019989014, + 0.0055160522, -0.0289917, 0.0043029785, -0.038024902, -0.021331787, + 0.000076293945, 0.07116699, -0.04071045, -0.0036392212, -0.034301758, + -0.0039024353, -0.027938843, -0.08569336, 0.025802612, -0.025100708, + -0.011383057, -0.014770508, -0.005870819, 0.04083252, 0.031921387, + 0.0066452026, 0.0017795563, 0.020889282, 0.008766174, -0.04321289, + -0.0031108856, -0.02772522, 0.0066604614, -0.06689453, -0.033111572, + 0.029876709, -0.024414062, 0.0031051636, -0.08502197, 0.0021133423, + 0.0027370453, 0.0005173683, -0.0023441315, 0.0076828003, -0.046783447, + -0.018814087, -0.016342163, -0.043304443, -0.047943115, 0.039245605, + 0.07208252, -0.053100586, 0.013511658, -0.0033283234, -0.031402588, + 0.06463623, -0.030059814, -0.050231934, 0.023971558, -0.014717102, + -0.0073432922, -0.01171875, -0.02760315, -0.00058841705, 0.037109375, + -0.02684021, -0.018463135, -0.0025234222, -0.027053833, 0.050689697, + -0.026046753, -0.0067825317, 0.052337646, -0.04260254, 0.018539429, + -0.03692627, 0.022369385, -0.025039673, 0.01525116, 0.032165527, + -0.00422287, 0.0059661865, -0.0073280334, 0.017303467, -0.012710571, + -0.03338623, -0.03137207, -0.01789856, 0.005458832 + ] + ], + meta: { + api_version: { + version: '1' + }, + billed_units: { + input_tokens: 8 + } + }, + response_type: 'embeddings_floats' +}; +export default data; diff --git a/src/pages/playground/config/types.ts b/src/pages/playground/config/types.ts index 6a69db73..7e3df936 100644 --- a/src/pages/playground/config/types.ts +++ b/src/pages/playground/config/types.ts @@ -5,9 +5,36 @@ export interface ModelSelectionItem extends Global.BaseOption { } export interface MessageItem { - role: string; content: string; - title?: string; imgs?: { uid: string | number; dataUrl: string }[]; + role: string; + title?: string; uid: number; } + +type SchemaType = + | 'Input' + | 'InputNumber' + | 'Textarea' + | 'Select' + | 'Slider' + | 'Checkbox'; + +export interface ParamsSchema { + type: SchemaType; + name: string; + label: { + text: string; + isLocalized?: boolean; + }; + options?: Global.BaseOption[]; + value?: string | number | boolean | string[]; + min?: number; + max?: number; + step?: number; + disabled?: boolean; + defaultValue?: string | number | boolean; + rules: { required: boolean; message: string }[]; + placeholder?: string; + attrs?: Record; +} diff --git a/src/pages/playground/embedding.tsx b/src/pages/playground/embedding.tsx new file mode 100644 index 00000000..da6e5d69 --- /dev/null +++ b/src/pages/playground/embedding.tsx @@ -0,0 +1,116 @@ +import IconFont from '@/components/icon-font'; +import HotKeys from '@/config/hotkeys'; +import { PageContainer } from '@ant-design/pro-components'; +import { useIntl } from '@umijs/max'; +import { Button, Space } from 'antd'; +import classNames from 'classnames'; +import _ from 'lodash'; +import { useCallback, useEffect, useRef, useState } from 'react'; +import { useHotkeys } from 'react-hotkeys-hook'; +import { queryModelsList } from './apis'; +import GroundEmbedding from './components/ground-embedding'; +import './style/play-ground.less'; + +const PlaygroundEmbedding: React.FC = () => { + const intl = useIntl(); + const groundLeftRef = useRef(null); + const ref = useRef(null); + const [modelList, setModelList] = useState[]>([]); + const [loaded, setLoaded] = useState(false); + + const handleViewCode = useCallback(() => { + ref.current?.viewCode?.(); + }, [ref.current]); + + const handleToggleCollapse = useCallback(() => { + ref.current?.setCollapse?.(); + }, [ref.current]); + + useEffect(() => { + const getModelListByEmbedding = async () => { + try { + const params = { + embedding_only: true + }; + const res = await queryModelsList(params); + const list = _.map(res.data || [], (item: any) => { + return { + value: item.id, + label: item.id + }; + }) as Global.BaseOption[]; + return list; + } catch (error) { + console.error(error); + return []; + } + }; + const fetchData = async () => { + try { + const [dataList] = await Promise.all([getModelListByEmbedding()]); + setModelList(dataList); + } catch (error) { + setLoaded(true); + } + }; + fetchData(); + }, []); + + const renderExtra = () => { + return ( + + + + + ); + }; + + useHotkeys( + HotKeys.RIGHT.join(','), + () => { + groundLeftRef.current?.setCollapse?.(); + }, + { + preventDefault: true + } + ); + + return ( + +
+
+ +
+
+
+ ); +}; + +export default PlaygroundEmbedding; diff --git a/src/pages/playground/index.tsx b/src/pages/playground/index.tsx index a1daf9d3..b24c27c3 100644 --- a/src/pages/playground/index.tsx +++ b/src/pages/playground/index.tsx @@ -22,9 +22,6 @@ const Playground: React.FC = () => { const groundLeftRef = useRef(null); const groundRerankerRef = useRef(null); const [modelList, setModelList] = useState[]>([]); - const [rerankerModelList, setRerankerModelList] = useState< - Global.BaseOption[] - >([]); const [loaded, setLoaded] = useState(false); const optionsList = [ { @@ -37,11 +34,6 @@ const Playground: React.FC = () => { value: 'compare', icon: } - // { - // label: 'Rerank', - // value: 'reranker', - // icon: - // } ]; const handleViewCode = useCallback(() => { @@ -73,17 +65,6 @@ const Playground: React.FC = () => { label: 'Compare', children: } - // { - // key: 'reranker', - // label: 'Reranker', - // children: ( - // - // ) - // } ]; useEffect(() => { @@ -113,32 +94,11 @@ const Playground: React.FC = () => { return []; } }; - const getModelListByReranker = async () => { - try { - const params = { - reranker: true - }; - const res = await queryModelsList(params); - const list = _.map(res.data || [], (item: any) => { - return { - value: item.id, - label: item.id - }; - }) as Global.BaseOption[]; - return list; - } catch (error) { - console.error(error); - return []; - } - }; + const fetchData = async () => { try { - const [modelist, rerankerModelList] = await Promise.all([ - getModelList(), - getModelListByReranker() - ]); + const modelist = await getModelList(); setModelList(modelist); - setRerankerModelList(rerankerModelList); } catch (error) { setLoaded(true); } diff --git a/src/pages/playground/style/file-list.less b/src/pages/playground/style/file-list.less index 346c8a42..adb1c201 100644 --- a/src/pages/playground/style/file-list.less +++ b/src/pages/playground/style/file-list.less @@ -7,9 +7,9 @@ display: flex; align-items: center; justify-content: space-between; - border-bottom: 1px solid var(--ant-color-split); - padding: 8px 14px; - padding-right: 6px; + border: 1px solid var(--ant-color-border); + border-radius: var(--border-radius-base); + padding: 8px 6px 8px 14px; cursor: pointer; height: 41px; transition: background-color 0.3s ease; @@ -33,7 +33,8 @@ .title { display: flex; align-items: center; - max-width: 300px; + width: 300px; + flex: 1; } } } diff --git a/src/pages/playground/style/ground-left.less b/src/pages/playground/style/ground-left.less index 875b76a2..38e74ca9 100644 --- a/src/pages/playground/style/ground-left.less +++ b/src/pages/playground/style/ground-left.less @@ -41,6 +41,7 @@ flex-direction: column; position: relative; height: calc(100vh - 72px); + width: 100%; .message-list-wrap { display: flex; diff --git a/src/pages/playground/style/play-ground.less b/src/pages/playground/style/play-ground.less index 79b0693f..d78d04e0 100644 --- a/src/pages/playground/style/play-ground.less +++ b/src/pages/playground/style/play-ground.less @@ -32,6 +32,7 @@ flex: 1; display: flex; flex-direction: column; + width: 100%; } .params { diff --git a/src/pages/playground/style/rerank.less b/src/pages/playground/style/rerank.less index af426f85..8557c3bf 100644 --- a/src/pages/playground/style/rerank.less +++ b/src/pages/playground/style/rerank.less @@ -16,6 +16,7 @@ top: 0; background: var(--color-white-1); z-index: 100; + align-items: center; } }