mtyrrell commited on
Commit
6978666
1 Parent(s): 848919d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -10
app.py CHANGED
@@ -36,19 +36,30 @@ pinecone_key = os.environ["PINECONE_API_KEY"]
36
  # progress_bar=False,
37
  # )
38
 
39
- # Setup retriever, pulling from pinecone
40
- doc_file_name="cpv_full_southern_africa"
41
- document_store = PineconeDocumentStore(api_key=pinecone_key,
 
 
 
42
  environment="asia-southeast1-gcp-free",
43
  index=doc_file_name)
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
- retriever = EmbeddingRetriever(
46
- document_store=document_store,
47
- embedding_model="sentence-transformers/multi-qa-mpnet-base-dot-v1",
48
- model_format="sentence_transformers",
49
- progress_bar=False,
50
- )
51
-
52
 
53
  # template = PromptTemplate(
54
  # prompt="""
 
36
  # progress_bar=False,
37
  # )
38
 
39
+
40
+ @st.cache(allow_output_mutation=True)
41
+ def get_document_store():
42
+ # Assuming you're using Elasticsearch as a document store
43
+ doc_file_name="cpv_full_southern_africa"
44
+ document_store = PineconeDocumentStore(api_key=pinecone_key,
45
  environment="asia-southeast1-gcp-free",
46
  index=doc_file_name)
47
+ return document_store
48
+
49
+ @st.cache(allow_output_mutation=True)
50
+ def get_retriever(document_store):
51
+ # Initialize the Pinecone retriever configuration here
52
+ retriever = EmbeddingRetriever(
53
+ document_store=document_store,
54
+ embedding_model="sentence-transformers/multi-qa-mpnet-base-dot-v1",
55
+ model_format="sentence_transformers",
56
+ progress_bar=False,
57
+ )
58
+ return retriever
59
 
60
+ # Get (or initialize and get) the document store and retriever
61
+ document_store = get_document_store()
62
+ retriever = get_retriever(document_store)
 
 
 
 
63
 
64
  # template = PromptTemplate(
65
  # prompt="""