Commit 0d26b1d4 by archer

fix: file sprcial char

parent 4973d7ad
...@@ -53,4 +53,4 @@ export const getAppTotalUsage = (data: { appId: string }) => ...@@ -53,4 +53,4 @@ export const getAppTotalUsage = (data: { appId: string }) =>
}).then((res) => (res.length === 0 ? [{ date: new Date(), total: 0 }] : res)); }).then((res) => (res.length === 0 ? [{ date: new Date(), total: 0 }] : res));
export const getAppChatLogs = (data: RequestPaging & { appId: string }) => export const getAppChatLogs = (data: RequestPaging & { appId: string }) =>
POST(`/chat/getChatLogs`, data); POST(`/app/getChatLogs`, data);
...@@ -105,6 +105,7 @@ A2: ...@@ -105,6 +105,7 @@ A2:
const result = formatSplitText(answer || ''); // 格式化后的QA对 const result = formatSplitText(answer || ''); // 格式化后的QA对
console.log(`split result length: `, result.length); console.log(`split result length: `, result.length);
// 计费 // 计费
result.length > 0 &&
pushQABill({ pushQABill({
userId: data.userId, userId: data.userId,
totalTokens, totalTokens,
......
...@@ -53,8 +53,8 @@ export async function generateVector(): Promise<any> { ...@@ -53,8 +53,8 @@ export async function generateVector(): Promise<any> {
dataItems = [ dataItems = [
{ {
q: data.q, q: data.q.replace(/[\x00-\x1F]/g, ' '),
a: data.a a: data.a.replace(/[\x00-\x1F]/g, ' ')
} }
]; ];
...@@ -109,12 +109,13 @@ export async function generateVector(): Promise<any> { ...@@ -109,12 +109,13 @@ export async function generateVector(): Promise<any> {
// err vector data // err vector data
if (err?.code === 500) { if (err?.code === 500) {
await TrainingData.findByIdAndRemove(trainingId); await TrainingData.findByIdAndDelete(trainingId);
return generateVector(); return generateVector();
} }
// 账号余额不足,删除任务 // 账号余额不足,删除任务
if (userId && err === ERROR_ENUM.insufficientQuota) { if (userId && err === ERROR_ENUM.insufficientQuota) {
try {
sendInform({ sendInform({
type: 'system', type: 'system',
title: '索引生成任务中止', title: '索引生成任务中止',
...@@ -131,6 +132,7 @@ export async function generateVector(): Promise<any> { ...@@ -131,6 +132,7 @@ export async function generateVector(): Promise<any> {
lockTime: new Date('2999/5/5') lockTime: new Date('2999/5/5')
} }
); );
} catch (error) {}
return generateVector(); return generateVector();
} }
......
...@@ -37,6 +37,12 @@ const ChatItemSchema = new Schema({ ...@@ -37,6 +37,12 @@ const ChatItemSchema = new Schema({
type: String, type: String,
default: '' default: ''
}, },
userFeedback: {
type: String
},
adminFeedback: {
type: String
},
[TaskResponseKeyEnum.responseData]: { [TaskResponseKeyEnum.responseData]: {
type: [ type: [
{ {
...@@ -65,6 +71,7 @@ try { ...@@ -65,6 +71,7 @@ try {
ChatItemSchema.index({ userId: 1 }); ChatItemSchema.index({ userId: 1 });
ChatItemSchema.index({ appId: 1 }); ChatItemSchema.index({ appId: 1 });
ChatItemSchema.index({ chatId: 1 }); ChatItemSchema.index({ chatId: 1 });
ChatItemSchema.index({ userFeedback: 1 });
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }
......
...@@ -239,10 +239,12 @@ function getChatMessages({ ...@@ -239,10 +239,12 @@ function getChatMessages({
if (!quotePrompt) { if (!quotePrompt) {
return limitPrompt; return limitPrompt;
} }
const defaultPrompt =
'三引号引用的内容是你的补充知识,它们是最新的,根据引用内容来回答我的问题。';
if (limitPrompt) { if (limitPrompt) {
return `Use the provided documents delimited by triple quotes to answer questions. ${limitPrompt}`; return `${defaultPrompt}${limitPrompt}`;
} }
return `Use the provided documents delimited by triple quotes to answer questions.Your task is to answer the question using only the provided documents. If the documents does not contain the information needed to answer this question then simply write: "你的问题没有在知识库中体现"`; return `${defaultPrompt}你仅回答引用包含的内容,如果问题不包含在引用中,你直接回复: "你的问题没有在知识库中体现"`;
})(); })();
const messages: ChatItemType[] = [ const messages: ChatItemType[] = [
......
...@@ -102,6 +102,8 @@ export interface ChatItemSchema extends ChatItemType { ...@@ -102,6 +102,8 @@ export interface ChatItemSchema extends ChatItemType {
userId: string; userId: string;
appId: string; appId: string;
time: Date; time: Date;
userFeedback?: string;
adminFeedback?: string;
} }
export type BillListItemType = { export type BillListItemType = {
......
...@@ -282,9 +282,7 @@ export const simpleText = (text: string) => { ...@@ -282,9 +282,7 @@ export const simpleText = (text: string) => {
text = text.replace(/\n{2,}/g, '\n'); text = text.replace(/\n{2,}/g, '\n');
text = text.replace(/\s{2,}/g, ' '); text = text.replace(/\s{2,}/g, ' ');
text = text.replace(/\\x([0-9A-Fa-f]{2})/g, function (match, hex) { text = text.replace(/[\x00-\x1F]/g, ' ');
return String.fromCharCode(parseInt(hex, 16));
});
return text; return text;
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment