Skip to main content

How to Run GAIA with Mistral

This guide provides a comprehensive walkthrough for setting up and running the GAIA Avatar project, which connects to a Mistral LLM backend.

Prerequisites

Before you begin, it's crucial that you follow the instructions in the README.md file located in the ALXRAgent project directory. This will ensure your Python environment is correctly configured with all necessary dependencies.


Step 1: Run the LLM Server (ALXRAgent)

The ALXRAgent project serves the Mistral LLM over a WebSocket, allowing the GAIA frontend to communicate with it in real time.

  1. Open your terminal and navigate to the root directory of the ALXRAgent project.
  2. Execute the following command to start the server:
    python alxr_ws_server.py

Keep this server running. Note the host and port it's using, as you'll need this for the frontend configuration.


Step 2: Configure and Run the Web Application (GAIAAvatar)

This involves setting up the database, API server, and frontend for the main GAIA application.

A. Configure the API Environment

  1. Navigate to the API folder within the GAIAAvatar project.
  2. Create or edit the .env file and populate it with your database credentials:
    DB_HOST=your_domain_name
    DB_USER=alxr
    DB_PASSWORD=your_strong_password
    DB_NAME=alxrllm_db
    PORT=5050

B. Set Up the Database

Execute the following SQL script in your database management system. This will create the database, a dedicated user, and the necessary table schema.

-- 1. Create the database
CREATE DATABASE IF NOT EXISTS alxrllm_db;

-- 2. Create a dedicated user for local and remote access
CREATE USER IF NOT EXISTS 'alxr'@'localhost' IDENTIFIED BY 'your_strong_password';
CREATE USER IF NOT EXISTS 'alxr'@'%' IDENTIFIED BY 'your_strong_password';

-- 3. Grant privileges on the database to the new user
GRANT ALL PRIVILEGES ON alxrllm_db.* TO 'alxr'@'localhost';
GRANT ALL PRIVILEGES ON alxrllm_db.* TO 'alxr'@'%';

-- 4. Apply the privilege changes
FLUSH PRIVILEGES;

-- 5. Switch to the new database
USE alxrllm_db;

-- 6. Create the users table
CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
fullname VARCHAR(100) NOT NULL,
email VARCHAR(150) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
dob DATE NOT NULL,
phone VARCHAR(20) NOT NULL,
city VARCHAR(100) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

C. Run the API Server

Once the database is ready, start the backend API server.

  1. From within the API folder, run the following command:
    node gaaiserver.js

The API server is now running and will handle requests from the frontend.

Of course. Here is Part D of the guide formatted in Markdown.


D. Configure the Frontend

The final step connects the GAIA frontend to the backend services.

1. Set Up Frontend Environment Variables

In the root directory of the GAIAAvatar project, create a new file named .env.local and add the following keys. Replace the placeholder values with your actual credentials. You can get the d-id agent information from d-id website.

VITE_DID_CLIENT_KEY=your_did_client_key_here
VITE_AGENT_ID=your_agent_id_here

# This must match the simple auth key in the ALXRAgent project
VITE_ALXR_API_KEY=your_alxr_api_key_here

2. Configure the WebSocket Proxy

In the vite.config.js file, locate the server proxy settings and update the target key to point to the address of your LLM WebSocket server from Step 1.

   // Example vite.config.js configuration
...
proxy: {
// Forward API + WS to your FastAPI backend
'/v1': {
target: 'http://localhost:8080',
changeOrigin: true,
ws: true,
}
...

3. Start the Development Server

Start the frontend development server according to the project's instructions (e.g., npm run dev). Your GAIA Avatar application should now be fully configured and able to communicate with the Mistral LLM.