Skip to content

Commit

Permalink
Add enum for AudioResponseFormat + dependency updates
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed Sep 25, 2024
1 parent 60022d2 commit 0ff8bd0
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ java {
}

def jacksonVersion = "2.17.2"
def junitVersion = "5.11.0"
def junitVersion = "5.11.1"

dependencies {
implementation("com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}")
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.github.stefanbratanov.jvm.openai;

/** The format of the output */
public enum AudioResponseFormat {
JSON("json"),
TEXT("text"),
SRT("srt"),
VERBOSE_JSON("verbose_json"),
VTT("vtt");

private final String id;

AudioResponseFormat(String id) {
this.id = id;
}

public String getId() {
return id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ public Builder responseFormat(String responseFormat) {
return this;
}

/**
* @param responseFormat The {@link AudioResponseFormat} of the translation output
*/
public Builder responseFormat(AudioResponseFormat responseFormat) {
this.responseFormat = Optional.of(responseFormat.getId());
return this;
}

/**
* @param temperature The sampling temperature, between 0 and 1. Higher values like 0.8 will
* make the output more random, while lower values like 0.2 will make it more focused and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ public Builder responseFormat(String responseFormat) {
return this;
}

/**
* @param responseFormat The {@link AudioResponseFormat} of the translation output
*/
public Builder responseFormat(AudioResponseFormat responseFormat) {
this.responseFormat = Optional.of(responseFormat.getId());
return this;
}

/**
* @param temperature The sampling temperature, between 0 and 1. Higher values like 0.8 will
* make the output more random, while lower values like 0.2 will make it more focused and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ void testAudioClient(@TempDir Path tempDir) {
TranslationRequest.newBuilder()
.file(greeting)
.model(OpenAIModel.WHISPER_1)
.responseFormat("json")
.responseFormat(AudioResponseFormat.JSON)
.build();

String translation = audioClient.createTranslation(translationRequest);
Expand Down

0 comments on commit 0ff8bd0

Please sign in to comment.