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

Add seed and fingerprint for reproducible outputs. #457

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package com.theokanning.openai.completion.chat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.util.List;
Expand Down Expand Up @@ -28,6 +29,13 @@ public class ChatCompletionChunk {
*/
String model;

/**
* The fingerprint denotes the backend configuration used by the model.
* Learn more at: https://platform.openai.com/docs/api-reference/chat/streaming#chat/streaming-system_fingerprint
*/
@JsonProperty("system_fingerprint")
String fingerprint;

/**
* A list of all generated completions.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ public class ChatCompletionRequest {
*/
Integer n;

/**
* For consistent results, use the same seed and parameters in your request.
* Set the seed parameter to an integer of your choice and maintain its value across requests for deterministic outputs.
*
* Determinism cannot be guaranteed, so please refer to the {@link ChatCompletionResult#fingerprint} to track any changes in the backend.
*/
Integer seed;

/**
* If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format">server-sent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package com.theokanning.openai.completion.chat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.theokanning.openai.Usage;
import lombok.Data;

Expand Down Expand Up @@ -30,6 +31,13 @@ public class ChatCompletionResult {
*/
String model;

/**
* The fingerprint denotes the backend configuration used by the model.
* Learn more at: https://platform.openai.com/docs/api-reference/chat/object#chat/object-system_fingerprint
*/
@JsonProperty("system_fingerprint")
String fingerprint;

/**
* A list of all generated completions.
*/
Expand Down