23
23
from openai_api .lambda_openai_function .custom_config import (
24
24
AdditionalInformation ,
25
25
CustomConfig ,
26
+ FunctionCalling ,
27
+ Prompting ,
26
28
SearchTerms ,
27
29
SystemPrompt ,
30
+ validate_required_keys ,
28
31
)
29
32
30
33
# our stuff
@@ -42,6 +45,19 @@ def setUp(self):
42
45
self .everlasting_gobbstopper = get_test_file_yaml ("config/everlasting-gobbstopper.yaml" )
43
46
self .everlasting_gobbstopper_invalid = get_test_file_yaml ("config/everlasting-gobbstopper-invalid.yaml" )
44
47
48
+ def test_validate_required_keys (self ):
49
+ """Test validate_required_keys."""
50
+ required_keys = ["meta_data" , "prompting" , "function_calling" ]
51
+ validate_required_keys (
52
+ class_name = "CustomConfig" , config_json = self .everlasting_gobbstopper , required_keys = required_keys
53
+ )
54
+
55
+ with self .assertRaises (ValueError ):
56
+ required_keys = ["meta_data" , "prompting" , "some_other_key" ]
57
+ validate_required_keys (
58
+ class_name = "CustomConfig" , config_json = self .everlasting_gobbstopper_invalid , required_keys = required_keys
59
+ )
60
+
45
61
def test_system_prompt (self ):
46
62
"""Test system_prompt."""
47
63
prompt = self .everlasting_gobbstopper ["prompting" ]["system_prompt" ]
@@ -53,6 +69,7 @@ def test_system_prompt(self):
53
69
)
54
70
self .assertIsInstance (system_prompt , SystemPrompt )
55
71
self .assertIsInstance (system_prompt .system_prompt , str )
72
+ self .assertTrue (isinstance (system_prompt .to_json (), dict ))
56
73
57
74
def test_system_prompt_invalid (self ):
58
75
"""Test system_prompt."""
@@ -132,3 +149,21 @@ def test_refers_to(self):
132
149
self .assertListEqual (
133
150
additional_information .keys , ["contact" , "biographical" , "sales_promotions" , "coupon_codes" ]
134
151
)
152
+
153
+ def test_prompting (self ):
154
+ """Test prompting."""
155
+ custom_config = CustomConfig (config_json = self .everlasting_gobbstopper )
156
+ prompting_config_json = custom_config .prompting .to_json ()
157
+ Prompting (config_json = prompting_config_json )
158
+
159
+ with self .assertRaises (ValueError ):
160
+ Prompting (config_json = {})
161
+
162
+ def test_function_calling (self ):
163
+ """Test function_calling."""
164
+ custom_config = CustomConfig (config_json = self .everlasting_gobbstopper )
165
+ function_calling_config_json = custom_config .function_calling .to_json ()
166
+ FunctionCalling (config_json = function_calling_config_json )
167
+
168
+ with self .assertRaises (ValueError ):
169
+ FunctionCalling (config_json = {})
0 commit comments