RobotFramework-AI is a library that adds AI functionality to the Robot Framework.
It can generate test data for you using the RealTestDataGenerator but also reply to your
messages with the Chatbot.
To setup the library:
robotframework-ai folder.Use the following command to create the package.
python setup.py sdist bdist_wheel
This requires the wheel package to be installed, which can be installed with:
pip install wheel
To install the library using the package just created, use the following command.
pip install .\dist\RobotFrameworkAI-0.0.2-py3-none-any.whl
Setup the API key for the AI you want to use. This can be done by creating a new environment variable called OPENAI_KEY with your key as the value. More information about this in the AI models header below.
The library is now properly setup, to confirm it works, run the following code in a robot file. This will generate 3 addresses and create a log.html file.
*** Settings ***
Library RobotFrameworkAI
*** Test Cases ***
Exec Test
[Documentation] Test
${response} Generate Test Data openai address
Log ${response}
Opening this testlog file in a browser and opening the suite Test, the test Exec test and the keyword Log will reveal a list with the 3 addresses in the INFO section.
Each module in the RobotFramework-AI library can support multiple different AI models. Each AI model needs an API key for the generation of test data. This key gets read directly from your environment variables. Each AI model has their own API key. To define a key, create a new variable with the name of the AI model capitalized followed by "_KEY". Then set this variable to your key. At the moment only OpenAI is supported.
Example API keys - OPENAI_KEY=278bxw4m89monwxmu89wm98ufx8hwxfhqwifmxou09qwxp09jmx - GEMINI_KEY=cavhjbcZCJKnvmzxcnzkcjkczckzcskjnjn7h38nwd923hdnind
RealTestDataGenerator can generate test data for the Robot Framework similar to
the library Faker. The RealTestDataGenerator however, generates real existing data, using AI.
To generate test data simply import the package and use the keyword: Generate Test Data
This keyword takes various arguments, some being specific for the generation of certain
types of test data.
The following arguments can be used (arguments prefixed by an * are required):
NOTE: Be careful with changing the temperature, top p, frequency- and presence penalty as it will likely deviate from the format we expect it to return.
When generating addresses additional argument are available. These arguments are as follows:
Generate 3 addresses from anywhere using OpenAI:
Generate Test Data openai address
Generate 10 addresses from Finland using the gpt-3.5-turbo from OpenAI in the default format with a token limit at 1024, temperature at 1, top p at .5 and frequency- and presence penalty at 0
Generate Test Data openai address gpt-3.5-turbo 10 None 1024 1 .5 0 0 country=finland
The Chatbot is a simple response generating library for Robot Framework similar to
ChatGPT on the web. You can ask it a question or give it a task to have it automatically
reply to your emails.
The following arguments can be used (arguments prefixed by an * are required):
keep_history: bool = False A flag to keep the chat history of previous messages. When settings this to True, your previous prompt and the response by the AI will be saved for the next message. This feature will keep the previous message, so if you want to send two messages and refer to your first message from the second message, you need to set this flag to True in the second message. Leaving this on for the third message aswell will keep both the first and second message.
NOTE: This works by incorporating the previous messages into the prompt, this will charge you again for both the prompt and response. So leaving this on, could quickly drain all your tokens.
response_format: dict = None Can be used to make the response compile to JSON. Set this to { "type": "json_object" } to make the response compile to JSON or None if it shouldn't necessarily.
Generate a response to a question using OpenAI
Generate Response openai What is the wheather today?
Declare a rule in the first message and refer to it in the second message
Generate Response openai If I say water you say fire
Generate Response openai Water keep_history=True
Generate the meaning of life in a json format using the gpt-3.5-turbo from OpenAI in the default format with a token limit at 1024, temperature at 2, top p at .5 and frequency- and presence penalty at 0 without using the previous messages in the response.
Generate Response openai What is the meaning of life? In json. gpt-3.5-turbo 1024 2 .5 0 0 False {"type": "json_object"}
The Assistant is a module that allows talking to AI and adding files to the conversation.
It functions similar to the Chatbot module, but with some changes.
With the Assistant module AI Assistants can be created, these will exists for aslong as they
are not deleted, meaning that they are still available several weeks later or indefinitely.
In the mean time new AI Assistants can be created and talked to.
Files can be uploaded to the AI for inspection or to add knowledge. Similarly files can also be send along side a message to the AI Assistant. The difference being that files send alongsides message only remain aslong as the thread (conversation). When a new thread is created, the AI Assistant wont remember previous message send to it, including files. It will only remember files uploaded to the AI assistant itself.
The Assistant can also be given instructions and parameters to influence its behaviour. These
can be given at creation or later be changed.
The Assistant has 9 different keywords that can be used to interact with the AI assistant.
The way the Assistant module works is that there can be multiple AI assistants. But there can
only be 1 active assistant. All keywords where it isn't explicitely mentioned which assistant
will be affected (all keywords that don't require an Id as argument), will be performed on the
active assistant.
This keyword creates a new assistant and sets it as the active assistant.
Returns the Id of the newly created assistant.
The following arguments can be used (arguments prefixed by an * are required):
Create a new assistant Test Assistant:
Set AI Model openai
Set Name Test Assistant
Create Assistant
Create a new assistant with all changing all default arguments:
Set AI Model openai
Set Name Full Featured Assistant
Set Instructions This assistant is capable of handling various technical queries.
Set Model gpt-3.5-turbo
Set Temperature 1.5
Set Top P 0.8
Set Response Format { "type": "json_object" }
Create Assistant
This keyword updates parameters of the active assistant.
This keyword takes the same arguments as the Create Assistant keyword
Returns a success message explaining which parameters have been updated.
The following arguments can be used (arguments prefixed by an * are required):
Update the active assistant's name:
Set AI Model openai
Set Name Mark
Update Assistant
Update the all the parameters of the active assistant:
Set AI Model openai
Set Name Helpy
Set Instructions You write documentation for code.
Set Model gpt-3.5-turbo
Se
$ claude mcp add robotframework-ai \
-- python -m otcore.mcp_server <graph>