|
|
@@ -219,6 +219,7 @@ export class ChatPdfService {
|
|
|
}
|
|
|
|
|
|
async ask(q: string, name: string) {
|
|
|
+ const defSysMsg = (await this.sysConfigService.findByName('customer_system_message'))?.value
|
|
|
const keywords = await this.getKeywords(q)
|
|
|
const { embedding: keywordEmbedding } = await this.getEmbedding(keywords)
|
|
|
const context = this.cutContext((await this.searchEmbedding(name, keywordEmbedding)).map((item) => item.text))
|
|
|
@@ -227,16 +228,15 @@ export class ChatPdfService {
|
|
|
answer: '未找到相关内容'
|
|
|
}
|
|
|
}
|
|
|
- const content = dedent`You are a helpful AI article assistant. '
|
|
|
- The following are the relevant article content fragments found from the article.
|
|
|
- The relevance is sorted from high to low. '
|
|
|
- You can only answer according to the following content:
|
|
|
+ const content = dedent`${defSysMsg}'
|
|
|
+ 根据相关性从高到低排序。 '
|
|
|
+ 这是用户提出的问题:
|
|
|
+ ${q}
|
|
|
+ 你只能根据用户的问题,以下面的内容为准进行回答:
|
|
|
\`\`\`
|
|
|
${context.join('\n')}
|
|
|
\`\`\`
|
|
|
- You need to carefully consider your answer to ensure that it is based on the context.
|
|
|
- If the context does not mention the content or it is uncertain whether it is correct,
|
|
|
- please answer "Current context cannot provide effective information."
|
|
|
+ 你要确保你的回答全部基于上面的问题和内容,如果无法找到答案,你需要根据给你设定的角色表述你不能回答这个问题。
|
|
|
You must use Chinese to respond.`
|
|
|
try {
|
|
|
const response = await this.openai.createChatCompletion({
|