Skip to content
This repository was archived by the owner on Jun 6, 2024. It is now read-only.

Commit 77219d4

Browse files
authored
Add user to CompletionRequest (#23)
Fixes #19
1 parent 1391f40 commit 77219d4

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

api/src/main/java/com/theokanning/openai/completion/CompletionRequest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,9 @@ public class CompletionRequest {
108108
* best_of must be greater than n.
109109
*/
110110
Integer bestOf;
111+
112+
/**
113+
* A unique identifier representing your end-user, which will help OpenAI to monitor and detect abuse.
114+
*/
115+
String user;
111116
}

client/src/test/java/com/theokanning/openai/CompletionTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ void createCompletion() {
1919
CompletionRequest completionRequest = CompletionRequest.builder()
2020
.prompt("Somebody once told me the world is gonna roll me")
2121
.echo(true)
22+
.user("testing")
2223
.build();
2324

2425
List<CompletionChoice> choices = service.createCompletion("ada", completionRequest).getChoices();

example/src/main/java/example/OpenAiApiExample.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public static void main(String... args) {
2323
CompletionRequest completionRequest = CompletionRequest.builder()
2424
.prompt("Somebody once told me the world is gonna roll me")
2525
.echo(true)
26+
.user("testing")
2627
.build();
2728
service.createCompletion("ada", completionRequest).getChoices().forEach(System.out::println);
2829

0 commit comments

Comments
 (0)