aboutsummaryrefslogtreecommitdiffstats
path: root/vespajlib/src/test/java/ai/vespa/llm/client/openai/OpenAiClientCompletionTest.java
blob: 961a02afea34bc1d6289d3f15b08db139e8a6f39 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package ai.vespa.llm.client.openai;

import ai.vespa.llm.completion.Completion;
import ai.vespa.llm.completion.StringPrompt;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

/**
 * @author bratseth
 */
public class OpenAiClientCompletionTest {

    @Test
    @Disabled
    public void testClient() {
        var client = new OpenAiClient.Builder("your token here").build();
        String input = "You are an unhelpful assistant who never answers questions straightforwardly. " +
                       "Be as long-winded as possible. Are humans smarter than cats?";
        StringPrompt prompt = StringPrompt.from(input);
        System.out.print(prompt);
        for (int i = 0; i < 10; i++) {
            var completion = client.complete(prompt).get(0);
            System.out.print(completion.text());
            if (completion.finishReason() == Completion.FinishReason.stop) break;
            prompt = prompt.append(completion.text());
        }
    }

}