Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -51,6 +51,9 @@ class QueryInput(BaseModel):
|
|
| 51 |
query: str
|
| 52 |
index_name: str
|
| 53 |
|
|
|
|
|
|
|
|
|
|
| 54 |
@app.get("/")
|
| 55 |
async def test():
|
| 56 |
return {"Message":"Application is working !!"}
|
|
@@ -114,15 +117,13 @@ async def query_index(query_input: QueryInput):
|
|
| 114 |
return {"response": response.response}
|
| 115 |
|
| 116 |
@app.delete("/delete_index/")
|
| 117 |
-
async def delete_index():
|
| 118 |
-
|
| 119 |
-
|
|
|
|
| 120 |
|
| 121 |
pc = Pinecone(api_key=pinecone_api_key)
|
| 122 |
-
index_name = "demo-index-2"
|
| 123 |
pc.delete_index(index_name)
|
| 124 |
-
state["index_created"] = False
|
| 125 |
-
state["vector_store"] = None
|
| 126 |
|
| 127 |
return {"message": "Index deleted successfully"}
|
| 128 |
|
|
|
|
| 51 |
query: str
|
| 52 |
index_name: str
|
| 53 |
|
| 54 |
+
class delete_index(BaseModel):
|
| 55 |
+
index_name:str
|
| 56 |
+
|
| 57 |
@app.get("/")
|
| 58 |
async def test():
|
| 59 |
return {"Message":"Application is working !!"}
|
|
|
|
| 117 |
return {"response": response.response}
|
| 118 |
|
| 119 |
@app.delete("/delete_index/")
|
| 120 |
+
async def delete_index(delete_input:delete_index):
|
| 121 |
+
index_name = delete_input.index_name
|
| 122 |
+
if index_name not in pc.list_indexes().names():
|
| 123 |
+
return {"message":"Index is not already present to delete it !"}
|
| 124 |
|
| 125 |
pc = Pinecone(api_key=pinecone_api_key)
|
|
|
|
| 126 |
pc.delete_index(index_name)
|
|
|
|
|
|
|
| 127 |
|
| 128 |
return {"message": "Index deleted successfully"}
|
| 129 |
|