Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -50,15 +50,12 @@ logger = logging.getLogger(__name__)
|
|
50 |
embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key)
|
51 |
|
52 |
# Load FAISS index with error handling
|
|
|
|
|
|
|
53 |
# Load FAISS index with error handling
|
54 |
-
|
55 |
-
|
56 |
-
try:
|
57 |
-
db = FAISS.load_local(faiss_index_path, embeddings, allow_dangerous_deserialization=True)
|
58 |
-
logger.info(f"FAISS index loaded successfully from {faiss_index_path}.")
|
59 |
-
except Exception as e:
|
60 |
-
logger.error(f"Error loading FAISS index from {faiss_index_path}: {e}")
|
61 |
-
db = None # Avoid crashing
|
62 |
|
63 |
|
64 |
# Define the prompt template
|
|
|
50 |
embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key)
|
51 |
|
52 |
# Load FAISS index with error handling
|
53 |
+
app = FastAPI()
|
54 |
+
templates = Jinja2Templates(directory="templates")
|
55 |
+
|
56 |
# Load FAISS index with error handling
|
57 |
+
db = FAISS.load_local("faiss_index", embeddings, allow_dangerous_deserialization=True)
|
58 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
|
61 |
# Define the prompt template
|