async_dashscope/operation/
validate.rs1use crate::error::Result;
2use crate::{error::DashScopeError, operation::generation::GenerationParam};
3pub trait ModelValidation {
4 fn validate(&self, params: &GenerationParam) -> Result<()>;
5}
6
7pub struct DefaultValidation;
8
9impl ModelValidation for DefaultValidation {
10 fn validate(&self, _params: &GenerationParam) -> Result<()> {
11 Ok(())
12 }
13}
14
15pub struct DeepSeekV1;
16
17impl ModelValidation for DeepSeekV1 {
18 fn validate(&self, params: &GenerationParam) -> Result<()> {
19 if let Some(param) = ¶ms.parameters {
20 if let Some(ref format) = param.result_format {
21 if format == "text" {
22 return Err(DashScopeError::InvalidArgument(
23 "deepseek-r1 does not support result_format = text".into(),
24 ));
25 }
26 }
27 }
28 Ok(())
29 }
30}
31
32
33pub(crate) fn check_model_parameters(model: &str) -> Box<dyn ModelValidation> {
34
35 match model {
36 "deepseek-r1" => Box::new(DeepSeekV1),
37
38 _ => Box::new(DefaultValidation),
39 }
40}