Skip to content

Commit

Permalink
add chatclient IT for openai multimodal Audio resposne
Browse files Browse the repository at this point in the history
  • Loading branch information
tzolov committed Dec 5, 2024
1 parent f922195 commit 6cfe5e7
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.springframework.ai.openai.OpenAiChatOptions;
import org.springframework.ai.openai.OpenAiTestConfiguration;
import org.springframework.ai.openai.api.OpenAiApi;
import org.springframework.ai.openai.api.OpenAiApi.ChatCompletionRequest.AudioParameters;
import org.springframework.ai.openai.api.tool.MockWeatherService;
import org.springframework.ai.openai.testutils.AbstractIT;
import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -367,6 +368,24 @@ void streamingMultiModalityImageUrl() throws IOException {
assertThat(content).containsAnyOf("bowl", "basket");
}

@Test
void multiModalityAudioResponse() {
ChatResponse response = ChatClient.create(this.chatModel)
.prompt("Tell me joke about Spring Framework")
.options(OpenAiChatOptions.builder()
.withModel(OpenAiApi.ChatModel.GPT_4_O_AUDIO_PREVIEW)
.withOutputAudio(
new AudioParameters(AudioParameters.Voice.ALLOY, AudioParameters.AudioResponseFormat.WAV))
.withOutputModalities(List.of("text", "audio"))
.build())
.call()
.chatResponse();

assertThat(response).isNotNull();
assertThat(response.getResult().getOutput().getMedia().get(0).getDataAsByteArray()).isNotEmpty();
logger.info("Response: " + response);
}

record ActorsFilms(String actor, List<String> movies) {

}
Expand Down

0 comments on commit 6cfe5e7

Please sign in to comment.