Package com.intellijava.core.wrappers
Class OpenAIWrapper
java.lang.Object
com.intellijava.core.wrappers.OpenAIWrapper
- All Implemented Interfaces:
ImageModelInterface
,LanguageModelInterface
OpenAIWrapper is a wrapper for the OpenAI API, providing a simplified interface for interacting with the API.
- Author:
- github.com/Barqawiz
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongenerateChatText
(Map<String, Object> params) Generate text from remote large language model based on the chat history.generateImages
(Map<String, Object> params) Generate image from openai image model.generateText
(Map<String, Object> params) Generate text from remote large language model based on the received prompt.
-
Constructor Details
-
OpenAIWrapper
OpenAIWrapper constructor with the API key- Parameters:
apiKey
- openai API key, generate if from your account.
-
-
Method Details
-
generateText
Generate text from remote large language model based on the received prompt.- Specified by:
generateText
in interfaceLanguageModelInterface
- Parameters:
params
- key and value for the API parameters model the model name, example: text-davinci-002. prompt text of the required action or the question. temperature higher values means more risks and creativity. maxTokens maximum size of the model input and output. For more GPT3 models: https://beta.openai.com/docs/models/gpt-3- Returns:
- BaseRemoteModel for model response
- Throws:
IOException
- if there is an error when connecting to the OpenAI API.
-
generateChatText
Generate text from remote large language model based on the chat history.- Parameters:
params
- key and value for the API parameters model the model name, example: gpt-3.5-turbo. messages a dictionary of role and prompt. temperature higher values means more risks and creativity. maxTokens maximum size of the model input and output. For more GPT3 models: https://beta.openai.com/docs/models/gpt-3- Returns:
- BaseRemoteModel for model response
- Throws:
IOException
- if there is an error when connecting to the OpenAI API.
-
generateImages
Generate image from openai image model.- Specified by:
generateImages
in interfaceImageModelInterface
- Parameters:
params
- should include prompt, n, size prompt: text of the required action or the question. n: number of the generated images. size: 256x256, 512x512, or 1024x1024.- Returns:
- BaseRemoteModel
- Throws:
IOException
- if there is an error when connecting to the OpenAI API.
-