Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
import atexit
|
2 |
import gradio as gr
|
3 |
#from langchain.document_loaders import UnstructuredPDFLoader
|
4 |
from langchain.document_loaders import PyPDFLoader
|
@@ -153,14 +152,20 @@ def run_chain(user_query):
|
|
153 |
else:
|
154 |
print("Invalid inputs.")
|
155 |
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
#from langchain.document_loaders import UnstructuredPDFLoader
|
3 |
from langchain.document_loaders import PyPDFLoader
|
|
|
152 |
else:
|
153 |
print("Invalid inputs.")
|
154 |
|
155 |
+
def delete_index_namespace():
|
156 |
+
pinecone.init(api_key=PINECONE_API_KEY, environment=PINECONE_ENVIRONMENT)
|
157 |
+
index_namespace_to_delete = pinecone.Index(index_name=index_name)
|
158 |
+
index_namespace_to_delete.delete(delete_all=True, namespace=namespace)
|
159 |
+
print("Pinecone Index Namespace: "+namespace+" has been deleted!")
|
160 |
+
|
161 |
+
with gr.Blocks() as demo:
|
162 |
+
gr.Markdown("Start typing below and then click **Run** to see the output.")
|
163 |
+
with gr.Row():
|
164 |
+
user_query = gr.Textbox(placeholder="Enter your query here.")
|
165 |
+
ai_response = gr.Textbox()
|
166 |
+
btn_1 = gr.Button("Get AI Response")
|
167 |
+
btn_2 = gr.Button("Exit & Clear Data")
|
168 |
+
btn_1.click(fn=run_chain, inputs=user_query, outputs=ai_response)
|
169 |
+
btn_2.click(fn=delete_index_namespace)
|
170 |
+
|
171 |
+
demo.launch()
|