spring-ai icon indicating copy to clipboard operation
spring-ai copied to clipboard

OpenAI Transcription Options are Getting Overwritten

Open springframeworkguru opened this issue 1 year ago • 5 comments
trafficstars

When using AudioTranscription Options, they seem to be getting overwritten with the defaults.

Setting options as:

OpenAiAudioTranscriptionOptions transcriptionOptions = OpenAiAudioTranscriptionOptions.builder()
                .withResponseFormat(OpenAiAudioApi.TranscriptResponseFormat.SRT)
                .withModel(OpenAiAudioApi.WhisperModel.WHISPER_1.name())
                .withTemperature(0f)
                .build();

        AudioTranscriptionPrompt prompt = new AudioTranscriptionPrompt(file.getResource(), transcriptionOptions);

Will always return text, response format is ignored.

HOWEVER, Setting options at a global level via properties, this works.

Example:

  ai:
    openai:
      api-key: ${OPENAI_API_KEY}
      audio:
        transcription:
          options:
            response-format: srt

This will produce the srt output properly. Seems the options set via properties are overriding the options set in Java.

I saw this working okay before. I think this commit might be overriding the options.

springframeworkguru avatar Apr 28 '24 21:04 springframeworkguru

@springframeworkguru , can you share which spring ai version are using? I've added a test that verifies the correctness transcription merging behaviour for version 1.0.0-SNAPSHOT.

tzolov avatar Apr 29 '24 21:04 tzolov

Hi @tzolov - I'm using the 0.0.1-SNAPSHOT version. I noticed the issue because I started to always get TEXT back, regardless to what I set the runtime option to.

springframeworkguru avatar Apr 30 '24 11:04 springframeworkguru

Hi @tzolov - I'm using the 0.0.1-SNAPSHOT version. do you mean 1.0.0-SNAPSHOT version?

tzolov avatar Apr 30 '24 11:04 tzolov

It would help if you provide a simple example to reproduce the behaviour.

tzolov avatar Apr 30 '24 11:04 tzolov

Yes, the 1.0.0-SNAPSHOT version.

Please see the branch spring-ai-audio-test. in this repo.

The test OpenAIServiceImplTest has two tests one for srt, one for json. Options are set at runtime in the method. Both return plain text.

The test OpebAIServiceImplTestSrt brings in a profile that sets the default response format to SRT. Both tests now return vaild SRT. Expected behavior of the json test would be to return json, since that is being set as the option in the method being called.

The test OpenAIServiceImplJsonTest bring in a profile to set to verbose_json. Both tests return text. Same result with using the json format option too. This one made no sense to me, I was expecting it to behave like the SRT test.

springframeworkguru avatar Apr 30 '24 14:04 springframeworkguru