Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,6 +29,7 @@ app = FastAPI()
|
|
| 29 |
|
| 30 |
@app.get("/")
|
| 31 |
def read_root():
|
|
|
|
| 32 |
return {"message": "Connected"}
|
| 33 |
|
| 34 |
@tool
|
|
@@ -42,7 +43,7 @@ def retrieve(query_text):
|
|
| 42 |
Returns:
|
| 43 |
- str: Retrieved text from the document.
|
| 44 |
"""
|
| 45 |
-
if vector_index is None:
|
| 46 |
return "Vector index not found. Please upload a file first."
|
| 47 |
else:
|
| 48 |
retriever = app.state.vector_index.as_retriever(similarity_top_k=3)
|
|
|
|
| 29 |
|
| 30 |
@app.get("/")
|
| 31 |
def read_root():
|
| 32 |
+
app.state.vector_index = None
|
| 33 |
return {"message": "Connected"}
|
| 34 |
|
| 35 |
@tool
|
|
|
|
| 43 |
Returns:
|
| 44 |
- str: Retrieved text from the document.
|
| 45 |
"""
|
| 46 |
+
if not hasattr(app.state, "vector_index") or app.state.vector_index is None:
|
| 47 |
return "Vector index not found. Please upload a file first."
|
| 48 |
else:
|
| 49 |
retriever = app.state.vector_index.as_retriever(similarity_top_k=3)
|