@@ -1050,3 +1050,51 @@ def test_threshold_raised_short_strings(self):
10501050 weighted_mks = [mk for mk in config .get_matchkeys () if mk .type == "weighted" ]
10511051 assert len (weighted_mks ) > 0 , "Expected at least one weighted matchkey"
10521052 assert weighted_mks [0 ].threshold >= 0.80
1053+
1054+
1055+ class TestLLMMemoryAutoEnablement :
1056+ """Tests for LLM + memory auto-enablement."""
1057+
1058+ def test_llm_auto_with_api_key (self ):
1059+ from goldenmatch .core .autoconfig import auto_configure_df
1060+ from unittest .mock import patch
1061+ df = pl .DataFrame ({"name" : ["John" , "Jane" , "Bob" ], "email" : ["a@t.com" , "b@t.com" , "c@t.com" ]})
1062+ with patch .dict ("os.environ" , {"OPENAI_API_KEY" : "sk-fake" }):
1063+ config = auto_configure_df (df , llm_auto = True )
1064+ assert config .llm_scorer is not None
1065+ assert config .llm_scorer .enabled is True
1066+ assert config .llm_scorer .budget .max_cost_usd == 0.05
1067+
1068+ def test_llm_auto_no_key (self ):
1069+ from goldenmatch .core .autoconfig import auto_configure_df
1070+ from unittest .mock import patch
1071+ import os
1072+ df = pl .DataFrame ({"name" : ["John" , "Jane" , "Bob" ], "email" : ["a@t.com" , "b@t.com" , "c@t.com" ]})
1073+ with patch .dict ("os.environ" , {"OPENAI_API_KEY" : "" , "ANTHROPIC_API_KEY" : "" }):
1074+ os .environ .pop ("OPENAI_API_KEY" , None )
1075+ os .environ .pop ("ANTHROPIC_API_KEY" , None )
1076+ config = auto_configure_df (df , llm_auto = True )
1077+ assert config .llm_scorer is None
1078+
1079+ def test_llm_auto_off (self ):
1080+ from goldenmatch .core .autoconfig import auto_configure_df
1081+ from unittest .mock import patch
1082+ df = pl .DataFrame ({"name" : ["John" , "Jane" , "Bob" ], "email" : ["a@t.com" , "b@t.com" , "c@t.com" ]})
1083+ with patch .dict ("os.environ" , {"OPENAI_API_KEY" : "sk-fake" }):
1084+ config = auto_configure_df (df , llm_auto = False )
1085+ assert config .llm_scorer is None
1086+
1087+ def test_memory_with_llm_auto (self ):
1088+ from goldenmatch .core .autoconfig import auto_configure_df
1089+ from unittest .mock import patch
1090+ df = pl .DataFrame ({"name" : ["John" , "Jane" , "Bob" ], "email" : ["a@t.com" , "b@t.com" , "c@t.com" ]})
1091+ with patch .dict ("os.environ" , {"OPENAI_API_KEY" : "sk-fake" }):
1092+ config = auto_configure_df (df , llm_auto = True )
1093+ assert config .memory is not None
1094+ assert config .memory .enabled is True
1095+
1096+ def test_memory_off_by_default (self ):
1097+ from goldenmatch .core .autoconfig import auto_configure_df
1098+ df = pl .DataFrame ({"name" : ["John" , "Jane" , "Bob" ], "email" : ["a@t.com" , "b@t.com" , "c@t.com" ]})
1099+ config = auto_configure_df (df )
1100+ assert config .memory is None
0 commit comments