Guest User

lex_runtime

a guest
Apr 15th, 2022
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. def lex_extend_slots(new_labels):
  2.     print('entering lex model...')
  3.     lex = boto3.client('lex-models')
  4.     slot_name = 'keysDb'
  5.     intent_name = 'searchKeys'
  6.     bot_name = 'photosBot'
  7.     res = lex.get_slot_type(
  8.         name = slot_name,
  9.         version = '$LATEST'
  10.     )
  11.     current_labels = res['enumerationValues']
  12.     latest_checksum = res['checksum']
  13.     arr = [x['value'] for x in current_labels]
  14.     labels = arr + new_labels
  15.     print('arry: ', arr)
  16.     print('new_labels', new_labels)
  17.     print('labels in lex: ', labels)
  18.     labels = list(set(labels))
  19.     enumerationList = [{'value': label, 'synonyms': []} for label in labels]
  20.     print('getting ready to push enum..: ', enumerationList)
  21.     res_slot = lex.put_slot_type(
  22.         name = slot_name,
  23.         description = 'updated slots...',
  24.         enumerationValues = enumerationList,
  25.         valueSelectionStrategy = 'TOP_RESOLUTION',
  26.     )
  27.     res_build_intent = lex.create_intent_version(
  28.         name = intent_name
  29.     )
  30.     res_build_bot = lex.create_bot_version(
  31.         name = bot_name,
  32.         checksum = latest_checksum
  33.     )
  34.     return current_labels
Add Comment
Please, Sign In to add comment