Package com.anlavn.openai
Class ChatGPT
java.lang.Object
com.anlavn.openai.ChatGPT
The ChatGPT class supports to connect to OpenAI using API key.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumOur GPT-3 models can understand and generate natural language. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal StringUse this method to chat with ChatGPT bot, just ask the question and you will get reply from chatGPT bot.
Using model Davinci with max 256 token.final StringUse this method to chat with ChatGPT bot, just ask the question, enter the max token will return and you will get reply from chatGPT bot.
Using model Davinci.final StringChat(String question, ChatGPT.Model model) Use this method to chat with ChatGPT bot, just ask the question, required the model will answer you and you will get reply from chatGPT bot.
Using max 256 token.final StringChat(String question, ChatGPT.Model model, int maxTokens) Use this method to chat with ChatGPT bot, just ask the question, required the model will answer you, enter the max token will return and you will get reply from chatGPT bot.
-
Constructor Details
-
ChatGPT
Create an ChatGPT service using API key. API key is a mandatory requirement. It has format "sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX".
Login to OpenAI website with your account and access to https://beta.openai.com/account/api-keys to get API key.- Parameters:
APIKey- is your API key in OpenAI.
-
-
Method Details
-
Chat
Use this method to chat with ChatGPT bot, just ask the question and you will get reply from chatGPT bot.
Using model Davinci with max 256 token.- Parameters:
question- a string of any question you wonder. The longer the question, the more tokens it costs.- Returns:
- a string choices of model with your question.
- See Also:
-
Chat
Use this method to chat with ChatGPT bot, just ask the question, enter the max token will return and you will get reply from chatGPT bot.
Using model Davinci.- Parameters:
question- a string of any question you wonder. The longer the question, the more tokens it costs.maxTokens- is the maximum token limit will return. Other models only have 2048 while Davinci is 4000.- Returns:
- a string choices of model with your question.
- See Also:
-
Chat
Use this method to chat with ChatGPT bot, just ask the question, required the model will answer you and you will get reply from chatGPT bot.
Using max 256 token.- Parameters:
question- a string of any question you wonder. The longer the question, the more tokens it costs.model- is a model will answer your question. Ada is the fastest model, while Davinci is the most powerful.- Returns:
- a string choices of model with your question.
- See Also:
-
Chat
Use this method to chat with ChatGPT bot, just ask the question, required the model will answer you, enter the max token will return and you will get reply from chatGPT bot.- Parameters:
question- a string of any question you wonder. The longer the question, the more tokens it costs.model- is a model will answer your question. Ada is the fastest model, while Davinci is the most powerful.maxTokens- is the maximum token limit will return. Other models only have 2048 while Davinci is 4000.- Returns:
- a string that the model choices to answer your question.
-