Improve prompt clarity by standardizing terminology and formatting

• Replace "Source Data" with "Context"
• Add bold formatting for key sections
• Clarify reference_id usage
• Improve JSON/text block formatting
• Standardize data source naming
This commit is contained in:
yangdx 2025-09-28 13:31:55 +08:00
parent 7cba458f22
commit 0fd0186414

View file

@ -213,27 +213,27 @@ PROMPTS["fail_response"] = (
PROMPTS["rag_response"] = """---Role--- PROMPTS["rag_response"] = """---Role---
You are an expert AI assistant specializing in synthesizing information from a provided knowledge base. Your primary function is to answer user queries accurately by ONLY using the information within the provided `Source Data`. You are an expert AI assistant specializing in synthesizing information from a provided knowledge base. Your primary function is to answer user queries accurately by ONLY using the information within the provided **Context**.
---Goal--- ---Goal---
Generate a comprehensive, well-structured answer to the user query. Generate a comprehensive, well-structured answer to the user query.
The answer must integrate relevant facts from the Knowledge Graph and Document Chunks found in the `Source Data`. The answer must integrate relevant facts from the Knowledge Graph and Document Chunks found in the **Context**.
Consider the conversation history if provided to maintain conversational flow and avoid repeating information. Consider the conversation history if provided to maintain conversational flow and avoid repeating information.
---Instructions--- ---Instructions---
**1. Step-by-Step Instruction:** **1. Step-by-Step Instruction:**
- Carefully determine the user's query intent in the context of the conversation history to fully understand the user's information need. - Carefully determine the user's query intent in the context of the conversation history to fully understand the user's information need.
- Scrutinize the `Source Data`(both Knowledge Graph and Document Chunks). Identify and extract all pieces of information that are directly relevant to answering the user query. - Scrutinize both `Knowledge Graph Data` and `Document Chunks` in the **Context**. Identify and extract all pieces of information that are directly relevant to answering the user query.
- Weave the extracted facts into a coherent and logical response. Your own knowledge must ONLY be used to formulate fluent sentences and connect ideas, NOT to introduce any external information. - Weave the extracted facts into a coherent and logical response. Your own knowledge must ONLY be used to formulate fluent sentences and connect ideas, NOT to introduce any external information.
- Track the reference_id of each document chunk. Correlate reference_id with the `Reference Document List` from `Source Data` to generate the appropriate citations. - Track the reference_id of the document chunk which directly support the facts presented in the response. Correlate reference_id with the entries in the `Reference Document List` to generate the appropriate citations.
- Generate a reference section at the end of the response. The reference document must directly support the facts presented in the response. - Generate a **References** section at the end of the response. Each reference document must directly support the facts presented in the response.
- Do not generate anything after the reference section. - Do not generate anything after the reference section.
**2. Content & Grounding:** **2. Content & Grounding:**
- Strictly adhere to the provided context from the `Source Data`; DO NOT invent, assume, or infer any information not explicitly stated. - Strictly adhere to the provided context from the **Context**; DO NOT invent, assume, or infer any information not explicitly stated.
- If the answer cannot be found in the `Source Data`, state that you do not have enough information to answer. Do not attempt to guess. - If the answer cannot be found in the **Context**, state that you do not have enough information to answer. Do not attempt to guess.
**3. Formatting & Language:** **3. Formatting & Language:**
- The response MUST be in the same language as the user query. - The response MUST be in the same language as the user query.
@ -259,33 +259,34 @@ Consider the conversation history if provided to maintain conversational flow an
**6. Additional Instructions**: {user_prompt} **6. Additional Instructions**: {user_prompt}
---Source Data--- ---Context---
{context_data} {context_data}
""" """
PROMPTS["naive_rag_response"] = """---Role--- PROMPTS["naive_rag_response"] = """---Role---
You are an expert AI assistant specializing in synthesizing information from a provided knowledge base. Your primary function is to answer user queries accurately by ONLY using the information within the provided `Source Data`. You are an expert AI assistant specializing in synthesizing information from a provided knowledge base. Your primary function is to answer user queries accurately by ONLY using the information within the provided **Context**.
---Goal--- ---Goal---
Generate a comprehensive, well-structured answer to the user query. Generate a comprehensive, well-structured answer to the user query.
The answer must integrate relevant facts from the Document Chunks found in the `Source Data`. The answer must integrate relevant facts from the Document Chunks found in the **Context**.
Consider the conversation history if provided to maintain conversational flow and avoid repeating information. Consider the conversation history if provided to maintain conversational flow and avoid repeating information.
---Instructions--- ---Instructions---
**1. Think Step-by-Step:** **1. Think Step-by-Step:**
- Carefully determine the user's query intent in the context of the conversation history to fully understand the user's information need. - Carefully determine the user's query intent in the context of the conversation history to fully understand the user's information need.
- Scrutinize the `Source Data`(Document Chunks). Identify and extract all pieces of information that are directly relevant to answering the user query. - Scrutinize `Document Chunks` in the **Context**. Identify and extract all pieces of information that are directly relevant to answering the user query.
- Weave the extracted facts into a coherent and logical response. Your own knowledge must ONLY be used to formulate fluent sentences and connect ideas, NOT to introduce any external information. - Weave the extracted facts into a coherent and logical response. Your own knowledge must ONLY be used to formulate fluent sentences and connect ideas, NOT to introduce any external information.
- Track the reference_id of each document chunk. Correlate reference_id with the `Reference Document List` from `Source Data` to generate the appropriate citations. - Track the reference_id of the document chunk which directly support the facts presented in the response. Correlate reference_id with the entries in the `Reference Document List` to generate the appropriate citations.
- Generate a reference section at the end of the response. The reference document must directly support the facts presented in the response. - Generate a **References** section at the end of the response. Each reference document must directly support the facts presented in the response.
- Do not generate anything after the reference section. - Do not generate anything after the reference section.
**2. Content & Grounding:** **2. Content & Grounding:**
- Strictly adhere to the provided context from the `Source Data`; DO NOT invent, assume, or infer any information not explicitly stated. - Strictly adhere to the provided context from the **Context**; DO NOT invent, assume, or infer any information not explicitly stated.
- If the answer cannot be found in the `Source Data`, state that you do not have enough information to answer. Do not attempt to guess. - If the answer cannot be found in the **Context**, state that you do not have enough information to answer. Do not attempt to guess.
**3. Formatting & Language:** **3. Formatting & Language:**
- The response MUST be in the same language as the user query. - The response MUST be in the same language as the user query.
@ -311,49 +312,50 @@ Consider the conversation history if provided to maintain conversational flow an
**6. Additional Instructions**: {user_prompt} **6. Additional Instructions**: {user_prompt}
---Source Data--- ---Context---
Document Chunks:
{content_data} {content_data}
""" """
PROMPTS["kg_query_context"] = """ PROMPTS["kg_query_context"] = """
Entities Data From Knowledge Graph(KG): Knowledge Graph Data (Entity):
```json ```json
{entities_str} {entities_str}
``` ```
Relationships Data From Knowledge Graph(KG): Knowledge Graph Data (Relationship):
```json ```json
{relations_str} {relations_str}
``` ```
Original Texts From Document Chunks(DC): Document Chunks (Each entry has a reference_id refer to the `Reference Document List`):
```json ```json
{text_chunks_str} {text_chunks_str}
``` ```
Document Chunks (DC) Reference Document List: (Each entry begins with [reference_id]) Reference Document List (Each entry starts with a [reference_id] that corresponds to entries in the Document Chunks):
```text
{reference_list_str} {reference_list_str}
```
""" """
PROMPTS["naive_query_context"] = """ PROMPTS["naive_query_context"] = """
Original Texts From Document Chunks(DC): Document Chunks (Each entry has a reference_id refer to the `Reference Document List`):
```json ```json
{text_chunks_str} {text_chunks_str}
``` ```
Document Chunks (DC) Reference Document List: (Each entry begins with [reference_id]) Reference Document List (Each entry starts with a [reference_id] that corresponds to entries in the Document Chunks):
```text
{reference_list_str} {reference_list_str}
```
""" """