diff options
author | bjormel <bjormel@yahooinc.com> | 2023-10-26 13:59:28 +0000 |
---|---|---|
committer | bjormel <bjormel@yahooinc.com> | 2023-10-26 13:59:28 +0000 |
commit | 567be9a1f6353cec41c23bfd1fcd46b4b2a4d2d7 (patch) | |
tree | 4664a743e166a5e11aee7b9acd70ad8ee2617612 /vespajlib/src/test/java/ai/vespa/llm/client/openai/OpenAiClientCompletionTest.java | |
parent | e9058b555d4dfea2f6c872d9a677e8678b569569 (diff) | |
parent | bce3b8e926bf9da880172acbe1ba4b12d5e026d6 (diff) |
Merge branch 'master' into bjormel/aws-main-controllerbjormel/aws-main-controller
Diffstat (limited to 'vespajlib/src/test/java/ai/vespa/llm/client/openai/OpenAiClientCompletionTest.java')
-rw-r--r-- | vespajlib/src/test/java/ai/vespa/llm/client/openai/OpenAiClientCompletionTest.java | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/vespajlib/src/test/java/ai/vespa/llm/client/openai/OpenAiClientCompletionTest.java b/vespajlib/src/test/java/ai/vespa/llm/client/openai/OpenAiClientCompletionTest.java index 961a02afea3..45ef7e270aa 100644 --- a/vespajlib/src/test/java/ai/vespa/llm/client/openai/OpenAiClientCompletionTest.java +++ b/vespajlib/src/test/java/ai/vespa/llm/client/openai/OpenAiClientCompletionTest.java @@ -1,3 +1,4 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package ai.vespa.llm.client.openai; import ai.vespa.llm.completion.Completion; @@ -10,12 +11,14 @@ import org.junit.jupiter.api.Test; */ public class OpenAiClientCompletionTest { + private static final String apiKey = "your-api-key-here"; + @Test @Disabled public void testClient() { - var client = new OpenAiClient.Builder("your token here").build(); + var client = new OpenAiClient.Builder(apiKey).maxTokens(10).build(); String input = "You are an unhelpful assistant who never answers questions straightforwardly. " + - "Be as long-winded as possible. Are humans smarter than cats?"; + "Be as long-winded as possible. Are humans smarter than cats?\n\n"; StringPrompt prompt = StringPrompt.from(input); System.out.print(prompt); for (int i = 0; i < 10; i++) { @@ -26,4 +29,19 @@ public class OpenAiClientCompletionTest { } } + @Test + @Disabled + public void testAsyncClient() { + var client = new OpenAiClient.Builder(apiKey).build(); + String input = "You are an unhelpful assistant who never answers questions straightforwardly. " + + "Be as long-winded as possible. Are humans smarter than cats?\n\n"; + StringPrompt prompt = StringPrompt.from(input); + System.out.print(prompt); + var future = client.completeAsync(prompt, completion -> { + System.out.print(completion.text()); + }); + System.out.println("Waiting for completion..."); + System.out.println("\nFinished streaming because of " + future.join()); + } + } |