diff --git a/agent/test/dsl_examples/retrieval_and_generate.json b/agent/test/dsl_examples/retrieval_and_generate.json index b392962e2..3897e877f 100644 --- a/agent/test/dsl_examples/retrieval_and_generate.json +++ b/agent/test/dsl_examples/retrieval_and_generate.json @@ -31,7 +31,7 @@ "component_name": "LLM", "params": { "llm_id": "deepseek-chat", - "sys_prompt": "You are an intelligent assistant. Please summarize the content of the knowledge base to answer the question. Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, your answer must include the sentence \"The answer you are looking for is not found in the knowledge base!\" Answers need to consider chat history.\n Here is the knowledge base:\n {retrieval:0@formalized_content}\n The above is the knowledge base.", + "sys_prompt": "You are an intelligent assistant. Please summarize the content of the knowledge base to answer the question. Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, your answer must include the sentence \"The answer you are looking for is not found in the knowledge base!\" Answers need to consider chat history.\n Here is the knowledge base:\n {retrieval:0@formalized_content}\n Above is the knowledge base.", "temperature": 0.2 } }, diff --git a/agent/test/dsl_examples/tavily_and_generate.json b/agent/test/dsl_examples/tavily_and_generate.json index caa10d155..95739224a 100644 --- a/agent/test/dsl_examples/tavily_and_generate.json +++ b/agent/test/dsl_examples/tavily_and_generate.json @@ -25,7 +25,7 @@ "component_name": "LLM", "params": { "llm_id": "deepseek-chat", - "sys_prompt": "You are an intelligent assistant. Please summarize the content of the knowledge base to answer the question. Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, your answer must include the sentence \"The answer you are looking for is not found in the knowledge base!\" Answers need to consider chat history.\n Here is the knowledge base:\n {tavily:0@formalized_content}\n The above is the knowledge base.", + "sys_prompt": "You are an intelligent assistant. Please summarize the content of the knowledge base to answer the question. Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, your answer must include the sentence \"The answer you are looking for is not found in the knowledge base!\" Answers need to consider chat history.\n Here is the knowledge base:\n {tavily:0@formalized_content}\n Above is the knowledge base.", "temperature": 0.2 } }, diff --git a/sdk/python/ragflow_sdk/modules/chat.py b/sdk/python/ragflow_sdk/modules/chat.py index 5935b5b70..53fcc1af9 100644 --- a/sdk/python/ragflow_sdk/modules/chat.py +++ b/sdk/python/ragflow_sdk/modules/chat.py @@ -50,10 +50,12 @@ class Chat(Base): self.opener = "Hi! I'm your assistant. What can I do for you?" self.show_quote = True self.prompt = ( - "You are an intelligent assistant. Please summarize the content of the knowledge base to answer the question. " - "Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, " - "your answer must include the sentence 'The answer you are looking for is not found in the knowledge base!' " - "Answers need to consider chat history.\nHere is the knowledge base:\n{knowledge}\nThe above is the knowledge base." + "You are an intelligent assistant. Your primary function is to answer questions based strictly on the provided knowledge base." + "**Essential Rules:**" + "- Your answer must be derived **solely** from this knowledge base: `{knowledge}`." + "- **When information is available**: Summarize the content to give a detailed answer." + "- **When information is unavailable**: Your response must contain this exact sentence: 'The answer you are looking for is not found in the knowledge base!' " + "- **Always consider** the entire conversation history." ) super().__init__(rag, res_dict) diff --git a/sdk/python/ragflow_sdk/ragflow.py b/sdk/python/ragflow_sdk/ragflow.py index f200a6b5c..e46023177 100644 --- a/sdk/python/ragflow_sdk/ragflow.py +++ b/sdk/python/ragflow_sdk/ragflow.py @@ -146,10 +146,12 @@ class RAGFlow: prompt.opener = "Hi! I'm your assistant. What can I do for you?" if prompt.prompt is None: prompt.prompt = ( - "You are an intelligent assistant. Please summarize the content of the knowledge base to answer the question. " - "Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, " - "your answer must include the sentence 'The answer you are looking for is not found in the knowledge base!' " - "Answers need to consider chat history.\nHere is the knowledge base:\n{knowledge}\nThe above is the knowledge base." + "You are an intelligent assistant. Your primary function is to answer questions based strictly on the provided knowledge base." + "**Essential Rules:**" + "- Your answer must be derived **solely** from this knowledge base: `{knowledge}`." + "- **When information is available**: Summarize the content to give a detailed answer." + "- **When information is unavailable**: Your response must contain this exact sentence: 'The answer you are looking for is not found in the knowledge base!' " + "- **Always consider** the entire conversation history." ) temp_dict = {"name": name, "avatar": avatar, "dataset_ids": dataset_list if dataset_list else [], "llm": llm.to_json(), "prompt": prompt.to_json()} diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts index 6e2e18144..9329c2c61 100644 --- a/web/src/locales/en.ts +++ b/web/src/locales/en.ts @@ -647,10 +647,13 @@ This auto-tagging feature enhances retrieval by adding another layer of domain-s knowledgeBasesTip: 'Select the datasets to associate with this chat assistant. An empty knowledge base will not appear in the dropdown list.', system: 'System prompt', - systemInitialValue: `You are an intelligent assistant. Please summarize the content of the knowledge base to answer the question. Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, your answer must include the sentence "The answer you are looking for is not found in the knowledge base!" Answers need to consider chat history. - Here is the knowledge base: - {knowledge} - The above is the knowledge base.`, + systemInitialValue: `You are an intelligent assistant. Your primary function is to answer questions based strictly on the provided knowledge base. + + **Essential Rules:** + - Your answer must be derived **solely** from this knowledge base: \`{knowledge}\`. + - **When information is available**: Summarize the content to give a detailed answer. + - **When information is unavailable**: Your response must contain this exact sentence: "The answer you are looking for is not found in the knowledge base!" + - **Always consider** the entire conversation history.`, systemMessage: 'Please input!', systemTip: 'Your prompts or instructions for the LLM, including but not limited to its role, the desired length, tone, and language of its answers. If your model has native support for reasoning, you can add //no_thinking add the prompt to stop reasoning.',