@@ -422,9 +422,82 @@ mod tests {
422422
423423 assert_eq ! ( request_body[ "thinking" ] [ "type" ] , "enabled" ) ;
424424 assert ! ( request_body. get( "enable_thinking" ) . is_none( ) ) ;
425+ assert ! ( request_body. get( "reasoning_effort" ) . is_none( ) ) ;
425426 assert ! ( request_body. get( "reasoning_split" ) . is_none( ) ) ;
426427 }
427428
429+ #[ test]
430+ fn build_openai_request_body_adds_deepseek_reasoning_effort ( ) {
431+ let client = AIClient :: new ( AIConfig {
432+ name : "deepseek" . to_string ( ) ,
433+ base_url : "https://api.deepseek.com/v1" . to_string ( ) ,
434+ request_url : "https://api.deepseek.com/v1/chat/completions" . to_string ( ) ,
435+ api_key : "test-key" . to_string ( ) ,
436+ model : "deepseek-v4-pro" . to_string ( ) ,
437+ format : "openai" . to_string ( ) ,
438+ context_window : 128000 ,
439+ max_tokens : Some ( 4096 ) ,
440+ temperature : None ,
441+ top_p : None ,
442+ reasoning_mode : ReasoningMode :: Enabled ,
443+ inline_think_in_text : false ,
444+ custom_headers : None ,
445+ custom_headers_mode : None ,
446+ skip_ssl_verify : false ,
447+ reasoning_effort : Some ( "xhigh" . to_string ( ) ) ,
448+ thinking_budget_tokens : None ,
449+ custom_request_body : None ,
450+ custom_request_body_mode : None ,
451+ } ) ;
452+
453+ let request_body = openai:: chat:: build_request_body (
454+ & client,
455+ & client. config . request_url ,
456+ vec ! [ json!( { "role" : "user" , "content" : "hello" } ) ] ,
457+ None ,
458+ None ,
459+ ) ;
460+
461+ assert_eq ! ( request_body[ "thinking" ] [ "type" ] , "enabled" ) ;
462+ assert_eq ! ( request_body[ "reasoning_effort" ] , "max" ) ;
463+ }
464+
465+ #[ test]
466+ fn build_openai_request_body_omits_deepseek_reasoning_effort_when_disabled ( ) {
467+ let client = AIClient :: new ( AIConfig {
468+ name : "deepseek" . to_string ( ) ,
469+ base_url : "https://api.deepseek.com/v1" . to_string ( ) ,
470+ request_url : "https://api.deepseek.com/v1/chat/completions" . to_string ( ) ,
471+ api_key : "test-key" . to_string ( ) ,
472+ model : "deepseek-v4-flash" . to_string ( ) ,
473+ format : "openai" . to_string ( ) ,
474+ context_window : 128000 ,
475+ max_tokens : Some ( 4096 ) ,
476+ temperature : None ,
477+ top_p : None ,
478+ reasoning_mode : ReasoningMode :: Disabled ,
479+ inline_think_in_text : false ,
480+ custom_headers : None ,
481+ custom_headers_mode : None ,
482+ skip_ssl_verify : false ,
483+ reasoning_effort : Some ( "max" . to_string ( ) ) ,
484+ thinking_budget_tokens : None ,
485+ custom_request_body : None ,
486+ custom_request_body_mode : None ,
487+ } ) ;
488+
489+ let request_body = openai:: chat:: build_request_body (
490+ & client,
491+ & client. config . request_url ,
492+ vec ! [ json!( { "role" : "user" , "content" : "hello" } ) ] ,
493+ None ,
494+ None ,
495+ ) ;
496+
497+ assert_eq ! ( request_body[ "thinking" ] [ "type" ] , "disabled" ) ;
498+ assert ! ( request_body. get( "reasoning_effort" ) . is_none( ) ) ;
499+ }
500+
428501 #[ test]
429502 fn build_openai_request_body_uses_enable_thinking_for_siliconflow ( ) {
430503 let client = AIClient :: new ( AIConfig {
@@ -536,10 +609,52 @@ mod tests {
536609 assert_eq ! ( request_body[ "output_config" ] [ "effort" ] , "high" ) ;
537610 }
538611
612+ #[ test]
613+ fn build_anthropic_request_body_adds_deepseek_reasoning_effort ( ) {
614+ let client = AIClient :: new ( AIConfig {
615+ name : "deepseek" . to_string ( ) ,
616+ base_url : "https://api.deepseek.com/anthropic" . to_string ( ) ,
617+ request_url : "https://api.deepseek.com/anthropic/v1/messages" . to_string ( ) ,
618+ api_key : "test-key" . to_string ( ) ,
619+ model : "deepseek-v4-pro" . to_string ( ) ,
620+ format : "anthropic" . to_string ( ) ,
621+ context_window : 200000 ,
622+ max_tokens : Some ( 8192 ) ,
623+ temperature : None ,
624+ top_p : None ,
625+ reasoning_mode : ReasoningMode :: Enabled ,
626+ inline_think_in_text : false ,
627+ custom_headers : None ,
628+ custom_headers_mode : None ,
629+ skip_ssl_verify : false ,
630+ reasoning_effort : Some ( "xhigh" . to_string ( ) ) ,
631+ thinking_budget_tokens : None ,
632+ custom_request_body : None ,
633+ custom_request_body_mode : None ,
634+ } ) ;
635+
636+ let request_body = anthropic:: request:: build_request_body (
637+ & client,
638+ & client. config . request_url ,
639+ None ,
640+ vec ! [ json!( { "role" : "user" , "content" : [ { "type" : "text" , "text" : "hello" } ] } ) ] ,
641+ None ,
642+ None ,
643+ ) ;
644+
645+ assert_eq ! ( request_body[ "thinking" ] [ "type" ] , "enabled" ) ;
646+ assert_eq ! ( request_body[ "output_config" ] [ "effort" ] , "max" ) ;
647+ }
648+
539649 #[ test]
540650 fn build_openai_request_body_trim_mode_preserves_essential_fields ( ) {
541651 let mut client = make_trim_test_client ( "openai" ) ;
652+ client. config . base_url = "https://api.deepseek.com/v1" . to_string ( ) ;
653+ client. config . request_url = "https://api.deepseek.com/v1/chat/completions" . to_string ( ) ;
654+ client. config . model = "deepseek-v4-pro" . to_string ( ) ;
542655 client. config . max_tokens = Some ( 8192 ) ;
656+ client. config . reasoning_mode = ReasoningMode :: Enabled ;
657+ client. config . reasoning_effort = Some ( "high" . to_string ( ) ) ;
543658 let messages = vec ! [ json!( { "role" : "user" , "content" : "hello" } ) ] ;
544659
545660 let request_body = openai:: chat:: build_request_body (
@@ -557,13 +672,14 @@ mod tests {
557672 } ) ) ,
558673 ) ;
559674
560- assert_eq ! ( request_body[ "model" ] , "test-model " ) ;
675+ assert_eq ! ( request_body[ "model" ] , "deepseek-v4-pro " ) ;
561676 assert_eq ! ( request_body[ "messages" ] , json!( messages) ) ;
562677 assert_eq ! ( request_body[ "stream" ] , true ) ;
563678 assert_eq ! ( request_body[ "max_tokens" ] , 8192 ) ;
564679 assert_eq ! ( request_body[ "temperature" ] , 0.7 ) ;
565680 assert_eq ! ( request_body[ "response_format" ] [ "type" ] , "json_object" ) ;
566681 assert ! ( request_body. get( "thinking" ) . is_none( ) ) ;
682+ assert ! ( request_body. get( "reasoning_effort" ) . is_none( ) ) ;
567683 }
568684
569685 #[ test]
0 commit comments