From 596733722916786614fe4e50ba33ca5f3bc1eeea Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Sat, 7 Jan 2023 08:41:19 -0500 Subject: [PATCH] Update the test folder and sub-task --- .idea/compiler.xml | 1 + .idea/encodings.xml | 3 + example/pom.xml | 213 ++++++++++++++++++ .../openai/example/OpenAiApiExample.java | 25 ++ openai-j-example/build.gradle | 10 - .../main/java/example/OpenAiApiExample.java | 20 -- pom.xml | 1 + 7 files changed, 243 insertions(+), 30 deletions(-) create mode 100644 example/pom.xml create mode 100644 example/src/main/java/com/ossez/openai/example/OpenAiApiExample.java delete mode 100644 openai-j-example/build.gradle delete mode 100644 openai-j-example/src/main/java/example/OpenAiApiExample.java diff --git a/.idea/compiler.xml b/.idea/compiler.xml index f9c0925..bd1a6c5 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -7,6 +7,7 @@ + diff --git a/.idea/encodings.xml b/.idea/encodings.xml index 4e5a82d..6e603e9 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -7,6 +7,9 @@ + + + diff --git a/example/pom.xml b/example/pom.xml new file mode 100644 index 0000000..51d13f8 --- /dev/null +++ b/example/pom.xml @@ -0,0 +1,213 @@ + + + 4.0.0 + + + com.ossez.openai + openai-j + 0.0.1-SNAPSHOT + + + openai-j-example + jar + + OpenAI J Example + The module that constitutes the main USRealEstate data process system + + + + The MIT license + https://opensource.org/licenses/mit-license.php + repo + + + + + + YuCheng Hu + honeymoose + huyuchengus@gmail.com + -5 + Open Source + + Sr. Java Developer + + + + + + scm:git:git://github.com/USRealEstate/Usreio-Parent.git + scm:git:ssh://git@github.com/USRealEstate/Usreio-Parent.git + https://github.com/USRealEstate + HEAD + + + + JIRA + http://bug.ossez.com/projects/USVisaTrack + + + + 11 + + + + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + + + com.ossez.openai + openai-j-api + 0.0.1-SNAPSHOT + compile + + + + + + org.junit.jupiter + junit-jupiter + 5.9.0 + test + + + org.assertj + assertj-core + 3.23.1 + test + + + + + com.ossez.openai + openai-j-client + 0.0.1-SNAPSHOT + + + + + install + + + ${basedir}/src/main/resources + false + + + ${basedir}/src/filter/resources + true + + + + + + org.apache.maven.plugins + maven-deploy-plugin + 3.0.0 + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.13 + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.8 + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + true + alwaysNew + ${java.version} + ${java.version} + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.4 + + + org.apache.maven.plugins + maven-install-plugin + 2.3.1 + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.3 + + true + + + + org.apache.maven.plugins + maven-jar-plugin + 2.6 + + + org.apache.maven.plugins + maven-war-plugin + 2.6 + + + org.apache.maven.plugins + maven-surefire-plugin + 2.20 + + -noverify + + + ${project.build.directory} + 3600 + true + + false + true + + + + com.cloudbees + maven-license-plugin + 1.7 + + + + process + + compile + + true + + + + + + + org.codehaus.mojo + cobertura-maven-plugin + 2.5.2 + + + + + + + + + + + + diff --git a/example/src/main/java/com/ossez/openai/example/OpenAiApiExample.java b/example/src/main/java/com/ossez/openai/example/OpenAiApiExample.java new file mode 100644 index 0000000..dab2f67 --- /dev/null +++ b/example/src/main/java/com/ossez/openai/example/OpenAiApiExample.java @@ -0,0 +1,25 @@ +package com.ossez.openai.example; + +import com.ossez.openai.OpenAiService; +import com.ossez.openai.completion.CompletionRequest; +import com.ossez.openai.completion.CompletionRequestBuilder; + +/** + * Test Object for ChatGPT OpenAI + */ +public class OpenAiApiExample { + public static void main(String... args) { + String token = "sk-****************************************"; + OpenAiService service = new OpenAiService(token); + + System.out.println("\nCreating completion..."); + CompletionRequest completionRequest = new CompletionRequestBuilder() + .setModel("text-davinci-003") + .setPrompt("长沙机场") + .setMaxTokens(700) + .setEcho(true) + .createCompletionRequest(); + + System.out.println(service.createCompletion(completionRequest).getChoices().get(0).getText()); + } +} diff --git a/openai-j-example/build.gradle b/openai-j-example/build.gradle deleted file mode 100644 index 0719011..0000000 --- a/openai-j-example/build.gradle +++ /dev/null @@ -1,10 +0,0 @@ -apply plugin: 'java' -apply plugin: 'application' - -application { - mainClass.set('example.OpenAiApiExample') -} - -dependencies { - implementation project(":client") -} \ No newline at end of file diff --git a/openai-j-example/src/main/java/example/OpenAiApiExample.java b/openai-j-example/src/main/java/example/OpenAiApiExample.java deleted file mode 100644 index 27b6671..0000000 --- a/openai-j-example/src/main/java/example/OpenAiApiExample.java +++ /dev/null @@ -1,20 +0,0 @@ -package example; - -import com.theokanning.openai.OpenAiService; -import com.theokanning.openai.completion.CompletionRequest; - -class OpenAiApiExample { - public static void main(String... args) { - String token = System.getenv("OPENAI_TOKEN"); - OpenAiService service = new OpenAiService(token); - - System.out.println("\nCreating completion..."); - CompletionRequest completionRequest = CompletionRequest.builder() - .model("ada") - .prompt("Somebody once told me the world is gonna roll me") - .echo(true) - .user("testing") - .build(); - service.createCompletion(completionRequest).getChoices().forEach(System.out::println); - } -} diff --git a/pom.xml b/pom.xml index 0d7aeca..2923b76 100644 --- a/pom.xml +++ b/pom.xml @@ -48,6 +48,7 @@ api client + example