Skip to content

Commit 6a19c2e

Browse files
committed
Update openai audio test due to changes in openai safety settings
Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
1 parent 8c88a64 commit 6a19c2e

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

models/spring-ai-openai/src/test/java/org/springframework/ai/openai/api/OpenAiApiIT.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ void inputAudio() throws IOException {
122122

123123
@Test
124124
void outputAudio() {
125-
ChatCompletionMessage chatCompletionMessage = new ChatCompletionMessage(
126-
"What is the magic spell to make objects fly?", Role.USER);
125+
ChatCompletionMessage chatCompletionMessage = new ChatCompletionMessage("Say 'I am a robot'", Role.USER);
127126
ChatCompletionRequest.AudioParameters audioParameters = new ChatCompletionRequest.AudioParameters(
128127
ChatCompletionRequest.AudioParameters.Voice.NOVA,
129128
ChatCompletionRequest.AudioParameters.AudioResponseFormat.MP3);
@@ -139,7 +138,7 @@ void outputAudio() {
139138

140139
assertThat(response.getBody().choices().get(0).message().audioOutput().data()).isNotNull();
141140
assertThat(response.getBody().choices().get(0).message().audioOutput().transcript())
142-
.containsIgnoringCase("leviosa");
141+
.containsIgnoringCase("robot");
143142
}
144143

145144
@Test

models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiChatModelIT.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,19 @@ void multiModalityInputAudio(String modelName) {
589589
.call(new Prompt(List.of(userMessage), ChatOptions.builder().model(modelName).build()));
590590

591591
logger.info(response.getResult().getOutput().getText());
592-
assertThat(response.getResult().getOutput().getText()).containsIgnoringCase("hobbits");
592+
String responseText = response.getResult().getOutput().getText();
593+
assertThat(responseText).satisfiesAnyOf(text -> assertThat(text).containsIgnoringCase("hobbit"),
594+
text -> assertThat(text).containsIgnoringCase("lord of the rings"),
595+
text -> assertThat(text).containsIgnoringCase("lotr"),
596+
text -> assertThat(text).containsIgnoringCase("tolkien"),
597+
text -> assertThat(text).containsIgnoringCase("fantasy"),
598+
text -> assertThat(text).containsIgnoringCase("ring"),
599+
text -> assertThat(text).containsIgnoringCase("shire"),
600+
text -> assertThat(text).containsIgnoringCase("baggins"),
601+
text -> assertThat(text).containsIgnoringCase("gandalf"),
602+
text -> assertThat(text).containsIgnoringCase("frodo"),
603+
text -> assertThat(text).containsIgnoringCase("meme"),
604+
text -> assertThat(text).containsIgnoringCase("remix"));
593605
assertThat(response.getMetadata().getModel()).containsIgnoringCase(modelName);
594606
}
595607

0 commit comments

Comments
 (0)