diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0a51551 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Joshua W. (@Tigjaw) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index d9ddc3a..fe99ec2 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,9 @@ * Create API key at https://beta.openai.com/account/api-keys * Store the key in application.properties file in cloned project. * Start it as Spring Boot application. -* For chatting with ChatGPT: http://localhost:8080/ -* For drawing images with DALL-E: http://localhost:8080/image +* Browser opens index.html automatically, hosted at: + * http://localhost:8080/ (for chatting with ChatGPT) + * http://localhost:8080/image (for drawing images with DALL-E) ## Setup proxy If you need a proxy to communicate with Internet (ChatGPT API is in Internet), adapt ChatGptController.java like this: diff --git a/src/main/java/de/bsi/openai/BrowserLauncher.java b/src/main/java/de/bsi/openai/BrowserLauncher.java new file mode 100644 index 0000000..c09ec70 --- /dev/null +++ b/src/main/java/de/bsi/openai/BrowserLauncher.java @@ -0,0 +1,27 @@ +package de.bsi.openai; + +import java.awt.Desktop; +import java.net.URI; + +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.event.EventListener; +import org.springframework.stereotype.Component; + +@Component +public class BrowserLauncher { + + @EventListener(ApplicationReadyEvent.class) + public void launchBrowser() { + + System.setProperty("java.awt.headless", "false"); + + Desktop desktop = Desktop.getDesktop(); + + try { + desktop.browse(new URI("http://localhost:8080")); + } catch (Exception e) { + } + + } + +} \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index c158d9e..30e8b1f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1 +1 @@ -openai.api_key=Generate this at openai.com +openai.api_key=Generate this at openai.com \ No newline at end of file diff --git a/src/main/resources/templates/image.html b/src/main/resources/templates/image.html index 0544cb5..e509b49 100644 --- a/src/main/resources/templates/image.html +++ b/src/main/resources/templates/image.html @@ -1,28 +1,36 @@
- - -