@@ -875,14 +875,114 @@ def test_disable_trustworthiness_with_custom_criteria_works(tlm_api_key: str) ->
875875
876876def test_disable_trustworthiness_without_custom_criteria_raises_error_rag (tlm_api_key : str ) -> None :
877877 """Test that disable_trustworthiness=True without custom_eval_criteria raises ValueError for TrustworthyRAG."""
878- from cleanlab_tlm .utils .rag import TrustworthyRAG
879-
880878 with pytest .raises (ValidationError , match = "^When disable_trustworthiness=True in TrustworthyRAG" ):
881879 TrustworthyRAG (evals = [], api_key = tlm_api_key , options = {"disable_trustworthiness" : True })
882880
883881
884882def test_disable_trustworthiness_with_custom_criteria_works_rag (tlm_api_key : str ) -> None :
885883 """Test that disable_trustworthiness=True with custom_eval_criteria works normally for TrustworthyRAG."""
886- from cleanlab_tlm .utils .rag import TrustworthyRAG
887-
888884 TrustworthyRAG (api_key = tlm_api_key , options = {"disable_trustworthiness" : True })
885+
886+
887+ @pytest .mark .filterwarnings ("ignore::DeprecationWarning" )
888+ def test_validate_logging (tlm_api_key : str ) -> None :
889+ """Test validate_logging() method errors at the right times."""
890+ # Settings that should not raise error:
891+ TLM (api_key = tlm_api_key )
892+ TLM (api_key = tlm_api_key , options = {"log" : ["explanation" ]})
893+ TLM (api_key = tlm_api_key , quality_preset = "best" , options = {"log" : ["explanation" ], "reasoning_effort" : "none" })
894+ TLM (api_key = tlm_api_key , quality_preset = "high" , options = {"log" : ["explanation" ], "reasoning_effort" : "none" })
895+ TLM (api_key = tlm_api_key , quality_preset = "base" , options = {"log" : ["explanation" ], "num_consistency_samples" : 8 })
896+ TLM (
897+ api_key = tlm_api_key ,
898+ quality_preset = "best" ,
899+ options = {"log" : ["explanation" ], "num_self_reflections" : 0 },
900+ )
901+ TLM (
902+ api_key = tlm_api_key ,
903+ quality_preset = "low" ,
904+ options = {
905+ "log" : ["explanation" ],
906+ "num_self_reflections" : 0 ,
907+ "num_consistency_samples" : 4 ,
908+ },
909+ )
910+ TLM (api_key = tlm_api_key , options = {"model" : "gpt-5-mini" })
911+
912+ # Settings that should error:
913+ with pytest .raises (ValueError , match = "does not support logged explanations" ):
914+ TLM (api_key = tlm_api_key , quality_preset = "low" , options = {"log" : ["explanation" ]})
915+ with pytest .raises (ValueError , match = "does not support logged explanations" ):
916+ TLM (api_key = tlm_api_key , quality_preset = "base" , options = {"log" : ["explanation" ]})
917+ with pytest .raises (ValueError , match = "does not support logged explanations" ):
918+ TLM (
919+ api_key = tlm_api_key ,
920+ quality_preset = "best" ,
921+ options = {"log" : ["explanation" ], "reasoning_effort" : "none" , "num_consistency_samples" : 0 },
922+ )
923+ with pytest .raises (ValueError , match = "does not support logged explanations" ):
924+ TLM (
925+ api_key = tlm_api_key ,
926+ options = {"log" : ["explanation" ], "num_self_reflections" : 0 },
927+ )
928+
929+ with pytest .raises (ValueError , match = "does not support logged explanations" ):
930+ TLM (
931+ api_key = tlm_api_key ,
932+ options = {"log" : ["explanation" ], "use_self_reflection" : False },
933+ )
934+ with pytest .raises (ValueError , match = "does not support logged explanations" ):
935+ TLM (
936+ api_key = tlm_api_key ,
937+ quality_preset = "best" ,
938+ options = {
939+ "log" : ["explanation" ],
940+ "num_self_reflections" : 0 ,
941+ "num_consistency_samples" : 0 ,
942+ },
943+ )
944+ with pytest .raises (ValueError , match = "does not support logged explanations" ):
945+ TLM (
946+ api_key = tlm_api_key ,
947+ options = {
948+ "log" : ["explanation" ],
949+ "reasoning_effort" : "high" ,
950+ "num_self_reflections" : 0 ,
951+ },
952+ )
953+ with pytest .raises (ValueError , match = "does not support logged explanations" ):
954+ TLM (api_key = tlm_api_key , options = {"log" : ["explanation" ], "model" : "gpt-5-mini" })
955+
956+ # Settings that should not raise error:
957+ TrustworthyRAG (api_key = tlm_api_key )
958+ TrustworthyRAG (api_key = tlm_api_key , options = {"log" : ["explanation" ], "num_consistency_samples" : 5 })
959+ TrustworthyRAG (api_key = tlm_api_key , options = {"log" : ["explanation" ], "reasoning_effort" : "high" })
960+ TrustworthyRAG (api_key = tlm_api_key , quality_preset = "best" , options = {"log" : ["explanation" ]})
961+
962+ # Settings that should error:
963+ with pytest .raises (ValueError , match = "does not support logged explanations" ):
964+ TrustworthyRAG (api_key = tlm_api_key , options = {"log" : ["explanation" ]})
965+ with pytest .raises (ValueError , match = "does not support logged explanations" ):
966+ TrustworthyRAG (
967+ api_key = tlm_api_key , quality_preset = "best" , options = {"log" : ["explanation" ], "num_consistency_samples" : 0 }
968+ )
969+ with pytest .raises (ValueError , match = "does not support logged explanations" ):
970+ TrustworthyRAG (
971+ api_key = tlm_api_key ,
972+ options = {
973+ "log" : ["explanation" ],
974+ "reasoning_effort" : "high" ,
975+ "num_self_reflections" : 0 ,
976+ },
977+ )
978+ with pytest .raises (ValueError , match = "does not support logged explanations" ):
979+ TrustworthyRAG (
980+ api_key = tlm_api_key ,
981+ quality_preset = "best" ,
982+ options = {
983+ "log" : ["explanation" ],
984+ "reasoning_effort" : "high" ,
985+ "num_self_reflections" : 0 ,
986+ "num_consistency_samples" : 0 ,
987+ },
988+ )
0 commit comments