Skip to content

Commit

Permalink
Merge pull request #800 from aws-solutions/feature/v7.0.0
Browse files Browse the repository at this point in the history
Update to version v7.0.0
  • Loading branch information
abhirpat authored Jan 23, 2025
2 parents a334225 + f2271b1 commit 909958f
Show file tree
Hide file tree
Showing 295 changed files with 114,146 additions and 41,434 deletions.
8 changes: 8 additions & 0 deletions .nightswatch/functional/files/import-fail-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
"q": [
"Can I have a question but no answer?"
]
},
{
"a": "Questions/Utterances with over 140 Characters cannot be imported",
"type": "qna",
"qid": "QuestionCharLimit.001",
"q": [
"What will happen if I try to import a .json and/or excel (.xlsx) file containing a question/utterance with over 140 characters like this one?"
]
}
]
}
Binary file modified .nightswatch/functional/files/import-fail.xlsx
Binary file not shown.
2 changes: 1 addition & 1 deletion .nightswatch/functional/helpers/website_model/edit_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ def rebuild_lex(self) -> str:
self.select_sub_menu()
self.operator.select_id(REBUILD_LEX_ID, click=True)

success_status = self.operator.wait_for_element_by_id(REBUILD_LEX_SUCCESS_ID, delay=360).text
success_status = self.operator.wait_for_element_by_id(REBUILD_LEX_SUCCESS_ID, delay=600).text
self.operator.select_id(REBUILD_LEX_CLOSE_ID, click=True)
time.sleep(1)
return success_status
Expand Down
39 changes: 32 additions & 7 deletions .nightswatch/functional/helpers/website_model/settings_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
BEDROCK_GUARDRAIL_VERSION_ID = 'BEDROCK_GUARDRAIL_VERSION'
BEDROCK_GUARDRAIL_SUBGROUP_ID = 'text_generation_guardrail_subgroup'

PREPROCESS_GUARDRAIL_IDENTIFIER_ID = 'PREPROCESS_GUARDRAIL_IDENTIFIER'
PREPROCESS_GUARDRAIL_VERSION_ID = 'PREPROCESS_GUARDRAIL_VERSION'

POSTPROCESS_GUARDRAIL_IDENTIFIER_ID = 'POSTPROCESS_GUARDRAIL_IDENTIFIER'
POSTPROCESS_GUARDRAIL_VERSION_ID = 'POSTPROCESS_GUARDRAIL_VERSION'

class SettingsPage:
"""
Class representing a Settings Page.
Expand Down Expand Up @@ -332,7 +338,7 @@ def disable_llm_disambiguation(self):

return self.save_settings()

def enable_bedrock_guardrail(self, region, guardrail_identifier, guardrail_version):
def enable_bedrock_guardrail(self, region, guardrail_identifier, guardrail_version, selector='bedrock'):
"""
Enables the Bedrock guardrail for functional tests based on the nightswatch or local environment.
Expand All @@ -347,7 +353,11 @@ def enable_bedrock_guardrail(self, region, guardrail_identifier, guardrail_versi
'us-east-1': ('6wptcgn6mi7x', 2),
'us-west-2': ('nnbn5202wy5g', 2),
'eu-west-2': ('jsj81qgv3ky5', 2),
'ap-northeast-1': ('672yn8u1u3v5', 1)
'ap-northeast-1': ('672yn8u1u3v5', 1),
'ap-southeast-1': ('9svj21mhvizz', 1),
'ap-southeast-2': ('8t3dz616x886', 1),
'ca-central-1': ('vci2abppnly8', 1),
'eu-central-1': ('kxzczv00h33w', 1),
}

if os.getenv('NIGHTSWATCH_TEST_DIR'):
Expand All @@ -357,10 +367,25 @@ def enable_bedrock_guardrail(self, region, guardrail_identifier, guardrail_versi
if not guardrail_identifier or not guardrail_version:
return self.save_settings()

get_guardrail_identifier = self.operator.select_id(BEDROCK_GUARDRAIL_IDENTIFIER_ID)
valid_selectors = ['bedrock', 'preprocess', 'postprocess']

if selector not in valid_selectors:
raise ValueError(f"Invalid selector. Must be one of {valid_selectors}")

selector_id = BEDROCK_GUARDRAIL_IDENTIFIER_ID
selector_version_id = BEDROCK_GUARDRAIL_VERSION_ID

if selector == 'preprocess':
selector_id = PREPROCESS_GUARDRAIL_IDENTIFIER_ID
selector_version_id = PREPROCESS_GUARDRAIL_VERSION_ID
if selector == 'postprocess':
selector_id = POSTPROCESS_GUARDRAIL_IDENTIFIER_ID
selector_version_id = POSTPROCESS_GUARDRAIL_VERSION_ID

get_guardrail_identifier = self.operator.select_id(selector_id)
self.__set_element_value(get_guardrail_identifier, guardrail_identifier)

get_guardrail_version = self.operator.select_id(BEDROCK_GUARDRAIL_VERSION_ID)
get_guardrail_version = self.operator.select_id(selector_version_id)
self.__set_element_value(get_guardrail_version, guardrail_version)

return self.save_settings()
Expand Down Expand Up @@ -482,12 +507,12 @@ def enable_kb_advanced(self, knowledge_base_model) -> str:

if knowledge_base_model.startswith('anthropic'):
self.__set_element_value(kb_search_type, 'HYBRID')
self.__set_element_value(kb_max_results, 3)
self.__set_element_value(kb_model_params, '{"temperature": 0.3, "maxTokens": 245, "topP": 0.9, "top_k": 240 }')
self.__set_element_value(kb_max_results, 4)
self.__set_element_value(kb_model_params, '{"temperature": 0.1, "maxTokens": 300, "topP": 0.9, "top_k": 240 }')
else:
self.__set_element_value(kb_search_type, 'HYBRID')
self.__set_element_value(kb_max_results, 5)
self.__set_element_value(kb_model_params, '{"temperature": 0.1, "maxTokens": 264, "topP": 0.9 }')
self.__set_element_value(kb_model_params, '{"temperature": 0.1, "maxTokens": 300, "topP": 0.9 }')


return self.save_settings()
Expand Down
12 changes: 12 additions & 0 deletions .nightswatch/functional/question_bank/guardrail_question.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"qna": [
{
"a": "The credit card is 1111-1111-1111-1111",
"type": "qna",
"qid": "Guardrail.001",
"q": [
"Is their a credit card number stored in your database?"
]
}
]
}
Loading

0 comments on commit 909958f

Please sign in to comment.