Update the test folder and sub-task
This commit is contained in:
parent
09aa7fdeb6
commit
5967337229
1
.idea/compiler.xml
generated
1
.idea/compiler.xml
generated
@ -7,6 +7,7 @@
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="openai-j-api" />
|
||||
<module name="openai-j-example" />
|
||||
<module name="openai-j-client" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
|
3
.idea/encodings.xml
generated
3
.idea/encodings.xml
generated
@ -7,6 +7,9 @@
|
||||
<file url="file://$PROJECT_DIR$/client/src/filter/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/client/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/client/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/example/src/filter/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/example/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/example/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/openai-j-api/src/filter/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/openai-j-api/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/openai-j-api/src/main/resources" charset="UTF-8" />
|
||||
|
213
example/pom.xml
Normal file
213
example/pom.xml
Normal file
@ -0,0 +1,213 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.ossez.openai</groupId>
|
||||
<artifactId>openai-j</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>openai-j-example</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>OpenAI J Example</name>
|
||||
<description>The module that constitutes the main USRealEstate data process system</description>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The MIT license</name>
|
||||
<url>https://opensource.org/licenses/mit-license.php</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>YuCheng Hu</name>
|
||||
<id>honeymoose</id>
|
||||
<email>huyuchengus@gmail.com</email>
|
||||
<timezone>-5</timezone>
|
||||
<organization>Open Source</organization>
|
||||
<roles>
|
||||
<role>Sr. Java Developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/USRealEstate/Usreio-Parent.git</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/USRealEstate/Usreio-Parent.git</developerConnection>
|
||||
<url>https://github.com/USRealEstate</url>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
<issueManagement>
|
||||
<system>JIRA</system>
|
||||
<url>http://bug.ossez.com/projects/USVisaTrack</url>
|
||||
</issueManagement>
|
||||
|
||||
<properties>
|
||||
<java.level>11</java.level>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- LOGGING WITH SELF4J AND LOG4J2 -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- UTILS -->
|
||||
<dependency>
|
||||
<groupId>com.ossez.openai</groupId>
|
||||
<artifactId>openai-j-api</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- / UTILS -->
|
||||
|
||||
<!-- TEST -->
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>5.9.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>3.23.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!--/ TEST -->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ossez.openai</groupId>
|
||||
<artifactId>openai-j-client</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${basedir}/src/main/resources</directory>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>${basedir}/src/filter/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.13</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>2.8</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<fork>true</fork>
|
||||
<compilerReuseStrategy>alwaysNew</compilerReuseStrategy>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>1.4</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<version>2.3.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.3</version>
|
||||
<configuration>
|
||||
<quiet>true</quiet>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.20</version>
|
||||
<configuration>
|
||||
<argLine>-noverify
|
||||
</argLine> <!-- some versions of JDK7/8 causes VerifyError during mock tests: http://code.google.com/p/powermock/issues/detail?id=504 -->
|
||||
<systemPropertyVariables>
|
||||
<java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
|
||||
<forkedProcessTimeoutInSeconds>3600</forkedProcessTimeoutInSeconds>
|
||||
<java.awt.headless>true</java.awt.headless>
|
||||
</systemPropertyVariables>
|
||||
<trimStackTrace>false</trimStackTrace>
|
||||
<skipTests>true</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.cloudbees</groupId>
|
||||
<artifactId>maven-license-plugin</artifactId>
|
||||
<version>1.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>process</goal>
|
||||
</goals>
|
||||
<phase>compile</phase>
|
||||
<configuration>
|
||||
<requireCompleteLicenseInfo>true</requireCompleteLicenseInfo>
|
||||
<script>../licenseCompleter.groovy</script>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>cobertura-maven-plugin</artifactId>
|
||||
<version>2.5.2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
|
||||
<plugins></plugins>
|
||||
|
||||
<extensions></extensions>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
</profiles>
|
||||
</project>
|
@ -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());
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'application'
|
||||
|
||||
application {
|
||||
mainClass.set('example.OpenAiApiExample')
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(":client")
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user