Add logit bias parameter to CompletionRequest (#41)
This commit is contained in:
parent
c76923926e
commit
8d7f240010
|
@ -6,6 +6,7 @@ import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A request for OpenAi to generate a predicted completion for a prompt.
|
* A request for OpenAi to generate a predicted completion for a prompt.
|
||||||
|
@ -110,6 +111,15 @@ public class CompletionRequest {
|
||||||
*/
|
*/
|
||||||
Integer bestOf;
|
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<String, Integer> logitBias;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A unique identifier representing your end-user, which will help OpenAI to monitor and detect abuse.
|
* A unique identifier representing your end-user, which will help OpenAI to monitor and detect abuse.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.theokanning.openai.completion.CompletionChoice;
|
||||||
import com.theokanning.openai.completion.CompletionRequest;
|
import com.theokanning.openai.completion.CompletionRequest;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
@ -21,6 +22,7 @@ public class CompletionTest {
|
||||||
.prompt("Somebody once told me the world is gonna roll me")
|
.prompt("Somebody once told me the world is gonna roll me")
|
||||||
.echo(true)
|
.echo(true)
|
||||||
.user("testing")
|
.user("testing")
|
||||||
|
.logitBias(new HashMap<>())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
List<CompletionChoice> choices = service.createCompletion(completionRequest).getChoices();
|
List<CompletionChoice> choices = service.createCompletion(completionRequest).getChoices();
|
||||||
|
|
Loading…
Reference in New Issue