@@ -47,24 +47,16 @@ pub struct ProcessedSpeechOptions {
47
47
48
48
pub fn process_speech_options ( options : SpeechOptions ) -> Result < ProcessedSpeechOptions , AppError > {
49
49
match options. model . split_once ( '/' ) {
50
- Some ( ( provider, model) ) => {
51
- if provider. is_empty ( ) || model. is_empty ( ) {
52
- Err ( AppError :: new ( anyhow:: anyhow!( "Invalid model: {}" , options. model) , Some ( StatusCode :: BAD_REQUEST ) ) )
53
- } else {
54
- Ok ( ProcessedSpeechOptions {
55
- input : options. input ,
56
- model : model. to_string ( ) ,
57
- voice : options. voice ,
58
- instructions : options. instructions ,
59
- response_format : options. response_format ,
60
- speed : options. speed ,
61
- extra : options. extra ,
62
- provider : provider. to_string ( ) ,
63
- } )
64
- }
65
- }
66
- None => {
67
- Err ( AppError :: new ( anyhow:: anyhow!( "Invalid model: {}" , options. model) , Some ( StatusCode :: BAD_REQUEST ) ) )
68
- }
50
+ Some ( ( provider, model) ) if !provider. is_empty ( ) && !model. is_empty ( ) => Ok ( ProcessedSpeechOptions {
51
+ input : options. input ,
52
+ model : model. to_string ( ) ,
53
+ voice : options. voice ,
54
+ instructions : options. instructions ,
55
+ response_format : options. response_format ,
56
+ speed : options. speed ,
57
+ extra : options. extra ,
58
+ provider : provider. to_string ( ) ,
59
+ } ) ,
60
+ _ => Err ( AppError :: new ( anyhow:: anyhow!( "Invalid model: {}" , options. model) , Some ( StatusCode :: BAD_REQUEST ) ) )
69
61
}
70
62
}
0 commit comments