Usage
The OpenAI Roblox module library is a collection of commands that allow you to easily incorporate natural language processing and machine learning capabilities into your Roblox projects. These commands can be used to build interactive chatbots, language translation tools, and other applications that use artificial intelligence to enhance the user experience.
To use the OpenAI Roblox module library, you will need to install the module and require it in your script. From there, you can call the various commands available in the library to perform tasks such as generating responses to user input, classifying text, or translating between languages.
_______________________________________________________________________________________________________
setApiKey()
The OpenAI.setApiKey(apiKey)
command is used to set the API key for the OpenAI Roblox module library. The API key is a unique string that authenticates your access to the OpenAI API and allows you to use its various features and capabilities.
To use the OpenAI.setApiKey(apiKey)
command, you need to pass it a string value containing your API key. This key can be obtained by creating an account on the OpenAI website and obtaining a key from your account settings.
Here is an example of how to use the OpenAI.setApiKey(apiKey)
command in a script:
This code will set the API key for the OpenAI Roblox module library to the value specified in the apiKey
parameter. Once the API key is set, you can use the other commands in the library to perform tasks such as generating responses to user input, classifying text, or translating between languages.
It is important to note that the OpenAI.setApiKey(apiKey)
command should be called before any other commands in the library are used. This will ensure that the library has a valid API key and can perform its functions correctly.
_______________________________________________________________________________________________________
getModels()
The OpenAI.getModels()
command is used to retrieve a list of available models from the OpenAI API. A model is a machine learning algorithm that has been trained on a large dataset and can be used to perform various tasks such as generating text, classifying content, or making predictions.
To use the OpenAI.getModels()
command, you simply need to call it in your script. It does not take any arguments and does not require any setup or configuration.
Here is an example of how to use the OpenAI.getModels()
command in a script:
This code will retrieve a list of available models from the OpenAI API and store it in the models
variable. The list will include the name and other information about each model, such as its description and the tasks it is capable of performing.
The OpenAI.getModels()
command can be useful if you want to browse the available models and choose one that is suitable for your needs. It can also be used to get an overview of the capabilities of the OpenAI API and what types of tasks it is capable of performing.
_______________________________________________________________________________________________________
generateText()
It's possible that the text generated by the OpenAI model may not always be coherent or make sense, especially if the temperature parameter is set to a high value. The temperature parameter controls the randomness of the generated text, with higher values resulting in more randomness and lower values resulting in more predictability.
Additionally, the quality and coherence of the generated text may depend on the specific OpenAI model being used. Different models have been trained on different data sets and may have different capabilities and characteristics. It might be helpful to experiment with using different models to see which one produces the best results for your specific use case.
It's also important to note that the OpenAI API is a machine learning model, and like all machine learning models, it can make mistakes or produce unexpected results. It's always a good idea to carefully review the generated text to ensure that it meets your expectations and is suitable for your needs.
The OpenAI.generateText(model, prompt, temperature, maxTokens)
command is used to generate text using a specific machine learning model from the OpenAI API. The generated text is based on the prompt provided and can be customized using the optional temperature and maxTokens parameters.
To use the OpenAI.generateText(model, prompt, temperature, maxTokens)
command, you need to specify the name of the model you want to use, as well as the prompt from which the generated text should be based. The prompt should be a string containing the text you want the model to use as a starting point for generating the output.
You can also specify the temperature and maxTokens parameters to customize the generated text. The temperature parameter controls the randomness of the generated text, with higher values resulting in more random output and lower values resulting in more predictable output. The maxTokens parameter controls the maximum length of the generated text, with higher values resulting in longer output and lower values resulting in shorter output.
Here is an example of how to use the OpenAI.generateText(model, prompt, temperature, maxTokens)
command in a script:
The OpenAI.generateText(model, prompt, temperature, maxTokens)
command is used to generate text using a specific machine learning model from the OpenAI API. It takes four parameters:
model: The name of the OpenAI model to use for text generation. The model determines the style and content of the generated text.
prompt: The text prompt to use as input for the text generation process. The prompt can be a single sentence or a longer passage of text.
temperature (optional): Controls the "creativity" of the generated text. A higher temperature results in more creative and varied text, but can also result in lower quality text and longer generation times. A lower temperature results in more deterministic and accurate text, but can also result in less creative and varied text. The temperature should be set to a value between 0 and 1, with 0 being the most deterministic and 1 being the most creative. The default value is 0.5.
maxTokens (optional): Controls the maximum number of tokens (i.e., words and punctuation) that can be generated in the response. Increasing the value of maxTokens will result in longer responses, but may also result in longer generation times. The default value is 256.
maxTokens can sometimes cause too long response. For an example, if you'd simply just say hi to the AI, it'll respond with a whole story. It's recommended to use maxTokens when you really need to.
_______________________________________________________________________________________________________
models
The OpenAI.models
variable is a table containing the names of several machine learning models that are available for use with the OpenAI Roblox module library. The models are represented by string values that correspond to their unique identifier within the OpenAI API.
The OpenAI.models
table currently includes four models:
davinci: The "text-davinci-002" model, which is a large-scale transformer model trained on a diverse range of texts and is capable of generating high-quality text in a variety of styles and formats.
curie: The "text-curie-001" model, which is a smaller transformer model trained on a more limited dataset and is suitable for tasks that require less compute.
babbage: The "text-babbage-001" model, which is a small transformer model trained on a limited dataset and is suitable for tasks that require minimal compute.
ada: The "text-ada-001" model, which is a small transformer model trained on a limited dataset and is suitable for tasks that require minimal compute.
To use one of these models in your script, you can simply reference its string value from the OpenAI.models
table. For example, to use the "text-davinci-002" model, you can do the following:
This code will use the OpenAI.generateText()
command to generate a string of text using the "text-davinci-002" model and the provided prompt. The generated text will be based on the prompt and the characteristics of the "text-davinci-002" model.
The OpenAI.models
table is provided as a convenience to allow you to easily reference the available models in your scripts. You can also use the OpenAI.getModels()
command to retrieve a list of available models from the OpenAI API if you want to browse the full range of options.
Last updated