Update app.py
Browse files
app.py
CHANGED
@@ -25,6 +25,30 @@ openai.api_key = os.environ["OPENAI_API_KEY"]
|
|
25 |
# Get openai API key
|
26 |
pinecone_key = os.environ["PINECONE_API_KEY"]
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
# template = PromptTemplate(
|
30 |
# prompt="""
|
@@ -180,29 +204,7 @@ def run_query(input_text, country, model_sel):
|
|
180 |
st.markdown('References are based on text automatically extracted from climate policy documents. These extracts may contain non-legible characters or disjointed text as an artifact of the extraction procedure')
|
181 |
st.markdown(references, unsafe_allow_html=True)
|
182 |
|
183 |
-
# # Setup retriever, pulling from local faiss datastore
|
184 |
-
# retriever = EmbeddingRetriever(
|
185 |
-
# document_store=FAISSDocumentStore.load(
|
186 |
-
# index_path="./cpv_full_southern_africa_kenya.faiss",
|
187 |
-
# config_path="./cpv_full_southern_africa_kenya.json",
|
188 |
-
# ),
|
189 |
-
# embedding_model="sentence-transformers/multi-qa-mpnet-base-dot-v1",
|
190 |
-
# model_format="sentence_transformers",
|
191 |
-
# progress_bar=False,
|
192 |
-
# )
|
193 |
-
|
194 |
-
# Setup retriever, pulling from pinecone
|
195 |
-
doc_file_name="cpv_full_southern_africa"
|
196 |
-
document_store = PineconeDocumentStore(api_key=pinecone_key,
|
197 |
-
environment="asia-southeast1-gcp-free",
|
198 |
-
index=doc_file_name)
|
199 |
|
200 |
-
retriever = EmbeddingRetriever(
|
201 |
-
document_store=document_store,
|
202 |
-
embedding_model="sentence-transformers/multi-qa-mpnet-base-dot-v1",
|
203 |
-
model_format="sentence_transformers",
|
204 |
-
progress_bar=False,
|
205 |
-
)
|
206 |
|
207 |
|
208 |
with st.sidebar:
|
@@ -259,12 +261,10 @@ else:
|
|
259 |
client = InferenceClient()
|
260 |
|
261 |
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
# else:
|
267 |
-
# text = st.text_area('Enter your question in the text box below using natural language or select an example from above:', value=selected_example)
|
268 |
|
269 |
|
270 |
if st.button('Submit'):
|
|
|
25 |
# Get openai API key
|
26 |
pinecone_key = os.environ["PINECONE_API_KEY"]
|
27 |
|
28 |
+
# # Setup retriever, pulling from local faiss datastore
|
29 |
+
# retriever = EmbeddingRetriever(
|
30 |
+
# document_store=FAISSDocumentStore.load(
|
31 |
+
# index_path="./cpv_full_southern_africa_kenya.faiss",
|
32 |
+
# config_path="./cpv_full_southern_africa_kenya.json",
|
33 |
+
# ),
|
34 |
+
# embedding_model="sentence-transformers/multi-qa-mpnet-base-dot-v1",
|
35 |
+
# model_format="sentence_transformers",
|
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="""
|
|
|
204 |
st.markdown('References are based on text automatically extracted from climate policy documents. These extracts may contain non-legible characters or disjointed text as an artifact of the extraction procedure')
|
205 |
st.markdown(references, unsafe_allow_html=True)
|
206 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
|
209 |
|
210 |
with st.sidebar:
|
|
|
261 |
client = InferenceClient()
|
262 |
|
263 |
|
264 |
+
if selected_example == "-":
|
265 |
+
text = st.text_area('Enter your question in the text box below using natural language or select an example from above:')
|
266 |
+
else:
|
267 |
+
text = st.text_area('Enter your question in the text box below using natural language or select an example from above:', value=selected_example)
|
|
|
|
|
268 |
|
269 |
|
270 |
if st.button('Submit'):
|