diff --git a/pom.xml b/pom.xml
index 9e0ba0f..9d7f2b5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -70,6 +70,24 @@
3.2.0
+
+
+
+ com.theokanning.openai-gpt3-java
+ api
+ 0.12.0
+
+
+ com.theokanning.openai-gpt3-java
+ client
+ 0.12.0
+
+
+ com.theokanning.openai-gpt3-java
+ service
+ 0.12.0
+
+
@@ -112,4 +130,28 @@
+
+
+
+
+
+
+
+
+ com.fasterxml.jackson.core
+ jackson-annotations
+ 2.10.1
+
+
+
+
+
+ org.reactivestreams
+ reactive-streams
+ 1.0.0
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/info/istlab/Zemi01/chatgpt/OpenAiApiExample.java b/src/main/java/info/istlab/Zemi01/chatgpt/OpenAiApiExample.java
new file mode 100644
index 0000000..5821e7f
--- /dev/null
+++ b/src/main/java/info/istlab/Zemi01/chatgpt/OpenAiApiExample.java
@@ -0,0 +1,56 @@
+package info.istlab.Zemi01.chatgpt;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import com.theokanning.openai.completion.chat.ChatCompletionRequest;
+import com.theokanning.openai.completion.chat.ChatMessage;
+import com.theokanning.openai.completion.chat.ChatMessageRole;
+import com.theokanning.openai.service.OpenAiService;
+
+class OpenAiApiExample {
+ public static void main(String... args) {
+ String token = System.getenv("OPENAI_TOKEN"); //環境変数で設定
+ // System.out.println(token);
+ // System.exit(0);
+ com.theokanning.openai.service.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")
+ // .n(3)
+ // .build();
+ // service.createCompletion(completionRequest).getChoices().forEach(System.out::println);
+
+ // System.out.println("\nCreating Image...");
+ // CreateImageRequest request = CreateImageRequest.builder()
+ // .prompt("A cow breakdancing with a turtle")
+ // .build();
+
+ // System.out.println("\nImage is located at:");
+ // System.out.println(service.createImage(request).getData().get(0).getUrl());
+
+ System.out.println("Streaming chat completion...");
+ final List messages = new ArrayList<>();
+ final ChatMessage userMessage = new ChatMessage(ChatMessageRole.USER.value(), "創造的な活動をするには、普段どんなことに注意したらよいでしょうか?");
+ messages.add(userMessage);
+ ChatCompletionRequest chatCompletionRequest = ChatCompletionRequest
+ .builder()
+ .model("gpt-3.5-turbo")
+ .messages(messages)
+ .n(1)
+ .maxTokens(150)
+ .logitBias(new HashMap<>())
+ .build();
+
+ service.streamChatCompletion(chatCompletionRequest)
+ .doOnError(Throwable::printStackTrace)
+ .blockingForEach(System.out::println);
+
+ service.shutdownExecutor();
+ }
+}
\ No newline at end of file