arjunanand13 commited on
Commit
4b691ed
1 Parent(s): dd2e81b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -10
app.py CHANGED
@@ -131,21 +131,26 @@ chain = ConversationalRetrievalChain.from_llm(llm, vectorstore.as_retriever(), r
131
  chat_history = []
132
 
133
  def format_prompt(query):
134
- # This prompt is designed to guide the LLM to respond in a specified format
135
  prompt = f"""
136
- You are a helpful assistant with access to a specialized knowledge base. I have a question that I need answered. After providing a brief general response to the question, please return a JSON-formatted output with the following keys:
137
- - "question": The original question.
138
- - "answer": The detailed answer.
139
-
140
- related questions from database
141
- - "question " : related question
142
- - "answer" : its answer
143
-
144
- Please answer the following question:
 
 
 
 
145
  {query}
146
  """
147
  return prompt
148
 
 
149
  def qa_infer(query):
150
  formatted_prompt = format_prompt(query)
151
  result = chain({"question": formatted_prompt, "chat_history": chat_history})
 
131
  chat_history = []
132
 
133
  def format_prompt(query):
134
+ # Construct a clear and structured prompt to guide the LLM's response
135
  prompt = f"""
136
+ You are a knowledgeable assistant with access to a comprehensive database.
137
+ I need you to answer my question and provide related information in a specific format.
138
+
139
+ Here's what I need:
140
+ 1. A brief, general response to my question.
141
+ 2. A JSON-formatted output containing:
142
+ - "question": The original question.
143
+ - "answer": The detailed answer.
144
+ - "related_questions": A list of related questions and their answers, each as a dictionary with the keys:
145
+ - "question": The related question.
146
+ - "answer": The related answer.
147
+
148
+ Here's my question:
149
  {query}
150
  """
151
  return prompt
152
 
153
+
154
  def qa_infer(query):
155
  formatted_prompt = format_prompt(query)
156
  result = chain({"question": formatted_prompt, "chat_history": chat_history})