Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,7 +27,7 @@ class MyApp:
|
|
| 27 |
self.documents.append({"page": page_num + 1, "content": text})
|
| 28 |
print("PDF processed successfully!")
|
| 29 |
|
| 30 |
-
|
| 31 |
"""Builds a vector database using the content of the PDF."""
|
| 32 |
model = SentenceTransformer('all-MiniLM-L6-v2')
|
| 33 |
self.embeddings = model.encode([doc["content"] for doc in self.documents])
|
|
@@ -66,7 +66,7 @@ def respond(
|
|
| 66 |
|
| 67 |
# RAG - Retrieve relevant documents
|
| 68 |
retrieved_docs = app.search_documents(message)
|
| 69 |
-
context = "\n
|
| 70 |
messages.append({"role": "system", "content": "Relevant information: " + context})
|
| 71 |
|
| 72 |
response = ""
|
|
@@ -93,10 +93,9 @@ with demo:
|
|
| 93 |
examples=[
|
| 94 |
["How I feel positive about my studies?"],
|
| 95 |
["What do meditation relax my stress?"],
|
| 96 |
-
["Can you guide me about my
|
| 97 |
["How do I ignore the negative facts and remain positive?"],
|
| 98 |
["How do I politely decline an invitation?"],
|
| 99 |
-
|
| 100 |
],
|
| 101 |
title='Focus on your goals❤️🕊️'
|
| 102 |
)
|
|
@@ -104,3 +103,4 @@ with demo:
|
|
| 104 |
if __name__ == "__main__":
|
| 105 |
demo.launch()
|
| 106 |
|
|
|
|
|
|
| 27 |
self.documents.append({"page": page_num + 1, "content": text})
|
| 28 |
print("PDF processed successfully!")
|
| 29 |
|
| 30 |
+
def build_vector_db(self) -> None:
|
| 31 |
"""Builds a vector database using the content of the PDF."""
|
| 32 |
model = SentenceTransformer('all-MiniLM-L6-v2')
|
| 33 |
self.embeddings = model.encode([doc["content"] for doc in self.documents])
|
|
|
|
| 66 |
|
| 67 |
# RAG - Retrieve relevant documents
|
| 68 |
retrieved_docs = app.search_documents(message)
|
| 69 |
+
context = "\n.join(retrieved_docs)
|
| 70 |
messages.append({"role": "system", "content": "Relevant information: " + context})
|
| 71 |
|
| 72 |
response = ""
|
|
|
|
| 93 |
examples=[
|
| 94 |
["How I feel positive about my studies?"],
|
| 95 |
["What do meditation relax my stress?"],
|
| 96 |
+
["Can you guide me about my career Options?"],
|
| 97 |
["How do I ignore the negative facts and remain positive?"],
|
| 98 |
["How do I politely decline an invitation?"],
|
|
|
|
| 99 |
],
|
| 100 |
title='Focus on your goals❤️🕊️'
|
| 101 |
)
|
|
|
|
| 103 |
if __name__ == "__main__":
|
| 104 |
demo.launch()
|
| 105 |
|
| 106 |
+
|