aitoai==0.4.0
. The following configurations were used when this tutorial was created, use newer package versions at your own risk.
AitoRFHelper.py
to the root directory.AitoRFHelper.py
you will write helper functions to transform the data, predict with aito.ai, create output files and write data to the outputs. Our Python SDK exists to make the integration of aito.ai easier to Python based systems. You can leave the AitoRFHelper.py
file empty for now, we will get back to it when starting to create the workflow for the robot.vault.json
somewhere on you machine and define the URL and API key as variables for your robot to use. Here are the steps to follow:vault.json
file somewhere on your computer (not in the robot's directory if you're thinking to add it to git for example) and store your instance information in the file as variables.devdata
and create a json file in the directory called env.json
. Copy the following text into the env.json
and modify the RPA_SECRET_FILE to point to the vault.json
you created in the first step.variables
and under it a python script called variables.py
. Copy the following script to the variables.py
.tasks.robot
and underneath the *** Settings *** add:${AITO_API_URL}
and ${AITO_API_KEY}
respectively.tasks/robot.robot
it is created by Robocode lab. Let's start going through the workflow step by step.Download Ticket Data
to the tasks.Download Ticket Data
. It's a good practice to add each new keyword as a new cell for the robot as it will allow you to run just a single keyword at a time. The library RPA.HTTP
includes a Download
keyword that can be used for downloading files from URLs. For this tutorial the data files have been uploaded to S3, you can use those URLs for your robot. Set the variable overwrite
to be True
, so that when the robot is run it will download new files and overwrite the old ones.RPA.HTTP
has to be added to the *** Settings *** cell in order for the Download
keyword to work. At this point you can also add the AitoRFHelper
that you created earlier to the ĺibraries directory.Get Library Instance Keyword
keyword to the tasks. Then add a new task called Upload Training Data
, it will take in the name of the training data file and table name to be created to aito.ai as arguments. The tasks section should now look like the following.Collections
to be able to use the Get Library Instance
keyword.Upload Training Data
as a new cell in the robot file. The Upload Training Data
keyword will only upload data into aito.ai if the table does not yet exist. The Quick Add Table
keyword, provided by the aito.api, will infer a schema from the CSV, transform the data, upload the schema and the data.Create Output
task and define output and table name as arguments.Create Output
so add the code that creates an output file to the AitoRFHelper.py
.output_aito_classified.csv
being created the tasks directory.Create Output
task to tasks. This tine use a different output variable for the file name.output_needs_curation.csv
being created the tasks directory.Label Tickets With Aito
task into tasks. It will take the headers of both the labeled output, the manual curation output and the predict query.Label Tickets With Aito
keyword into a new cell. The keyword takes two arguments, headers for the output files. The test data is then read and formated from CSV into JSON as aito.ai queries work in JSON. The keyword Format CSV To Json
we created to the AitoRFHelper.py
previously when making the functions to add test data into aito.ai. The result is fetched separately for each row by a for loop and then the result is stored either into the labeled output or the manual curation output, depending on the probability of the result.predictField
in this case it is category
and threshold you want to use for the predictions as threshold
.Label Tickets With Aito
a bit closer you'll notice that you still have three keywords which haven't been defined, Format CSV To Json
, Predict Row
and Append Output
. Those you will add into the AitoRFHelper.py
. The formatting of the file is needed for making the queries for aito.ai.predict_row
function, looks like the following (data from the first row of the test data is used as an example).from
clause defines the table we're using for the prediction. Resembles FROM in SQL.where
clause defines the prior information we have on the ticket by using propositions, e.g. "ticket_type": 0
. This information is used by aito.ai to deduce a label for the ticket.predict
clause you define the column which you are trying to predict, in this case it's the category
column."limit": 1
aito.ai will return only one result by default the results are ordered by highest probability to the lowest, so the first result is the one with highest probability.append_output
function to AitoRFHelper.py
before trying to run the labeling task.Upload Data
to tasks.Upload Data
keyword as follows. The data has to first be transformed into the JSON format (function was defined in the AitoRFHelper.py
) and then the Upload Entries
can be used to upload the data into aito.ai.aito_api_url
and aito_api_key
to the keys section (use the read/write API key value) and click "Confirm". You can get your instance information through the Console.