RobotFramework-AI
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.
Setup
To setup the library:
Start by cloning this repository.
Open a terminal and locate the 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.

AI models
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
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):
- *ai_model: str: The AI model to be used, e.g. "openai", "gemini", "copilot", etc. Currently supporting: "openai"
- *type: str: The type of test data to create, e.g. "address", "user_data", etc. Currently supporting: "address"
- model: str: AI model specfic. The model of the AI model to be used. E.g. "gpt-3.5-turbo" when using the "openai" AI model.
Default per AI model:
- "openai" = "gpt-3.5-turbo"
- amount: int = 3 The amount of rows of test data to generate.
- format: str = None The format in which the test data will be given. If None, will return a 2 dimensional list.
- max_tokens: int = 256 The token limit for a conversation. Both prompt and response tokens will count towards this limit.
- temperature: float = 1 This value determines the creativity of the AI model. Can be anything from 0-2.
- top_p: float = 1 Similar to temperature. Determines the selection of tokens before selecting one.
The higher the value the more less likely tokens get added to the selection. Can be anything from 0-2. At 1,
only the top 50% of tokens will be used when selecting a token at 0 all tokens will be taken into consideration
- frequency_penalty: float = 0 Penalizes more frequent token reducing the chance of it reappearing.
Negative values encourage it to reuse tokens. Can be anything from -2 to 2.
- presence_penalty: float = 0 Exact same as frequency_penalty except its scope is reduced to the immediate context.
The immediate context can be seen as one or more paragrahps about a singular subject.
Can be anything from -2 to 2.
- kwargs: dict: Additional arguments can be supplied for specific types of test data. These will be explained in per type below
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.
Addresses
When generating addresses additional argument are available. These arguments are as follows:
- Country:str: The country from which to create addresses. If None, will generate an address from anywhere. Default = None
Examples
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
Chatbot
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):
*ai_model: str: The AI model to be used, e.g. "openai", "gemini", "copilot", etc. Currently supporting: "openai"
*message: str: The message you want to send to the AI model, e.g. "What is the weather today?"
model: str: AI model specfic. The model of the AI model to be used. E.g. "gpt-3.5-turbo" when using the "openai" AI model.
Default depends on AI model:
- "openai" = "gpt-3.5-turbo"
max_tokens: int = 256 The token limit for a conversation. Both prompt and response tokens will count towards this limit.
temperature: float = 1 This value determines the creativity of the AI model. Can be anything from 0-2.
top_p: float = 1 Similar to temperature. Determines the selection of tokens before selecting one.
The higher the value the more less likely tokens get added to the selection. Can be anything from 0-2.
At 1, only the top 50% of tokens will be used when selecting a token at 0 all tokens will be taken into consideration
frequency_penalty: float = 0 Penalizes more frequent token reducing the chance of it reappearing.
Negative values encourage it to reuse tokens. Can be anything from -2 to 2.
presence_penalty: float = 0 Exact same as frequency_penalty except its scope is reduced to the immediate context.
The immediate context can be seen as one or more paragrahps about a singular subject.
Can be anything from -2 to 2.
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.
Examples
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"}
Assistant
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.
Keywords
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.
Create 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):
- *ai_model: str: The AI model to be used, e.g. "openai", "gemini", "copilot", etc. Currently supporting: "openai"
- *name: str: The name of the assistant. This name will show up in responses and in the logs, e.g. "Bob". Max 256 characters
- *instructions: str: The instructions given to the assistant. Here you can explain how the assistant should behave, e.g. "You are a software engineer that can debug my code and explain it in a easy to understand manner". Max 256,000 characters
- model: str: AI model specfic. The model of the AI model to be used. E.g. "gpt-3.5-turbo" when using the "openai" AI model. Default depends on AI model:
- "openai" = "gpt-3.5-turbo"
- temperature: float = 1 This value determines the creativity of the AI model. Can be anything from 0-2.
- top_p: float = 1 Similar to temperature. Determines the selection of tokens before selecting one. The higher the value the more less likely tokens get added to the selection. Can be anything from 0-2. At 1, only the top 50% of tokens will be used when selecting a token at 0 all tokens will be taken into consideration
- 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.
Examples
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
Update 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):
- *ai_model: str: The AI model to be used, e.g. "openai", "gemini", "copilot", etc. Currently supporting: "openai"
- name: str: The name of the assistant. This name will show up in responses and in the logs, e.g. "Bob". Max 256 characters
- instructions: str: The instructions given to the assistant. Here you can explain how the assistant should behave, e.g. "You are a software engineer that can debug my code and explain it in a easy to understand manner". Max 256,000 characters
- model: str: AI model specfic. The model of the AI model to be used. E.g. "gpt-3.5-turbo" when using the "openai" AI model. Default depends on AI model:
- "openai" = "gpt-3.5-turbo"
- temperature: float = 1 This value determines the creativity of the AI model. Can be anything from 0-2.
- top_p: float = 1 Similar to temperature. Determines the selection of tokens before selecting one. The higher the value the more less likely tokens get added to the selection. Can be anything from 0-2. At 1, only the top 50% of tokens will be used when selecting a token at 0 all tokens will be taken into consideration
- 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.
Examples
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
Set Temperature 1.8
Set Top P 0.6
Set Response Format { "type": "json_object" }
Update Assistant
Send Message
Sends a prompt to the active assistant and returns its response