diff --git a/api/src/main/java/com/theokanning/openai/completion/CompletionRequest.java b/api/src/main/java/com/theokanning/openai/completion/CompletionRequest.java index 8ef6d466..dc8dc098 100644 --- a/api/src/main/java/com/theokanning/openai/completion/CompletionRequest.java +++ b/api/src/main/java/com/theokanning/openai/completion/CompletionRequest.java @@ -6,6 +6,7 @@ import lombok.NoArgsConstructor; import java.util.List; +import java.util.Map; /** * A request for OpenAi to generate a predicted completion for a prompt. @@ -110,6 +111,15 @@ public class CompletionRequest { */ Integer bestOf; + /** + * Modify the likelihood of specified tokens appearing in the completion. + * + * Maps tokens (specified by their token ID in the GPT tokenizer) to an associated bias value from -100 to 100. + * + * https://beta.openai.com/docs/api-reference/completions/create#completions/create-logit_bias + */ + Map logitBias; + /** * A unique identifier representing your end-user, which will help OpenAI to monitor and detect abuse. */ diff --git a/client/src/test/java/com/theokanning/openai/CompletionTest.java b/client/src/test/java/com/theokanning/openai/CompletionTest.java index 4a4d7463..7833f1e6 100644 --- a/client/src/test/java/com/theokanning/openai/CompletionTest.java +++ b/client/src/test/java/com/theokanning/openai/CompletionTest.java @@ -4,6 +4,7 @@ import com.theokanning.openai.completion.CompletionRequest; import org.junit.jupiter.api.Test; +import java.util.HashMap; import java.util.List; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -21,6 +22,7 @@ void createCompletion() { .prompt("Somebody once told me the world is gonna roll me") .echo(true) .user("testing") + .logitBias(new HashMap<>()) .build(); List choices = service.createCompletion(completionRequest).getChoices();