@@ -37,21 +37,53 @@ def check_model_structure(context: Context, model: str) -> None:
3737 models = response_json ["models" ]
3838 assert len (models ) > 0 , "Models list should not be empty"
3939
40- gpt_model = None
40+ llm_model = None
4141 for model_id in models :
4242 if "gpt-4o-mini" in model_id .get ("identifier" , "" ):
43- gpt_model = model_id
43+ llm_model = model_id
4444 break
4545
46- assert gpt_model is not None
46+ assert llm_model is not None
4747
48- assert gpt_model ["type" ] == "model" , "type should be 'model'"
49- assert gpt_model ["api_model_type" ] == "llm" , "api_model_type should be 'llm'"
50- assert gpt_model ["model_type" ] == "llm" , "model_type should be 'llm'"
51- assert gpt_model ["provider_id" ] == "openai" , "provider_id should be 'openai'"
48+ assert llm_model ["type" ] == "model" , "type should be 'model'"
49+ assert llm_model ["api_model_type" ] == "llm" , "api_model_type should be 'llm'"
50+ assert llm_model ["model_type" ] == "llm" , "model_type should be 'llm'"
51+ assert llm_model ["provider_id" ] == "openai" , "provider_id should be 'openai'"
5252 assert (
53- gpt_model ["provider_resource_id" ] == model
53+ llm_model ["provider_resource_id" ] == model
5454 ), "provider_resource_id should be 'gpt-4o-mini'"
5555 assert (
56- gpt_model ["identifier" ] == f"openai/{ model } "
56+ llm_model ["identifier" ] == f"openai/{ model } "
5757 ), "identifier should be 'openai/gpt-4o-mini'"
58+
59+
60+ @then ("The body of the response has proper shield structure" )
61+ def check_shield_structure (context : Context ) -> None :
62+ """Check that the first shield has the correct structure and required fields."""
63+ response_json = context .response .json ()
64+ assert response_json is not None , "Response is not valid JSON"
65+
66+ assert "shields" in response_json , "Response missing 'shields' field"
67+ shields = response_json ["shields" ]
68+ assert len (shields ) > 0 , "Response has empty list of shields"
69+
70+ # Find first shield
71+ found_shield = None
72+ for shield in shields :
73+ if shield .get ("type" ) == "shield" :
74+ found_shield = shield
75+ break
76+
77+ assert found_shield is not None , "No LLM model found in response"
78+
79+ # Validate structure and values
80+ assert found_shield ["type" ] == "shield" , "type should be 'model'"
81+ assert (
82+ found_shield ["provider_id" ] == "llama-guard"
83+ ), "provider_id should be 'llama-guard'"
84+ assert (
85+ found_shield ["provider_resource_id" ] == "llama-guard-shield"
86+ ), "provider_resource_id should be 'llama-guard-shield'"
87+ assert (
88+ found_shield ["identifier" ] == "llama-guard-shield"
89+ ), "identifier should be 'llama-guard-shield'"
0 commit comments