RoundtTble commited on
Commit
635ce8c
·
1 Parent(s): e0cd251

edit prompt

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -16,25 +16,31 @@ else:
16
  index = load_index_from_storage(storage_context)
17
 
18
  # Query Engine
19
- query_engine = index.as_query_engine(response_mode="tree_summarize")
20
 
21
- new_summary_tmpl_str = (
22
  "Context information is below.\n"
23
  "---------------------\n"
24
  "{context_str}\n"
25
  "---------------------\n"
26
  "Given the context information and not prior knowledge, "
27
- "As an employee specialized in customer service, your main role is to assist users by answering questions based on the context"
28
  "You are here to ensure that users receive accurate and helpful responses to their inquiries, making their experience smooth and satisfactory."
29
- "If you don't know something, tell the customer that you don't have the information yet and that it will be updated later."
30
- "Answer in the same language as the query"
 
 
 
 
 
 
31
  "Query: {query_str}\n"
32
  "Answer: "
33
  )
34
 
35
- new_summary_tmpl = PromptTemplate(new_summary_tmpl_str)
36
  query_engine.update_prompts(
37
- {"response_synthesizer:summary_template": new_summary_tmpl}
38
  )
39
 
40
  def predict(user_prompt: str) -> str:
 
16
  index = load_index_from_storage(storage_context)
17
 
18
  # Query Engine
19
+ query_engine = index.as_query_engine(response_mode="compact")
20
 
21
+ new_query_tmpl_str = (
22
  "Context information is below.\n"
23
  "---------------------\n"
24
  "{context_str}\n"
25
  "---------------------\n"
26
  "Given the context information and not prior knowledge, "
27
+ "As an employee specialized in customer service, your main role is to assist users by answering questions based on the context."
28
  "You are here to ensure that users receive accurate and helpful responses to their inquiries, making their experience smooth and satisfactory."
29
+ "If you don't know something, tell the user that you don't have the information yet and that it will be updated later."
30
+ "Your answer should follow this format."
31
+ "Answer in the same language as the query.\n"
32
+ "-------------------------\n"
33
+ "In this first section, You will summarize and reflect your understanding of the user's question. This step ensures you grasp exactly what the user is asking or seeking, preparing to address it appropriately in your response.\n"
34
+ "In this section, Here, you will provide a detailed answer to the user's question. This part includes relevant information, solutions, or suggestions related to the user's query, aiming to deliver the necessary insights in a clear and understandable manner.\n"
35
+ "In this final section, you'll ask if the answer was satisfactory or if there's a need for further information or clarification. This is to ensure the quality of your response and offer an opportunity to address any additional queries the user might have.\n"
36
+ "-------------------------\n"
37
  "Query: {query_str}\n"
38
  "Answer: "
39
  )
40
 
41
+ new_qeury_tmpl = PromptTemplate(new_query_tmpl_str)
42
  query_engine.update_prompts(
43
+ {"response_synthesizer:text_qa_template": new_qeury_tmpl}
44
  )
45
 
46
  def predict(user_prompt: str) -> str: