Agents

Agents are to core functionality in the prophet — they allow to create a intelligent desicion engine. An agent has two stages create and trained. In order to use an agent as infernce engine, one has to first create an agnet and then train it. Afterwards it is ready for inference.

The agent model

The agent model contains all the information about the agent.

Properties

  • Name
    id
    Type
    string
    Description

    Unique identifier for the agent.

  • Name
    status
    Type
    string
    Description

    The state of the agent. Can be either created or trained.

  • Name
    dataset
    Type
    string
    Description

    The dataset a agent was trained on.

  • Name
    last_trained
    Type
    datetime
    Description

    Datetime of the last training.

  • Name
    created
    Type
    datetime
    Description

    Datetime of the agent creation.


GET/v1/agents

List all agents

This endpoint allows you to retrieve a list of all your agents.

Required attributes

  • Name
    token
    Type
    string
    Description

    The access token to your account.

Request

GET
/v1/agents
curl -G https://prophet.devhub.place/v1/agents \
  -H "token: {token}" 

Response

{
  "agents": [
    {
      "id": "29d06994-f4b9-46fb-ba8a-bd966dcb0ddc"
    },
    ...
    {
      "id": "7fe13adc-21b9-43a8-88b3-6d13aa8d062e"
    }
  ]
}

POST/v1/agents

Create an agent

This endpoint allows you to add a new agents.

Required attributes

  • Name
    token
    Type
    string
    Description

    The access token to your account.

  • Name
    name
    Type
    string
    Description

    The name of the agent in the format agent_name-version_number.

  • Name
    data_schema
    Type
    json
    Description

    The data schemata, contains SwitchColumns,IndependentColumns, DependentColumns and HelperColumns. See Data schemata for more information.

Request

POST
/v1/conversations
curl https://prophet.devhub.place/v1/agents \
  -H "token: {token}" 
  -d 'name'="GoogleAgent-v1"
  -d 'data_schema'='{
    "SwitchColumns": [...],
    "IndependentColumns": [...],
    "DependentColumns": [...],
    "HelperColumns": [...]
  }'

Response

  {
      "agent_id": "b5891a21-f6df-4709-9610-220f46a4825c",
      "agent_name": "GoogleAgent-v1",
      "message": "Agent created successfully"
  }

GET/v1/agents/:id

Retrieve an agent

This endpoint allows you to retrieve information about an agent.

Request

GET
/v1/agents/fb5c2d5e-1747-4c43-8932-74a1c5e9bbac
curl -G https://prophet.devhub.place/v1/agents/fb5c2d5e-1747-4c43-8932-74a1c5e9bbac \
  -H "token: {token}" 

Response

  {
      "created": "2023-06-26 07:23:05.615204+00:00",
      "dataset_id": "None",
      "id": "ea423427-b6f6-4a0f-8779-ff77d2d4035b",
      "last_trained": "None",
      "status": "created"
  }

POST/v1/agent/:id/train

Train agent

This endpoint allows you to train an agent with a dataset.

Required attributes

  • Name
    token
    Type
    string
    Description

    The access token to your account.

  • Name
    dataset_id
    Type
    string
    Description

    The dataset id to train the agent with.

  • Name
    model_schema
    Type
    json
    Description

    The model schemata, containing infromation about the model architecture. See Model schemata for more information.

  • Name
    training_parameters
    Type
    json
    Description

    The training parameters, containing infromation about the training process. See Training parameters for more information.

  • Name
    run_name
    Type
    string
    Description

    The name of the training run.

Request

POST
/v1/agents/fb5c2d5e-1747-4c43-8932-74a1c5e9bbac/train
    curl --location 'http://prophet.devhub.place/v1/agents/1f92ac9a-8a3a-4e30-a3ea-9c2f77310b6d/train' \
    --header 'token: fb5c2d5e-1747-4c43-8932-74a1c5e9bbac' \
    --header 'Content-Type: application/json' \
    --data '{
    "dataset_id":"fb688a0f-0bb3-443e-8488-7a062e69a5bd",
    "model_schema":{"input_size": 55,
                    "hidden_size": 32,
                    "action_size": 16,
                    "num_layers": 1,
                    "output_size": 39
                    },
    "training_parameters":{
                            "batch_size": 32,
                            "learning_rate": 0.001,
                            "num_epochs": 30
                        },
    "run_name":"model-long-test"
    }'

Response

    {
      'message': 'Agent trained successfully', 
      'file_id': agent_id
    }

GET/v1/agent/:id/train

Get training status

This endpoint allows you to get the training status.

Required attributes

  • Name
    token
    Type
    string
    Description

    The access token to your account.

Request

POGETST
/v1/agents/fb5c2d5e-1747-4c43-8932-74a1c5e9bbac/train
curl -X GET https://prophet.devhub.place/v1/agents/fb5c2d5e-1747-4c43-8932-74a1c5e9bbac/train \
  -H "token: {token}" 

Response

  {
      "agent_info": "created",
      "tensorboard": "http://64.226.87.157:6006"
  }

DELETE/v1/agent/:id

Delete a agent

This endpoint allows you to delete an agent. Note: This will permanently delete the agent.

Request

DELETE
/v1/agents/fb5c2d5e-1747-4c43-8932-74a1c5e9bbac
curl -X DELETE https://prophet.devhub.place/v1/agents/fb5c2d5e-1747-4c43-8932-74a1c5e9bbac \
  -H "token: {token}"

POST/v1/agents/:id/inference

Perform inference

This endpoint allows you to perform inference using a specific agent and a dataset stored in the Supabase database. You can pass several parameters in the POST request to define your inference requirements, such as the dataset id, data schema, whether the dataset is a timeseries or not, the number of lookback steps for inference, and others.

Required attributes

  • Name
    token
    Type
    string
    Description

    The access token to your account.

  • Name
    agent_id
    Type
    string
    Description

    The ID of the agent to use for inference.

  • Name
    dataset_id
    Type
    string
    Description

    The ID of the dataset to use for inference.

  • Name
    is_timeseries
    Type
    boolean
    Description

    Indicates whether the dataset is a timeseries or not.

  • Name
    lookback_steps
    Type
    integer
    Description

    The number of lookback steps for inference.

  • Name
    unit_index
    Type
    string
    Description

    The name of the unit index column.

  • Name
    time_index
    Type
    string
    Description

    The name of the time index column.

  • Name
    forward_steps
    Type
    integer
    Description

    The number of forward steps for inference.

  • Name
    iterations
    Type
    integer
    Description

    The number of iterations for inference.

  • Name
    target_imps
    Type
    integer
    Description

    The target number of impressions for inference.

  • Name
    cost_weights
    Type
    object
    Description

    The cost weights for inference. The object should include weights for 'ip', 'agof', 'capping', 'cpm', and 'difference'.

Request

POST
/v1/agents/618fc372-b2ab-4ba6-b036-9e5562b00bc4/inference
  curl --location 'http://prophet.devhub.place/v1/agents/b5891a21-f6df-4709-9610-220f46a4825c/inference' \
  --header 'token: fb5c2d5e-1747-4c43-8932-74a1c5e9bbac' \
  --header 'Content-Type: application/json' \
  --data '{
      "dataset_id": "cf77fa37-febd-4c10-9e53-eaa5631fdc72",
      "is_timeseries": 1,
      "lookback_steps": 4,
      "forward_steps": 1,
      "iterations": 100,
      "target_imps": 20,
      "cost_weights": {
          "ip": 0.5,
          "agof": 0.5,
          "capping": 0.5,
          "cpm": 0.5,
          "difference": 10
      },
      "unit_index": "external_id",
      "time_index": "date",
      "mode": "genetic",
      "cost_function": "custom",
      "operation": "max",
      "target_column": "followers"
  }'

Response

{
  "message": 'Agent trained successfully', 
  "recommended_decision": {
    "setting_A": XY,
    "setting_B": AS,
    ...
    },
  "predicted_state": {
      "IndependentCol_A": 2313,
      "IndependentCol_B": 351123,
      "IndependentCol_C": 32251123,
      ...
      }
}