Authorize To Openai

Keyword for authorize to OpenAI with your API key obtained from your account.

Arguments

Argument Type Default value Description
api_keystrnullYour OpenAI API key
param api_key:Your OpenAI API key

Robot Framework example:

${secrets}   Get Secret   secret_name=OpenAI
Authorize To OpenAI   api_key=${secrets}[key]

Python example:

secrets = Vault().get_secret("OpenAI")
baselib = OpenAI()
baselib.authorize_to_openai(secrets["key"])

Chat Completion Create

Keyword for creating ChatGPT text completions in OpenAI. Keyword returns a list containing the response as a string and the message history as a list.

Arguments

Argument Type Default value Description
user_contentstr, NoneNoneText submitted to ChatGPT to generate completions.
conversationList, NoneNoneList containing the conversation to be continued. Leave empty for a new conversation.
modelstr, Nonegpt-3.5-turboID of the model to use. Currently, only gpt-3.5-turbo and gpt-3.5-turbo-0301 are supported.
system_contentstr, NoneNoneThe system message helps set the behavior of the assistant.
temperatureint, None1What sampling temperature to use between 0 to 2. Higher values means the model will take more risks.
top_probabilityint, None1An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass.
frequency_penaltyint, None0Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far.
presence_penaltyint, None0Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far.
param user_content:
 Text submitted to ChatGPT to generate completions.
param conversation:
 List containing the conversation to be continued. Leave empty for a new conversation.
param model:ID of the model to use. Currently, only gpt-3.5-turbo and gpt-3.5-turbo-0301 are supported.
param system_content:
 The system message helps set the behavior of the assistant.
param temperature:
 What sampling temperature to use between 0 to 2. Higher values means the model will take more risks.
param top_probability:
 An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass.
param frequency_penalty:
 Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far.
param presence_penalty:
 Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far.

Robot Framework example:

# Create a new conversation without conversation history.
${response}   @{chatgpt_conversation}=     Chat Completion Create
...    user_content=What is the biggest mammal?
Log    ${response}

# Continue the conversation by using the "conversation" argument.
${response}   @{chatgpt_conversation}=     Chat Completion Create
...    conversation=${chatgpt_conversation}
...    user_content=How old can it live?
Log    ${response}

Completion Create

Keyword for creating text completions in OpenAI. Keyword returns a text string.

Arguments

Argument Type Default value Description
promptstrnullText submitted to OpenAI for creating natural language.
modelstr, Nonetext-davinci-003OpenAI's model to use in the completion.
temperatureint, None0.7What sampling temperature to use. Higher values means the model will take more risks..
max_tokensint, None256The maximum number of tokens to generate in the completion..
top_probabilityint, None1Controls diversity via nucleus sampling. 0.5 means half of all likelihood-weighted options are considered.
frequency_penaltyint, None0Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far.
presence_penaltyint, None0Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far.
result_formatstr, NonestringResult format (string / json). Return just a string or the default JSON response.
param prompt:Text submitted to OpenAI for creating natural language.
param model:OpenAI's model to use in the completion.
param temperature:
 What sampling temperature to use. Higher values means the model will take more risks..
param max_tokens:
 The maximum number of tokens to generate in the completion..
param top_probability:
 Controls diversity via nucleus sampling. 0.5 means half of all likelihood-weighted options are considered.
param frequency_penalty:
 Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far.
param presence_penalty:
 Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far.
param result_format:
 Result format (string / json). Return just a string or the default JSON response.

Robot Framework example:

${response}  Completion Create
...     Write a tagline for an icecream shop.
...     temperature=0.6
Log     ${response}

Python example:

result = baselib.completion_create(
    'Create a tagline for icecream shop',
    temperature=0.6,
)
print(result)

Image Create

Keyword for creating one or more images in OpenAI. Keyword returns a list of urls for the images created.

Arguments

Argument Type Default value Description
promptstrnullA text description of the desired image(s). The maximum length is 1000 characters.
sizestr, None512x512Size of the files to be created. 256x256, 512x512, 1024x1024
num_imagesint, None1The number of images to generate. Must be between 1 and 10.
result_formatstr, NonelistResult format (list / json).
param prompt:A text description of the desired image(s). The maximum length is 1000 characters.
param size:Size of the files to be created. 256x256, 512x512, 1024x1024
param num_images:
 The number of images to generate. Must be between 1 and 10.
param result_format:
 Result format (list / json).

Robot Framework example:

${images}    Image Create
...   Cartoon style picture of a cute monkey skateboarding.
...   size=256x256
...   num_images=2
FOR    ${url}    IN    @{images}
    Log    ${url}
END

Python example:

images = baselib.image_create(
    'Cartoon style picture of a cute monkey skateboarding',
    size='256x256',
    num_images=2,
)
for url in images:
    print(url)

Image Create Variation

Keyword for creating one or more variations of a image. Keyword returns a list of urls for the images created. Source file must be a valid PNG file, less than 4MB, and square.

Arguments

Argument Type Default value Description
src_imagestrnullThe image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.
sizestr, None512x512The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024.
num_imagesint, None1The number of images to generate. Must be between 1 and 10
result_formatstr, NonelistResult format (list / json).
param src_image:
 The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.
param size:The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024.
param num_images:
 The number of images to generate. Must be between 1 and 10
param result_format:
 Result format (list / json).

Robot Framework example:

${variations}   Image Create Variation
...     source_image.png
...     size=256x256
...     num_images=2
FOR    ${url}    IN    @{variations}
    Log    ${url}
END

Python example:

variations = baselib.image_create_variation(
    'source_image.png',
    size='256x256',
    num_images=2,
)
for url in variations:
    print(url)