Describe the bug
The OpenAIClient::audio_transcription(&self, req:AudioTranscriptionRequest) method takes in a request of structure:
#[derive(Debug, Serialize, Clone)]
pub struct AudioTranscriptionRequest {
pub file: String,
pub model: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub prompt: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub response_format: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub temperature: Option<f32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub language: Option<String>,
}
where response_format seems to be directly mapped to the response_format API argument described in OpenAI's documentation. However, when it is given a non-json argument, text in my case, the method fails to parse the response while attempting to deserialize it from an assumed json format, giving an error.
To Reproduce
- Create an
AudioTranscriptionRequest with its response_format field set to Some("text".to_string()).
- Use it to call
OpenAIClient::audio_transcription(&self, req:AudioTranscriptionRequest).
- Observe that the returned result is always a parsing error.
Code snippets
let request = AudioTranscriptionRequest {
file: tmp_path.to_string_lossy().to_string(), // arbitrary file path
model: "whisper-1".to_string(),
prompt: None,
response_format: Some("text".to_string()),
temperature: None,
language: Some("ko".to_string()),
};
let resp = openai.audio_transcription(request).await;
OS
Windows 10(Ubuntu 22.04 WSL2), Also tested on MacOS 15.1.1
Rust version
Rust v1.83.0
Library version
openai-api-rs v5.2.3
Describe the bug
The
OpenAIClient::audio_transcription(&self, req:AudioTranscriptionRequest)method takes in a request of structure:where
response_formatseems to be directly mapped to theresponse_formatAPI argument described in OpenAI's documentation. However, when it is given a non-json argument,textin my case, the method fails to parse the response while attempting to deserialize it from an assumedjsonformat, giving an error.To Reproduce
AudioTranscriptionRequestwith itsresponse_formatfield set toSome("text".to_string()).OpenAIClient::audio_transcription(&self, req:AudioTranscriptionRequest).Code snippets
OS
Windows 10(Ubuntu 22.04 WSL2), Also tested on MacOS 15.1.1
Rust version
Rust v1.83.0
Library version
openai-api-rs v5.2.3