Run Agent Intelligence Toolkit Workflows#

A workflow is defined by a YAML configuration file that specifies the tools and models to use. AIQ toolkit provides the following ways to run a workflow:

  • Using the aiq run command.

    • This is the simplest and most common way to run a workflow.

  • Using the aiq serve command.

    • This starts a web server that listens for incoming requests and runs the specified workflow.

  • Using the aiq eval command.

    • In addition to running the workflow, it also evaluates the accuracy of the workflow.

  • Using the Python API

    • This is the most flexible way to run a workflow.

Running Workflows

Using the aiq run Command#

The aiq run command is the simplest way to run a workflow. aiq run receives a configuration file as specified by the --config_file flag, along with input that can be specified either directly with the --input flag or by providing a file path with the --input_file flag.

A typical invocation of the aiq run command follows this pattern:

aiq run --config_file <path/to/config.yml> [--input "question?" | --input_file <path/to/input.txt>]

The following command runs the examples/simple workflow with a single input question “What is LangSmith?”:

aiq run --config_file examples/simple/configs/config.yml --input "What is LangSmith?"

The following command runs the same workflow with the input question provided in a file:

echo "What is LangSmith?" > .tmp/input.txt
aiq run --config_file examples/simple/configs/config.yml --input_file .tmp/input.txt

Using the aiq eval Command#

The aiq eval command is similar to the aiq run command. However, in addition to running the workflow, it also evaluates the accuracy of the workflow, refer to Evaluating AIQ toolkit Workflows for more information.

Using the aiq serve Command#

The aiq serve command starts a web server that listens for incoming requests and runs the specified workflow. The server can be accessed with a web browser or by sending a POST request to the server’s endpoint. Similar to the aiq run command, the aiq serve command requires a configuration file specified by the --config_file flag.

The following command runs the examples/simple workflow on a web server listening to the default port 8000 and default endpoint of /generate:

aiq serve --config_file examples/simple/configs/config.yml

In a separate terminal, run the following command to send a POST request to the server:

curl --request POST \
  --url http://localhost:8000/generate \
  --header 'Content-Type: application/json' \
  --data '{
    "input_message": "What is LangSmith?"
}'

Refer to aiq serve --help for more information on how to customize the server.

Using the Python API#

Using the Python API for running workflows is outside the scope of this document. Refer to the Python API documentation for the AIQRunner class for more information.