Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def lex_extend_slots(new_labels):
- print('entering lex model...')
- lex = boto3.client('lex-models')
- slot_name = 'keysDb'
- intent_name = 'searchKeys'
- bot_name = 'photosBot'
- res = lex.get_slot_type(
- name = slot_name,
- version = '$LATEST'
- )
- current_labels = res['enumerationValues']
- latest_checksum = res['checksum']
- arr = [x['value'] for x in current_labels]
- labels = arr + new_labels
- print('arry: ', arr)
- print('new_labels', new_labels)
- print('labels in lex: ', labels)
- labels = list(set(labels))
- enumerationList = [{'value': label, 'synonyms': []} for label in labels]
- print('getting ready to push enum..: ', enumerationList)
- res_slot = lex.put_slot_type(
- name = slot_name,
- description = 'updated slots...',
- enumerationValues = enumerationList,
- valueSelectionStrategy = 'TOP_RESOLUTION',
- )
- res_build_intent = lex.create_intent_version(
- name = intent_name
- )
- res_build_bot = lex.create_bot_version(
- name = bot_name,
- checksum = latest_checksum
- )
- return current_labels
Add Comment
Please, Sign In to add comment