Skip to content

Wolfram Agent

The Wolfram Agent is a third-party agent powered by Wolfram|Alpha and the Wolfram Language, designed to perform advanced computations, mathematical derivations, scientific data lookups, visualizations, and knowledge-based queries.

Our AI Refinery SDK enables seamless integration with a customized Wolfram Agent through the WolframAgent class. This integration brings the full computational and knowledge power of Wolfram into applications on the AI Refinery platform.


Creating Wolfram Agents

To create and use a Wolfram Agent, follow these steps:

  1. Sign Up for a Wolfram account.
  2. Obtain a Wolfram App ID from Wolfram Developer Portal. You will need this later to access the agent.
  3. Ensure network access to the Wolfram|Alpha LLM API endpoint and verify your API key by making a test query with your App ID (e.g., using curl).

    curl "https://<WOLFRAM_LLM_API>?input=2%2B2&appid=<YOUR_APP_ID>"
    
    where you can substitute WOLFRAM_LLM_API with the API you intend to use (https://www.wolframalpha.com/api/v1/llm-api) and YOUR_APP_ID with you API key you obtained in step 2.

  4. Use this App ID and endpoint to configure your agent in AI Refinery.


Onboarding Wolfram Agent

To use the Wolfram agent through our AI Refinery SDK, users need the following configuration parameters:

Variable Description Required
app_id Name of the environment variable holding your Wolfram App ID (e.g., "WOLFRAM_APP_ID"). Yes
base_url Wolfram LLM API base URL (default: https://www.wolframalpha.com/api/v1/llm-api). Yes
timeout Time (in seconds) to wait for a Wolfram API response. No
enable_interpreter Boolean switch to enable an interpreter helper that translates the Wolfram raw responses in a user-friendly format. No
output_format Exhaustive list of Wolfram-provided components to include in responses ("text", "images", "website_link"). No

Workflow Overview

The workflow of the WolframAgent class consists of four key stages:

  1. Initialization: A Wolfram agent is created and registered in AI Refinery with the specified configuration.
  2. Sending a Query: A user query is forwarded from the AI Refinery to the Wolfram API endpoint.
  3. Wolfram-side Processing: Wolfram evaluates the computation, retrieves data, or generates plots/visualizations.
  4. Receiving and Formatting: The Wolfram agent collects the raw API response. If the interpreter is enabled, the raw response is reformatted into user-friendly text, images, and/or links according to the settings in output_format.

Usage and Quickstart

To quickly establish an AI Refinery project with a Wolfram Agent, you will need:

  • A valid Wolfram App ID.
  • A YAML configuration file that registers WolframAgent as a utility agent.

Specifically, ensure the following configurations are included:

  • Add a utility agent with agent_class: WolframAgent under utility_agents.
  • Ensure the agent_name you chose for your WolframAgent is listed in the agent_list under orchestrator.

Template YAML Configuration of WolframAgent

orchestrator:
  agent_list:
    - agent_name: "WolframComputationalAgent"  # The name you choose for your Wolfram agent

utility_agents:
  - agent_class: WolframAgent
    agent_name: "WolframComputationalAgent"  # The name you choose for your Wolfram agent
    agent_description: "An assistant that can perform computations, solve equations, and provide scientific knowledge."
    config:
      app_id: "WOLFRAM_APP_ID"  # Required: Name of the environment variable holding your Wolfram App ID
      base_url: "https://www.wolframalpha.com/api/v1/llm-api"  # Required: Wolfram LLM API endpoint
      timeout: 60  # Optional: Timeout in seconds (default: 60)
      enable_interpreter: true  # Optional: Enables interpreter for formatted responses
      output_format: ["text", "images", "website_link"]  # Optional: Output components