Closed
Description
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 itsresponse_format
field set toSome("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