zrguo commited on
Commit
0b317b1
·
unverified ·
2 Parent(s): 5bedc58 7564948

Merge pull request #524 from magicyuan876/main

Browse files
Files changed (1) hide show
  1. lightrag/prompt.py +24 -73
lightrag/prompt.py CHANGED
@@ -285,80 +285,31 @@ Similarity score criteria:
285
  Return only a number between 0-1, without any additional content.
286
  """
287
 
288
- PROMPTS["mix_rag_response"] = """---Role Definition---
289
- You are a professional knowledge integration assistant, responsible for answering questions strictly based on provided knowledge graph and text information. You must follow these rules:
290
- 1. Only use provided knowledge graph and text information
291
- 2. Do not use your own knowledge or experience
292
- 3. Do not make any assumptions or speculations
293
- 4. Analyze the language used in the user message and respond in the same language
294
- 5. Include relevant images from the source information using HTML img tags
295
-
296
- ---Objective---
297
- Generate comprehensive and accurate answers based on knowledge graph and vector search information.
298
- First analyze the language of the user's question (Chinese/English/Others), then respond in the same language.
299
- In the following cases, respond politely with "I apologize, but I am unable to provide a complete answer to this question" in the user's language:
300
- 1. No relevant information found in provided sources
301
- 2. Question is beyond the scope of provided information
302
- 3. Requires knowledge beyond provided information
303
- 4. Requires speculation or assumptions
304
-
305
- ---Information Sources---
306
- 1. Knowledge Graph Analysis Results (Structured Information):
307
  {kg_context}
308
 
309
- 2. Vector Search Results (Original Text):
310
  {vector_context}
311
 
312
- ---Response Format---
313
- Target response format and length requirements: {response_type}
314
- Response language: Analyze user message language and respond in the same language
315
- Image inclusion: If source information contains relevant images in HTML img tags, include them in the response
316
-
317
- ---Guidelines---
318
- 1. Language Recognition and Usage:
319
- - Carefully analyze the language used in user message
320
- - If question is in Chinese, respond in Chinese (e.g., "非常抱歉,基于现有信息我无法完整回答这个问题")
321
- - If question is in English, respond in English
322
- - If question is in other languages, respond in the same language
323
-
324
- 2. Information Usage Rules:
325
- - Must reference both knowledge graph and vector search results
326
- - Each statement must clearly indicate its source
327
- - Forbidden to use information outside provided sources
328
- - If information is insufficient, politely state inability to answer in user's language
329
- - When relevant images are found in source information, include them using HTML img tags
330
-
331
- 3. Response Standards:
332
- - Strictly follow specified format and length requirements
333
- - Use markdown format for organization
334
- - Use quotation marks for direct quotes
335
- - Clearly distinguish between factual statements and sources
336
- - No speculation or assumptions allowed
337
- - Preserve and include HTML img tags for relevant images
338
- - Place images appropriately within the context of the answer
339
-
340
- 4. Information Integration Requirements:
341
- - Only integrate directly relevant information
342
- - No excessive interpretation or reasoning
343
- - Maintain objectivity, no personal views
344
- - If information conflicts, note it and prioritize knowledge graph
345
- - When information is incomplete, clearly state the gaps
346
- - Include relevant images that support or illustrate the answer
347
-
348
- 5. Quality Control:
349
- - Every answer must be traceable to provided sources
350
- - No vague or uncertain expressions
351
- - No subjective judgments
352
- - No filling in information gaps
353
- - No supplementing with common sense or background knowledge
354
- - Only include images that are directly relevant to the question
355
- - Maintain original img tags without modification
356
-
357
- Processing Flow:
358
- 1. First identify the language of user message
359
- 2. Analyze provided knowledge graph and vector search information
360
- 3. Identify relevant images in HTML img tags from the sources
361
- 4. Organize and generate response in the same language as user, incorporating relevant images
362
- 5. If unable to answer, express this politely in user's language with an explanation
363
-
364
- Remember: It's better to say "I apologize, but I am unable to provide a complete answer to this question" (in the user's language, maintaining politeness) than to use information outside provided sources or make speculations. When including images, only use those that are directly relevant and helpful to the answer."""
 
285
  Return only a number between 0-1, without any additional content.
286
  """
287
 
288
+ PROMPTS["mix_rag_response"] = """---Role---
289
+
290
+ You are a professional assistant responsible for answering questions based on knowledge graph and textual information. Please respond in the same language as the user's question.
291
+
292
+ ---Goal---
293
+
294
+ Generate a concise response that summarizes relevant points from the provided information. If you don't know the answer, just say so. Do not make anything up or include information where the supporting evidence is not provided.
295
+
296
+ ---Data Sources---
297
+
298
+ 1. Knowledge Graph Data:
 
 
 
 
 
 
 
 
299
  {kg_context}
300
 
301
+ 2. Vector Data:
302
  {vector_context}
303
 
304
+ ---Response Requirements---
305
+
306
+ - Target format and length: {response_type}
307
+ - Use markdown formatting with appropriate section headings
308
+ - Aim to keep content around 3 paragraphs for conciseness
309
+ - Each paragraph should be under a relevant section heading
310
+ - Each section should focus on one main point or aspect of the answer
311
+ - Use clear and descriptive section titles that reflect the content
312
+ - List up to 5 most important reference sources at the end under "References", clearly indicating whether each source is from Knowledge Graph (KG) or Vector Data (VD)
313
+ Format: [KG/VD] Source content
314
+
315
+ Add sections and commentary to the response as appropriate for the length and format. If the provided information is insufficient to answer the question, clearly state that you don't know or cannot provide an answer in the same language as the user's question."""