JayWadekar commited on
Commit
d995ec7
·
1 Parent(s): 699fe5f

Improving RAG prompt

Browse files
Files changed (1) hide show
  1. rag.py +7 -4
rag.py CHANGED
@@ -73,10 +73,13 @@ def RAG(llm, docs, embeddings):
73
  # Adding custom instructions to the prompt
74
  template = prompt.messages[0].prompt.template
75
  template_parts = template.split("\nQuestion: {question}")
76
- if len(template_parts) == 2:
77
- print("Error: Template does not contain the expected format.")
78
- combined_template = template_parts[0] +\
79
- " Include the reference IDs in square brackets when citing specific information." + template_parts[1]
 
 
 
80
  prompt.messages[0].prompt.template = combined_template
81
 
82
  # Create the chain
 
73
  # Adding custom instructions to the prompt
74
  template = prompt.messages[0].prompt.template
75
  template_parts = template.split("\nQuestion: {question}")
76
+ combined_template = "You are an assistant for question-answering tasks. "\
77
+ + "Use the following pieces of retrieved context to answer the question. "\
78
+ + "If you don't know the answer, just say that you don't know. "\
79
+ + "Use six sentences maximum and keep the answer concise. "\
80
+ + "Write the names of the relevant functions from the retrived code. "\
81
+ + "Include the reference IDs in square brackets at the end of your answer."\
82
+ + template_parts[1]
83
  prompt.messages[0].prompt.template = combined_template
84
 
85
  # Create the chain