Skip to content

GPT4 example

Ahmad Albarqawi edited this page Apr 16, 2023 · 1 revision

Use ChatGPT to access GPT4:
If you have access to GPT4 in your Openai account, you can use it as part of the chatGPT as follow:

// 1- initiate the chat model.
Chatbot bot = new Chatbot(apiKey, SupportedChatModels.openai);

// 2- prepare the chat history by calling addMessage.
String mode = "You are a helpful astronomy assistant.";
String ask = "Write a blog post introducing ChatGPT and its capabilities in marketing content.";
ChatModelInput input = new ChatGPTInput.Builder(mode).setModel("GPT-4").setMaxTokens(600).addUserMessage(ask).build();

// 3- call chat!
List<String> resValues =  bot.chat(input);

Output Example:
In today's fast-paced digital landscape, businesses need cutting-edge tools to stay ahead of the game. As a marketer, you've already dipped into the world of artificial intelligence (AI) for analyzing data, personalizing content, and automating social media management. But what if there was a tool that could help you create high-quality marketing content at scale and in less time? Allow us to introduce ChatGPT, an AI-based language model developed by OpenAI, designed to level up your marketing content creation game.....

Speed notes:

  • Note that gpt-3.5-turbo is much faster in response time than gpt4.
  • You can use gpt4 in cases with extensive text generation where the speed is not a priority.
Clone this wiki locally