Agents enable conversation with data, including structured and unstructured data connected to MindsDB.

CREATE AGENT Syntax

Here is the syntax for creating an agent:

CREATE AGENT my_agent
USING
    model = {
        "provider": "openai",
        "model_name" : "gpt-4o",
        "api_key": "sk-abc123"
    },
    data = {
         "knowledge_bases": ["project_name.kb_name", ...],
         "tables": ["datasource_conn_name.table_name", ...]
    },
    prompt_template='describe data';

It creates an agent that uses the defined model and has access to the connected data.

SHOW AGENTS
WHERE name = 'my_agent';

model

This parameter defines the underlying language model.

The available models and providers include the following.

Users can define the model for the agent choosing one of the following options.

Option 1. Use the model parameter to define the specification.

CREATE AGENT my_agent
USING
    model = {
        "provider": "openai",
        "model_name" : "got-4o",
        "api_key": "sk-abc123",
        "base_url": "https://xxx.com/",
        "api_version": "2024-02-01"
    },
    ...

Option 2. Define the default model in the MindsDB configuration file.

You can define the default models in the Settings of the MindsDB Editor GUI.

Note that if you define default_llm in the configuration file, you do not need to provide the model parameter when creating an agent. If provide both, then the values from the model parameter are used.

"default_llm": {

      "provider": "openai",
      "model_name" : "got-4o",
      "api_key": "sk-abc123",
      "base_url": "https://xxx.com/",
      "api_version": "2024-02-01"

}

The model specification includes:

  • provider It is a required parameter. It defines the model provider.

  • model_name It is a required parameter. It defines the model name as specified by the provider.

  • api_key The API key is required to access the model. Users can provide it either in this api_key parameter, or using environment variables.

  • base_url It is an optional parameter, which defaults to https://api.openai.com/v1/. It is a required parameter when using the azure_openai provider. It is the root URL used to send API requests.

  • api_version It is an optional parameter. It is a required parameter when using the azure_openai provider. It defines the API version.

data

This parameter stores data connected to the agent, including knowledge bases and data sources connected to MindsDB.

The following parameters store the list of connected data.

  • knowledge_bases stores the list of knowledge bases to be used by the agent.

  • tables stores the list of tables from data sources connected to MindsDB.

prompt_template

This parameter stores instructions for the agent.

It is recommended to provide data description of the data sources listed in the knowledge_bases and tables parameters to help the agent locate relevant data for answering questions.

SELECT FROM AGENT Syntax

Query an agent to generate responses to questions.

SELECT answer
FROM my_agent 
WHERE question = 'What is the average number of orders per customers?';

DROP AGENT Syntax

Here is the syntax for deleting an agent:

DROP AGENT my_agent;