OpenAI
Last updated
Last updated
OpenAI's GPT engine is a powerful language model that you can integrate into your chatbot to enhance the chatbot's conversational abilities and experience for your end users. This guide walks you through integrating OpenAI into your BotDistrikt chatbot.
To integrate OpenAI into your BotDistrikt chatbot:
Ensure you have Created an active Access Token on Personality -> Settings
Go to Integrations --> Artificial Intelligence --> OpenAI
Enter a valid API key* and click Save
Navigate to Trainings to train the OpenAI model
Select the available chat model from the dropdown.
Choose the appropriate temperature according to your chatbot's personality. Increased temperature indicates more random responses to the prompts. Decreased temperature ensures more stable and predictable responses.
Maximum tokens to generate indicates your chatbot's response length. Requests use up to 2048 to 4000 tokens (shared between prompt and completion). Your limit varies by the model you choose in 1. A token (approximately) equals 4 characters in plain English).
Top P indicates the normalcy of words within a response. A higher number indicates using more normal words and less includes the inclusion of more unique words in your chatbot's responses. The diversity is controlled through a nucleus sampling of 0.5 (consideration of half of all likelihood-weighted options).
Adjust the Frequency Penalty to control how often your chatbot repeats the same words. High-frequency penalty for less repetition and low-frequency penalty for more repetition.
Adjust the Presence Penalty to control how much your chatbot focuses on specific topics. Set a high presence penalty for more variety in responses and a low presence penalty for more focus on a topic.
Set the Max Conversation Tokens to indicate the maximum number of tokens to keep in the chatbot's conversation history. As the conversation history grows, the oldest messages are removed (if tokens exceed the specified number).
Toggle Generate Embeddings for Text Responses to retrieve the results of a similarity search of text responses (from the websites and documents in Sources) and the users' input message.
Toggle Generate Embeddings for Cards to retrieve the results of a similarity search of cards (from the cards tab in Responses and the users' input message.
Select the Embedding Model between the website and document sources. The model represents words or phrases as numerical vectors in a continuous vector space, allowing computers to process and understand textual data more effectively.
Adjust the Embedding Dimensions to control the length of the embeddings to store and query for similarity searches.
To optimize responses from the document or web resources, enter a number in Embedding Top K. This feature presents the top K most semantically related entries or documents, enabling the RAG model to use these documents as reference to generate more informed, accurate, and relevant responses to the given input.
Toggle Score RAGAS Metrics to observe RAGAS scores for generated RAG completions.
Enter an Intro Prompt to provide context, instructions, or other information relevant to the model and use case. The prompt can determine the character, behaviour, disposition and function of the chatbot. To write effective prompts, describe the task you want it to complete and provide background information. Give the model some examples of the desired output. Also note that the order of presenting information matters.
Import a Story
The number of tokens used is displayed in the bottom right corner of the Intro Prompt box. Tokens are units of text that these models process and generate which the model can turn into embeddings. Example: "I am a chatbot" utilizes 5 tokens.
Click Save.
To test your bot, navigate to Testing and test your bot accordingly.
*To generate a valid OpenAI API key:
Create an OpenAI account
Log in to your OpenAI account via API login
Click on API
In the left sidebar, select API Keys
Click on + Create new secret key button
Name your API key (for reference)
Choose an appropriate project
Set the level of permission required
Click Create secret key
In the popup, copy the secret key generated
Enter in BotDistrikt Integrations --> Artificial Intelligence --> OpenAI --> API key