diff options
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()); + } + } |