perf: 文本

This commit is contained in:
archer
2023-03-26 23:52:37 +08:00
parent 249ed18d15
commit 42e12d7db1
6 changed files with 186 additions and 7 deletions

View File

@@ -53,7 +53,7 @@ const ScrollData = ({
}, [elementRef, nextPage]);
return (
<Box {...props} ref={elementRef} overflow={'auto'} position={'relative'}>
<Box {...props} ref={elementRef} overflowY={'auto'} position={'relative'}>
{children}
<Box
mt={2}

View File

@@ -44,6 +44,9 @@ export const introPage = `
`;
export const chatProblem = `
**模型问题**
一般情况下,请直接选择 chatGPT 模型,价格低效果好。
**代理出错**
服务器代理不稳定,可以过一会儿再尝试。

View File

@@ -122,7 +122,7 @@ const DataList = () => {
</Box>
<Box fontSize={'xs'} color={'blackAlpha.600'}>
QA 使 QA
QA
</Box>
</Box>
<Button variant={'outline'} onClick={onOpenCreateDataModal}>

View File

@@ -12,7 +12,7 @@ export async function generateAbstract(next = false): Promise<any> {
const systemPrompt: ChatCompletionRequestMessage = {
role: 'system',
content: `请从长文本中总结出5至15个摘要尽量详细请务必按以下格式返回: "(1):"\n"(2):"\n"(3):"\n`
content: `请从长文本中总结出5至15个摘要尽量详细按以下格式返回: "A:"\n"A:"\n"A:"\n`
};
let dataItem: DataItemSchema | null = null;
@@ -97,7 +97,7 @@ export async function generateAbstract(next = false): Promise<any> {
console.log('获取词向量错误: ', item);
return {
abstract: splitContents[i].abstract,
abstractVector: ''
abstractVector: []
};
}
return {
@@ -120,7 +120,7 @@ export async function generateAbstract(next = false): Promise<any> {
// 计费
!userApiKey &&
vectorResponse.length > 0 &&
splitContents.length > 0 &&
pushSplitDataBill({
userId: dataItem.userId,
type: 'abstract',
@@ -134,7 +134,7 @@ export async function generateAbstract(next = false): Promise<any> {
'生成摘要成功time:',
`${(Date.now() - startTime) / 1000}s`,
'摘要数量:',
vectorResponse.length
splitContents.length
);
} catch (error: any) {
console.log('error: 生成摘要错误', dataItem?._id);
@@ -157,7 +157,7 @@ export async function generateAbstract(next = false): Promise<any> {
* 检查文本是否按格式返回
*/
function splitText(text: string) {
const regex = /\(\d+\):(\s*)(.*)(\s*)/g;
const regex = /A:(\s*)(.*)(\s*)/g;
const matches = text.matchAll(regex); // 获取所有匹配到的结果
const result = []; // 存储最终的结果