Update app.py
Browse files
app.py
CHANGED
|
@@ -48,39 +48,43 @@ pinecone_key = os.environ["PINECONE_API_KEY"]
|
|
| 48 |
|
| 49 |
#___________________________________________________________________________________________________________
|
| 50 |
|
| 51 |
-
@st.cache_resource
|
| 52 |
-
def get_document_store():
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
|
| 60 |
-
# Get (or initialize and get) the document store
|
| 61 |
-
document_store = get_document_store()
|
| 62 |
|
|
|
|
|
|
|
| 63 |
|
| 64 |
-
# @st.cache(allow_output_mutation=True)
|
| 65 |
-
# def get_retriever(document_store):
|
| 66 |
-
# retriever = EmbeddingRetriever(
|
| 67 |
-
# document_store=document_store,
|
| 68 |
-
# embedding_model="sentence-transformers/multi-qa-mpnet-base-dot-v1",
|
| 69 |
-
# model_format="sentence_transformers",
|
| 70 |
-
# progress_bar=False,
|
| 71 |
-
# )
|
| 72 |
-
# return retriever
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
prompt_template="Answer the given question using the following documents. \
|
| 86 |
Formulate your answer in the style of an academic report. \
|
|
|
|
| 48 |
|
| 49 |
#___________________________________________________________________________________________________________
|
| 50 |
|
| 51 |
+
# @st.cache_resource
|
| 52 |
+
# def get_document_store():
|
| 53 |
+
# doc_file_name="cpv_full_southern_africa"
|
| 54 |
+
# document_store = PineconeDocumentStore(api_key=pinecone_key,
|
| 55 |
+
# environment="asia-southeast1-gcp-free",
|
| 56 |
+
# index=doc_file_name)
|
| 57 |
+
# return document_store
|
|
|
|
| 58 |
|
|
|
|
|
|
|
| 59 |
|
| 60 |
+
# # Get (or initialize and get) the document store
|
| 61 |
+
# document_store = get_document_store()
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
+
@st.cache_resource
|
| 65 |
+
def get_retriever():
|
| 66 |
+
doc_file_name="cpv_full_southern_africa"
|
| 67 |
+
document_store = PineconeDocumentStore(api_key=pinecone_key,
|
| 68 |
+
environment="asia-southeast1-gcp-free",
|
| 69 |
+
index=doc_file_name)
|
| 70 |
+
retriever = EmbeddingRetriever(
|
| 71 |
+
document_store=document_store,
|
| 72 |
+
embedding_model="sentence-transformers/multi-qa-mpnet-base-dot-v1",
|
| 73 |
+
model_format="sentence_transformers",
|
| 74 |
+
progress_bar=False,
|
| 75 |
+
)
|
| 76 |
+
return retriever
|
| 77 |
+
|
| 78 |
+
retriever = get_retriever()
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
# # Instantiate retriever
|
| 82 |
+
# retriever = EmbeddingRetriever(
|
| 83 |
+
# document_store=document_store,
|
| 84 |
+
# embedding_model="sentence-transformers/multi-qa-mpnet-base-dot-v1",
|
| 85 |
+
# model_format="sentence_transformers",
|
| 86 |
+
# progress_bar=False,
|
| 87 |
+
# )
|
| 88 |
|
| 89 |
prompt_template="Answer the given question using the following documents. \
|
| 90 |
Formulate your answer in the style of an academic report. \
|