import os import sys import gradio as gr from utils import load_embeddings from ui import categorize_products, create_demo # Updated imports # 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 globally try: embeddings_data = load_embeddings(EMBEDDINGS_PATH) # Make embeddings available to the UI functions import ui ui.embeddings = embeddings_data except Exception as e: print(f"Error loading embeddings: {e}") sys.exit(1) # Launch the Gradio interface if __name__ == "__main__": demo = create_demo() demo.launch()