mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 13:03:50 +00:00
perf: 保持数据原样
This commit is contained in:
@@ -4,7 +4,6 @@ import { connectToDatabase } from '@/service/mongo';
|
||||
import { authToken } from '@/service/utils/tools';
|
||||
import { connectRedis } from '@/service/redis';
|
||||
import { VecModelDataIdx } from '@/constants/redis';
|
||||
import { clearStrLineBreak } from '@/utils/tools';
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
|
||||
try {
|
||||
@@ -45,7 +44,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
|
||||
|
||||
searchRes.documents.forEach((item: any) => {
|
||||
if (item.value.q && item.value.text) {
|
||||
data.push([clearStrLineBreak(item.value.q), clearStrLineBreak(item.value.text)]);
|
||||
data.push([item.value.q.replace(/\n/g, '\\n'), item.value.text.replace(/\n/g, '\\n')]);
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -71,10 +71,3 @@ export const formatVector = (vector: number[]) => {
|
||||
|
||||
return formattedVector;
|
||||
};
|
||||
|
||||
/**
|
||||
* 字符串清理,替换换行符号
|
||||
*/
|
||||
export const clearStrLineBreak = (str: string) => {
|
||||
return str.replace(/\n+/g, '\n').replace(/\n/g, '\\n').trim();
|
||||
};
|
||||
|
Reference in New Issue
Block a user