Skip to content

Commit

Permalink
simplify calls and bring back in line with latest naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
DGaffney committed Aug 27, 2024
1 parent 2eb3faf commit 1d03987
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions app/lib/smooch_nlu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,10 @@ def update_keywords(language, keywords, keyword, operation, doc_id, context)
}
if operation == 'add' && !keywords.include?(keyword)
keywords << keyword
alegre_operation = 'post'
alegre_params = common_alegre_params.merge({ text: keyword, models: ALEGRE_MODELS_AND_THRESHOLDS.keys })
Bot::Alegre.get_sync_raw_params(alegre_params, "text") if alegre_operation && alegre_params
Bot::Alegre.get_sync_with_params(common_alegre_params.merge({ text: keyword, models: ALEGRE_MODELS_AND_THRESHOLDS.keys }), "text")
elsif operation == 'remove'
keywords -= [keyword]
alegre_operation = 'delete'
alegre_params = common_alegre_params.merge({ quiet: true })
Bot::Alegre.request_delete_from_raw(alegre_params, "text") if alegre_operation && alegre_params
Bot::Alegre.request_delete_from_raw(common_alegre_params.merge({ quiet: true }), "text")
end
keywords
end
Expand Down Expand Up @@ -91,7 +87,7 @@ def self.alegre_matches_from_message(message, language, context, alegre_result_k
language: language,
}.merge(context)
}
response = Bot::Alegre.get_sync_raw_params(params, "text")
response = Bot::Alegre.get_sync_with_params(params, "text")

# One approach would be to take the option that has the most matches
# Unfortunately this approach is influenced by the number of keywords per option
Expand Down

0 comments on commit 1d03987

Please sign in to comment.