Spaces:
Runtime error
Runtime error
on1onmangoes
commited on
Commit
•
3997cd6
1
Parent(s):
c03dabe
Update app.py
Browse files
app.py
CHANGED
@@ -134,6 +134,36 @@ CSS = """
|
|
134 |
}
|
135 |
"""
|
136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
# Title for the application
|
138 |
TITLE = "<h1 style='text-align:center;'>CNI RAG AGENTIC v0.1</h1>"
|
139 |
|
@@ -213,17 +243,6 @@ with gr.Blocks(css=CSS) as demo:
|
|
213 |
],
|
214 |
)
|
215 |
|
216 |
-
# with gr.Tab("Process PDF"):
|
217 |
-
# pdf_input = gr.File(label="Upload PDF File")
|
218 |
-
# pdf_output = gr.Textbox(label="PDF Result", interactive=False)
|
219 |
-
|
220 |
-
# pdf_button = gr.Button("Process PDF")
|
221 |
-
# pdf_button.click(
|
222 |
-
# process_pdf,
|
223 |
-
# inputs=[pdf_input],
|
224 |
-
# outputs=pdf_output
|
225 |
-
# )
|
226 |
-
|
227 |
with gr.Tab("Process PDF"):
|
228 |
pdf_input = gr.File(label="Upload PDF File")
|
229 |
select_client_dropdown = gr.Dropdown(client_name, value="rosariarossi", label="Select or Type Client", allow_custom_value=True)
|
@@ -247,6 +266,11 @@ with gr.Blocks(css=CSS) as demo:
|
|
247 |
inputs=[question_input,answer_with_rag_select_client_dropdown ],
|
248 |
outputs=rag_output
|
249 |
)
|
|
|
|
|
|
|
|
|
|
|
250 |
|
251 |
# Launch the app
|
252 |
if __name__ == "__main__":
|
|
|
134 |
}
|
135 |
"""
|
136 |
|
137 |
+
|
138 |
+
def refresh_graph_index(index_name=index_name):
|
139 |
+
# Check if index exists; if not, create it
|
140 |
+
if index_name not in pc.list_indexes().names():
|
141 |
+
pc.create_index(
|
142 |
+
index_name,
|
143 |
+
dimension=dimension_embedding_model,
|
144 |
+
metric='cosine',
|
145 |
+
spec=spec
|
146 |
+
)
|
147 |
+
# Wait for index to be ready
|
148 |
+
while not pc.describe_index(index_name).status['ready']:
|
149 |
+
time.sleep(1)
|
150 |
+
|
151 |
+
# Connect to Pinecone index
|
152 |
+
index = pc.Index(index_name)
|
153 |
+
text_field = 'content'
|
154 |
+
|
155 |
+
# Initialize Vector Store
|
156 |
+
vectorstore = LangchainPinecone(
|
157 |
+
index, embed_model.embed_query, text_field
|
158 |
+
)
|
159 |
+
return index, vectorstore
|
160 |
+
|
161 |
+
def delete_index():
|
162 |
+
pc.delete_index(index_name)
|
163 |
+
index, vectorstore = refresh_graph_index(index_name)
|
164 |
+
return "Delete & Refresh Sucessful "
|
165 |
+
|
166 |
+
|
167 |
# Title for the application
|
168 |
TITLE = "<h1 style='text-align:center;'>CNI RAG AGENTIC v0.1</h1>"
|
169 |
|
|
|
243 |
],
|
244 |
)
|
245 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
with gr.Tab("Process PDF"):
|
247 |
pdf_input = gr.File(label="Upload PDF File")
|
248 |
select_client_dropdown = gr.Dropdown(client_name, value="rosariarossi", label="Select or Type Client", allow_custom_value=True)
|
|
|
266 |
inputs=[question_input,answer_with_rag_select_client_dropdown ],
|
267 |
outputs=rag_output
|
268 |
)
|
269 |
+
with gr.Tab(label="Manage Files"):
|
270 |
+
with gr.Column():
|
271 |
+
delete_index_button = gr.Button("Delete All Files")
|
272 |
+
delete_index_textout = gr.Textbox(label="Deleted Files and Refresh Result")
|
273 |
+
delete_index_button.click(fn=delete_index, inputs=[],outputs=[delete_index_textout])
|
274 |
|
275 |
# Launch the app
|
276 |
if __name__ == "__main__":
|