Skip to main content

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.

  1. Open your web browser and navigate to: http://127.0.0.1:8000/docs
  2. Click on the /query endpoint to expand it.
  3. Click "Try it out".
  4. Enter a question in the query_text field (e.g., "How do you say hello in French?").
  5. 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).