Skip to content

Open AI

Category: Cognitive

Description: Advanced functionality for integration with AI APIs, allowing for free conversational features and training based on corpora provided by the tool, including classifiers.

Functionality: It can be applied to various functions available in the OpenAI example library. Its main action is as an interface or connector with the cognitive manager API, with some possibilities including: translations, classifiers, sentiment analysis of phrases, sarcasm generator, QnA (Questions and Answers) generators, list generators, keyword analysis, text-to-emoji translator, third-person voice interpreters, interview or survey questionnaires.

Note πŸ“‘: For chat-oriented implementations, you can use the dedicated Chat OPENAI action from the Lynn Designer action library, which can facilitate the experience.

Prerequisites

  1. Create an account on OpenAI:

    • If you do not have an account, go to the OpenAI website and sign up. If you already have an account, simply log in.
  2. Access the Dashboard:

    • Once logged in, go to your OpenAI dashboard.
    • In the dashboard, look for the "API" or "API Keys" section. This may vary depending on user interface updates, but it is generally found in the main menu or a sub-menu related to account management or settings.
  3. Generate a new API Key:

    • Click the button to generate a new API Key. It may be labeled as "Create API Key," "Generate New Key," "New API Key," or something similar.
    • Follow the on-screen instructions to name and generate the key. You may be asked to verify your account or accept certain terms of use.

Note: Once generated, the API Key will be displayed on the screen. Copy it and save it in a safe place, as this key is necessary to authenticate your requests to the OpenAI API. Be aware that, for security reasons, you may not be able to see the complete key again after leaving the generation screen. If you lose it, you will need to generate a new one.

Implementation

Expression that defines the training corpus: Field where you must enter an expression that defines the behavior for the OpenAI chat, supporting the Human/AI format.

Note πŸ“‘: It is important to frame simpler corpora in backticks (`).

Model: String-type expression where the model to be used for text validation should be indicated. There are models with different levels of capabilities:

MODEL DESCRIPTION
gpt-3.5-turbo-instruct Capabilities similar to GPT-3 era models. Compatible with legacy completion endpoints and not with chat completions.
text-embedding-ada-002 The most capable second-generation integration model, replacing 16 first-generation models.
text-moderation-007 The most capable moderation model across all categories.

Note πŸ“‘: Check available models HERE.

Temperature: Float-type field that controls the creativity of the model's responses. A high value (like 0.9) generates more creative responses, while a low value (like 0) produces more precise and defined responses.

Top_P: Controls the diversity of the model's responses. A high value (close to 1) allows for greater diversity by considering more possible options. A low value (close to 0) limits the options to the most probable ones, resulting in more coherent and less creative responses.

Max_Tokens: Determines the maximum length of the response generated by the model, measured in tokens. A high value allows for longer and more detailed responses, while a low value restricts the length to shorter and more concise responses.

Stop: Defines a text string that will stop the response process of the OpenAI engine.

Authorization: To use OpenAI APIs, you need an API Key. This key acts as an identifier and authenticator for your requests. You can obtain your API Key in the OpenAI dashboard and use it in your code to access the service's functions.

Entity where the evaluation result will be deposited: Dropdown list field that allows you to select the entity where the OpenAI evaluation result will be saved.

If the maximum number of failed attempts is reached, the action flow will be interrupted and the error description will be passed to the selected intent with the name: 'OpenAi_Error': Dropdown list where the name of the intent for error handling must be selected.

Implementation Example

Field Value
Name: PruebaOpenAi
Expression that defines the training corpus: CURRENT_EVALUATION == "" ? 'tell the client to write a question': CURRENT_EVALUATION
MODEL: 'gpt-3.5-turbo-instruct'
TEMPERATURE: 0.8
TOP_PΒ : 0
MAX_TOKENS: 150
STOP: '[" Human:", " AI:"]'
Authorization: AXX2XkXmXXXXX
Entity where the evaluation result will be deposited: entityTest
If the maximum number of failed attempts is reached, the action flow will be interrupted and the error description will be passed to the selected intent with the name: 'OpenAi_Error': Error_Handler

Input:

Client writes: what are the GPT chat models?

CURRENT_EVALUATION <-- β€˜what are the GPT chat models?’

Output:

OPENAI <--

  1. GPT-1: The first GPT chat model released by OpenAI in 2018. It had 117 million parameters and was trained on a wide range of language tasks.

  2. GPT-2: Released in 2019, GPT-2 had 1.5 billion parameters and was trained on a large amount of internet data. It is considered one of the most advanced GPT chat models to date.

  3. GPT-3: Released in 2020, GPT-3 is the largest GPT chat model to date, with 175 billion parameters and has significantly advanced capabilities for language understanding and generation.