Spaces:
Sleeping
Sleeping
Gary commited on
Commit ·
12927e1
1
Parent(s): 7a6b4d1
filter results
Browse files
app.py
CHANGED
|
@@ -8,8 +8,17 @@ def answer_question(subreddit, num_posts, category, question):
|
|
| 8 |
db = create_vector_db(docs)
|
| 9 |
qa_chain = create_qa_chain(db)
|
| 10 |
result = qa_chain(question)
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
# Gradio UI
|
|
|
|
| 8 |
db = create_vector_db(docs)
|
| 9 |
qa_chain = create_qa_chain(db)
|
| 10 |
result = qa_chain(question)
|
| 11 |
+
output = result["result"]
|
| 12 |
+
|
| 13 |
+
# Remove instruction sentence
|
| 14 |
+
output = output.replace(
|
| 15 |
+
"Use the following pieces of context to answer the question at the end. If you don't know the answer, just say that you don't know, don't try to make up an answer.",
|
| 16 |
+
"",
|
| 17 |
+
)
|
| 18 |
+
# Remove everything after "Example:"
|
| 19 |
+
output = output.split("Example:")[0]
|
| 20 |
+
|
| 21 |
+
return output.strip()
|
| 22 |
|
| 23 |
|
| 24 |
# Gradio UI
|