Intelligent Java: A Gateway to the Latest AI Models

Leveraging ChatGPT, DALL·E, and WaveNet to Build a Climate Awareness App with Java

The Library Pillars

Intelligent Java Pillars visual— image by the author

Using Intelligent Java

<!-- maven -->
<dependency>
<groupId>io.github.barqawiz</groupId>
<artifactId>intellijava.core</artifactId>
<version>0.8.0</version>
</dependency>
implementation 'io.github.barqawiz:intellijava.core:0.8.0'

Let’s build an application for dynamic climate change museum using Intelligent Java

Imagination of climate change futuristic museum —image by Midjourney model

Application planning and coding

// get the API key from https://openai.com/api
RemoteLanguageModel model = new RemoteLanguageModel(apiKey, "openai");

LanguageModelInput input = new LanguageModelInput
.Builder("Write about climate change effect on earth if the pollution continue")
.setMaxTokens(250).setModel("text-davinci-003").setTemperature(0.5f).build();

String generatedText = model.generateText(input);
.setTemperature(0.5f)
// generate api key from console.cloud.google.com and enable the text-to-speech api
RemoteSpeechModel model = new RemoteSpeechModel(apiKey, SpeechModels.google);
Text2SpeechInput input = new Text2SpeechInput(generatedText, Gender.FEMALE);

byte[] decodedAudio = model.generateEnglishText(input);
audio description for climate change impact — generate by gpt3 language model and google speech model
String imageText = "oil panting for a city with rise in sea levels and extreme weather events";
RemoteImageModel model = new RemoteImageModel(apiKey, "openai");

// support image sizes: 256x256, 512x512, or 1024x1024
ImageModelInput input = new ImageModelInput.Builder(imageText)
.setNumberOfImages(4).setImageSize("512x512").build();

// output is list or URLs
List<String> images = model.generateImages(input);
oil panting for a city with rise in sea levels and extreme weather events — generate by Intelligent Java

References

--

--

Solution designer and a master’s data science scholar at Illinois Urbana-Champaign. ahmadai.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Albarqawi

Solution designer and a master’s data science scholar at Illinois Urbana-Champaign. ahmadai.com