Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: question extension & question optimize prompt i18n #3010

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions packages/global/core/ai/prompt/agent.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
export const Prompt_AgentQA = {
description: `<Context></Context> 标记中是一段文本,学习和分析它,并整理学习成果:
- 提出问题并给出每个问题的答案。
- 答案需详细完整,尽可能保留原文描述,可以适当扩展答案描述。
- 答案可以包含普通文字、链接、代码、表格、公示、媒体链接等 Markdown 元素。
- 最多提出 50 个问题。
- 生成的问题和答案和源文本语言相同。
description: `You are a highly knowledgeable and efficient learning assistant. Your task is to analyze the given text within the <Context> tags and generate a comprehensive set of questions and answers based on the content. Follow these guidelines:
- Carefully read and understand the text provided in the <Context> tags.
- Generate up to 50 relevant questions based on the information in the text.
- Provide detailed and complete answers to each question, preserving as much of the original text's description as possible.
- When appropriate, expand on the answers to provide additional context or explanation.
- Use various Markdown elements in your answers, including plain text, links, code blocks, tables, formulas, and media links, as appropriate to the content.
- Ensure that both questions and answers are in the same language as the source text (e.g., English questions and answers for English text).
- Organize the output in a clear Q&A format, with each question numbered (Q1, Q2, Q3, etc.) followed by its corresponding answer (A1, A2, A3, etc.).
- Be thorough in your analysis, covering all key points and concepts mentioned in the text.
- When relevant, include follow-up questions that delve deeper into the topic or explore related concepts.
- Maintain a neutral and informative tone throughout the Q&A, focusing on accuracy and clarity.
Remember, your goal is to create a comprehensive learning resource that helps users fully understand and retain the information presented in the original text.
`,
fixedText: `请按以下格式整理学习成果:
fixedText: `Please organize the learning outcomes in the following format:
<Context>
文本
Text
</Context>
Q1: 问题。
A1: 答案。
Q1: Question.
A1: Answer.
Q2:
A2:

------

我们开始吧!
Let's start!

<Context>
{{text}}
Expand Down
16 changes: 12 additions & 4 deletions packages/service/core/ai/functions/queryExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@ import { llmCompletionsBodyFormat } from '../utils';
*/

const title = global.feConfigs?.systemTitle || 'FastAI';
const defaultPrompt = `作为一个向量检索助手,你的任务是结合历史记录,从不同角度,为“原问题”生成个不同版本的“检索词”,从而提高向量检索的语义丰富度,提高向量检索的精度。
生成的问题要求指向对象清晰明确,并与“原问题语言相同”。

参考 <Example></Example> 标中的示例来完成任务。
const defaultPrompt = `You are a vector retrieval assistant tasked with generating diverse "retrieval terms" for an "original question" based on the given context and historical records. Your goal is to enhance the semantic richness and precision of vector retrieval. When generating retrieval terms, follow these guidelines:

- Analyze the historical records and the original question carefully.
- Generate 3 different versions of retrieval terms that are semantically related to the original question.
- Ensure that the generated terms are clear, specific, and focused on the main topic of the original question.
- Maintain the same language as the original question (e.g., if the original question is in Chinese, generate retrieval terms in Chinese).
- Phrase the retrieval terms as questions or short phrases that capture different aspects or perspectives of the original question.
- Consider including relevant keywords, synonyms, or related concepts from the historical records when appropriate.
- Avoid repetition and strive for diversity in the generated terms to cover various angles of the topic.
- Format your response as a list of retrieval terms enclosed in square brackets and quotation marks.

Your output should be concise and directly provide the list of retrieval terms without any additional explanation or commentary.

<Example>
历史记录:
Expand Down
Loading