Skip to content

515. AI Utils Service

The Foretify Manager AI Utils Service is a key component that enhances the functionality of Foretellix's Advanced Interval Filter by delivering AI-powered suggestions to users as they interact with the filter.

516. Enabling the AI Utils Service in Foretify Manager

To enable AI-powered features in Foretify Manager, install and configure the AI Utils Service on a dedicated server. You must also configure the Foretify Manager Assistant with a valid access key to support AI-driven queries and suggestions.

516.1 Basic installation of Foretify Manager AI Utils Service

  1. Obtain a Foretify Manager installation package (tarball) and extract it to a location (e.g., /opt/fmanager/latest).
  2. Locate the ai_utils_service executable located under /opt/fmanager/latest/server/bin/.

  3. Run the Foretify Manager AI Utils Service server using the command:

    /opt/fmanager/latest/server/bin/ai_utils_service
    
  4. Verify that the server starts up. By default, the server listens on port 8089.

  5. Configure the Foretify Manager application.properties file with the following property:

    ai-utils.serverUrl=http://localhost:8089/
    

    Then restart the Foretify Manager service. 6. Enable inter-service communication so Foretify Manager can communicate with the AI Utils Service.

516.2 Configuring the Foretify Manager AI Utils Service

A configuration file is provided with the installation package. You can modify the default values of the config.properties file in the path /opt/fmanager/config/ai_utils_service/ to customize the server settings:

  • Server configuration

    • host: Hostname or IP address the server listens on. Default: 0.0.0.0.
    • port: Port number the server listens on. Default: 8089.
  • Foretify Manager configuration

    • host: Hostname or IP address of the Foretify Manager server. Default: localhost.
    • port: Port number for Foretify Manager. Default: 8080.
    • https: Whether to use HTTPS when connecting. Default: true.
    • username: Leave empty to use the default username.
    • password: Leave empty to use the default password.
  • Database configuration

    • db_file_path: Path to the local cache database file.
  • Embedding configuration

    • assistant_key: API key for the Foretify Manager Assistant. Refer to Setting up the Assistant. Alternatively, you can set the FTX_ASSISTANT_KEY environment variable.

516.2.1 Example configuration file

[server]
host = 0.0.0.0
port = 8089

[fmanager]
host = localhost
port = 8080
https = true

[database]
db_file_path = DB/interval_search.db

[embeddings]
assistant_key = <assistant_key>

516.3 Deploying the Foretify Manager AI Utils Service

516.3.1 Running the AI Utils Service as a systemd service

  1. Create a new systemd service file:

    sudo touch /usr/lib/systemd/system/ai_utils_service.service
    sudo vi /usr/lib/systemd/system/ai_utils_service.service
    
  2. Create the following content in the service file:

    [Unit]
    Description=Foretify Manager AI Utils Service Daemon
    
    [Service]
    WorkingDirectory=/opt/fmanager/config/ai_utils_service
    ExecStart=/opt/fmanager/latest/server/bin/ai_utils_service
    SuccessExitStatus=143
    Restart=always
    RestartSec=30
    
    [Install]
    WantedBy=multi-user.target
    
  3. Start the service:

    sudo systemctl start ai_utils_service.service
    

    Note

    Ensure that the WorkingDirectory matches the location of your configuration files. If your configuration files are stored in a different directory, update the WorkingDirectory accordingly.

516.3.2 Running the Foretify Manager AI Utils Service as a Docker container

  1. Run the following script to build the ai_utils_service Docker image:

    /opt/fmanager/latest/docker/ai_utils_service/create_image.sh
    
  2. Use the following command to run the container:

    docker run -d -p 8089:8089 \
        -v /opt/fmanager/config/ai_utils_service/config.properties:/app/config.properties \
        -v /opt/fmanager/config/ai_utils_service/DB:/app/DB \
        --network=host \
        --name ai-utils-service \
        --restart=always \
        ai-utils-service
    

    Explanation of the command:

    • -p 8089:8089: Maps port 8089 from the container to the host.
    • -v /opt/fmanager/config/ai_utils_service/config.properties:/app/config.properties: Mounts the config.properties file into the container.
    • -v /opt/fmanager/config/ai_utils_service/DB:/app/DB: Mounts the local database to the container for persistent cache storage.
    • --network=host: Uses the host's network stack, allowing the container to communicate with services running on the host (e.g., Foretify Manager).
    • ai-utils-service: The name of the Docker image to run.
  3. Make sure the config.properties file correctly references the mounted database folder. For example, if the cache is stored in /opt/fmanager/config/ai_utils_service/DB, set the db_file_path property in config.properties to db_file_path=/app/DB.

516.3.3 Configuring Foretify Manager to use the AI Utils Service

  1. To configure Foretify Manager to use the AI Utils Service, add the following property to the application.properties file:

    ai-utils.serverUrl=http://localhost:8089/
    
  2. If the AI Utils Service is hosted on a different machine, replace localhost with that machine's hostname or IP address.

  3. If you modified the port in your config.properties file, replace 8089 with the updated value.

  4. Restart the Foretify Manager service to apply the changes.