feat: playground embedding

This commit is contained in:
jialin
2024-11-22 10:00:34 +08:00
parent 01214077d3
commit 16e2ac5b6c
33 changed files with 1518 additions and 172 deletions
@@ -15,7 +15,7 @@ import {
useState
} from 'react';
import { rerankerQuery } from '../apis';
import { MessageItem } from '../config/types';
import { MessageItem, ParamsSchema } from '../config/types';
import '../style/ground-left.less';
import '../style/rerank.less';
import '../style/system-message-wrap.less';
@@ -32,6 +32,30 @@ interface MessageProps {
ref?: any;
}
const paramsConfig: ParamsSchema[] = [
{
type: 'InputNumber',
name: 'top_n',
label: {
text: 'Top N',
isLocalized: false
},
attrs: {
min: 1
},
rules: [
{
required: true,
message: 'Top N is required'
}
]
}
];
const initialValues = {
top_n: 1
};
const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
const { modelList } = props;
const acceptType =
@@ -145,7 +169,7 @@ const GroundReranker: React.FC<MessageProps> = 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<MessageProps> = forwardRef((props, ref) => {
<h3 className="m-l-10 flex-between flex-center font-size-14 line-24 m-b-0">
<span>Documents</span>
</h3>
<div className="flex gap-20">
<div className="flex gap-10">
{/* <UploadFile
handleUpdateFileList={handleUpdateFileList}
accept={acceptType}
@@ -306,11 +330,12 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
Add Text
</Button>
<Button
type="text"
icon={<ClearOutlined />}
size="middle"
onClick={handleClearDocuments}
></Button>
>
{intl.formatMessage({ id: 'common.button.clear' })}
</Button>
</div>
</div>
<div className="docs-wrapper">
@@ -366,6 +391,8 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
<RerankerParams
setParams={setParams}
params={parameters}
paramsConfig={paramsConfig}
initialValues={initialValues}
selectedModel={selectModel}
modelList={modelList}
/>