Connect open Java to open AI
Create maven project: mvn archetype:generate -DgroupId=com.openai.test -DartifactId=openAIBanking -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false; Apps.java package com . openai . test ; public class App { public static void main ( String [] args ) { Connection connection = new Connection (); connection . connect (); } } Connection.java package com . openai . test ; import java . io . OutputStream ; import java . net . HttpURLConnection ; import java . net . URL ; import java . util . Scanner ; import org . json . JSONObject ; import org . json . JSONArray ; public class Connection { public void connect () { try { System . out . println ( "testing" ); // 1. Set the endpoint URL for ChatGPT (gpt-3.5 or gpt-4) URL url = new URL ( "https://api.openai.com/v1/chat/completions" ); // 2. Open HTTP connection ...