esilver's picture
added app.py
2321bf7
raw
history blame
787 Bytes
import os
import sys
from utils import load_embeddings
from ui import create_demo
# Path to the embeddings file
EMBEDDINGS_PATH = "ingredient_embeddings_voyageai.pkl"
# Check if embeddings file exists
if not os.path.exists(EMBEDDINGS_PATH):
print(f"Error: Embeddings file {EMBEDDINGS_PATH} not found!")
print(f"Please ensure the file exists at {os.path.abspath(EMBEDDINGS_PATH)}")
sys.exit(1)
# Load embeddings
try:
embeddings_data = load_embeddings(EMBEDDINGS_PATH)
# Update the embeddings in the ui module
import ui
ui.embeddings = embeddings_data
except Exception as e:
print(f"Error loading embeddings: {e}")
sys.exit(1)
# Create the Gradio interface
demo = create_demo()
# For Hugging Face Spaces, we need to use the app variable
app = demo