Running the Project
Step 1: Index the Data
First, you must populate the Vertex AI index with the embeddings from your data.json file.
Important: You need to run this script any time you add or change the data in data.json. This is a long-running operation and can take several minutes to complete.
python add_to_index.py
The script will print its progress and tell you how long the update took when it's finished.
Step 2: Run the API Server
Once the index is populated, you can start the API server.
uvicorn main:app --reload
The server will be running at http://127.0.0.1:8000.
Step 3: Use the API
The best way to interact with the API is via the automatically generated documentation.
- Open your web browser and navigate to:
http://127.0.0.1:8000/docs - Click on the
/queryendpoint to expand it. - Click "Try it out".
- Enter a question in the
query_textfield (e.g., "How do you say hello in French?"). - Click "Execute".
You will see the JSON response containing the most similar Q&A pairs from your data, ranked by their distance (lower is better).