Spaces:
Runtime error
Runtime error
arjunanand13
commited on
Commit
•
4b691ed
1
Parent(s):
dd2e81b
Update app.py
Browse files
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 |
-
#
|
135 |
prompt = f"""
|
136 |
-
You are a
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
-
|
142 |
-
|
143 |
-
|
144 |
-
|
|
|
|
|
|
|
|
|
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})
|