Skip to content

Commit 979e399

Browse files
committed
Add logic parameter to recommendation endpoints. Use HTTPS as default.
1 parent 1e105e2 commit 979e399

File tree

7 files changed

+45
-16
lines changed

7 files changed

+45
-16
lines changed

lib/recombee_api_client.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ class RecombeeClient
1818
include HTTParty
1919

2020
BATCH_MAX_SIZE = 10000
21-
USER_AGENT = {'User-Agent' => 'recombee-ruby-api-client/2.3.0'}
21+
USER_AGENT = {'User-Agent' => 'recombee-ruby-api-client/2.4.0'}
2222

2323
##
2424
# - +account+ -> Name of your account at Recombee
2525
# - +token+ -> Secret token obtained from Recombee for signing requests
2626
# - +protocol+ -> Default protocol for sending requests. Possible values: 'http', 'https'.
27-
def initialize(account, token, protocol = 'http', options = {})
27+
def initialize(account, token, protocol = 'https', options = {})
2828
@account = account
2929
@token = token
3030
@protocol = protocol

lib/recombee_api_client/api/recommend_items_to_item.rb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module RecombeeApiClient
1414
#The returned items are sorted by relevancy (first item being the most relevant).
1515
#
1616
class RecommendItemsToItem < ApiRequest
17-
attr_reader :item_id, :target_user_id, :count, :user_impact, :filter, :booster, :cascade_create, :scenario, :return_properties, :included_properties, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings, :return_ab_group
17+
attr_reader :item_id, :target_user_id, :count, :filter, :booster, :cascade_create, :scenario, :logic, :return_properties, :included_properties, :user_impact, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings, :return_ab_group
1818
attr_accessor :timeout
1919
attr_accessor :ensure_https
2020

@@ -42,12 +42,15 @@ class RecommendItemsToItem < ApiRequest
4242
# - +count+ -> Number of items to be recommended (N for the top-N recommendation).
4343
#
4444
# * *Optional arguments (given as hash optional)*
45-
# - +userImpact+ -> If *targetUserId* parameter is present, the recommendations are biased towards the user given. Using *userImpact*, you may control this bias. For an extreme case of `userImpact=0.0`, the interactions made by the user are not taken into account at all (with the exception of history-based blacklisting), for `userImpact=1.0`, you'll get user-based recommendation. The default value is `0`.
46-
#
4745
# - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes.
4846
# - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes.
4947
# - +cascadeCreate+ -> If item of given *itemId* or user of given *targetUserId* doesn't exist in the database, it creates the missing entity/entities and returns some (non-personalized) recommendations. This allows for example rotations in the following recommendations for the user of given *targetUserId*, as the user will be already known to the system.
5048
# - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". You can see each scenario in the UI separately, so you can check how well each application performs. The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
49+
# - +logic+ -> Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain (e-commerce, multimedia, fashion ...) and use case.
50+
#See [this section](https://docs.recombee.com/recommendation_logic.html) for list of available logics and other details.
51+
#
52+
#The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
53+
#
5154
# - +returnProperties+ -> With `returnProperties=true`, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used for easy displaying of the recommended items to the user.
5255
#
5356
#Example response:
@@ -104,6 +107,8 @@ class RecommendItemsToItem < ApiRequest
104107
# }
105108
#```
106109
#
110+
# - +userImpact+ -> **Expert option** If *targetUserId* parameter is present, the recommendations are biased towards the given user. Using *userImpact*, you may control this bias. For an extreme case of `userImpact=0.0`, the interactions made by the user are not taken into account at all (with the exception of history-based blacklisting), for `userImpact=1.0`, you'll get user-based recommendation. The default value is `0`.
111+
#
107112
# - +diversity+ -> **Expert option** Real number from [0.0, 1.0] which determines how much mutually dissimilar should the recommended items be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification.
108113
#
109114
# - +minRelevance+ -> **Expert option** If the *targetUserId* is provided: Specifies the threshold of how much relevant must the recommended items be to the user. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend number of items equal to *count* at any cost. If there are not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations to be appended to reach the full *count*. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends items of at least the requested relevancy, and may return less than *count* items when there is not enough data to fulfill it.
@@ -122,13 +127,14 @@ def initialize(item_id, target_user_id, count, optional = {})
122127
@target_user_id = target_user_id
123128
@count = count
124129
optional = normalize_optional(optional)
125-
@user_impact = optional['userImpact']
126130
@filter = optional['filter']
127131
@booster = optional['booster']
128132
@cascade_create = optional['cascadeCreate']
129133
@scenario = optional['scenario']
134+
@logic = optional['logic']
130135
@return_properties = optional['returnProperties']
131136
@included_properties = optional['includedProperties']
137+
@user_impact = optional['userImpact']
132138
@diversity = optional['diversity']
133139
@min_relevance = optional['minRelevance']
134140
@rotation_rate = optional['rotationRate']
@@ -139,7 +145,7 @@ def initialize(item_id, target_user_id, count, optional = {})
139145
@timeout = 3000
140146
@ensure_https = false
141147
@optional.each do |par, _|
142-
fail UnknownOptionalParameter.new(par) unless ["userImpact","filter","booster","cascadeCreate","scenario","returnProperties","includedProperties","diversity","minRelevance","rotationRate","rotationTime","expertSettings","returnAbGroup"].include? par
148+
fail UnknownOptionalParameter.new(par) unless ["filter","booster","cascadeCreate","scenario","logic","returnProperties","includedProperties","userImpact","diversity","minRelevance","rotationRate","rotationTime","expertSettings","returnAbGroup"].include? par
143149
end
144150
end
145151

@@ -153,13 +159,14 @@ def body_parameters
153159
p = Hash.new
154160
p['targetUserId'] = @target_user_id
155161
p['count'] = @count
156-
p['userImpact'] = @optional['userImpact'] if @optional.include? 'userImpact'
157162
p['filter'] = @optional['filter'] if @optional.include? 'filter'
158163
p['booster'] = @optional['booster'] if @optional.include? 'booster'
159164
p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
160165
p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
166+
p['logic'] = @optional['logic'] if @optional.include? 'logic'
161167
p['returnProperties'] = @optional['returnProperties'] if @optional.include? 'returnProperties'
162168
p['includedProperties'] = @optional['includedProperties'] if @optional.include? 'includedProperties'
169+
p['userImpact'] = @optional['userImpact'] if @optional.include? 'userImpact'
163170
p['diversity'] = @optional['diversity'] if @optional.include? 'diversity'
164171
p['minRelevance'] = @optional['minRelevance'] if @optional.include? 'minRelevance'
165172
p['rotationRate'] = @optional['rotationRate'] if @optional.include? 'rotationRate'

lib/recombee_api_client/api/recommend_items_to_user.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module RecombeeApiClient
1414
#The returned items are sorted by relevancy (first item being the most relevant).
1515
#
1616
class RecommendItemsToUser < ApiRequest
17-
attr_reader :user_id, :count, :filter, :booster, :cascade_create, :scenario, :return_properties, :included_properties, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings, :return_ab_group
17+
attr_reader :user_id, :count, :filter, :booster, :cascade_create, :scenario, :logic, :return_properties, :included_properties, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings, :return_ab_group
1818
attr_accessor :timeout
1919
attr_accessor :ensure_https
2020

@@ -28,6 +28,11 @@ class RecommendItemsToUser < ApiRequest
2828
# - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes.
2929
# - +cascadeCreate+ -> If the user does not exist in the database, returns a list of non-personalized recommendations and creates the user in the database. This allows for example rotations in the following recommendations for that user, as the user will be already known to the system.
3030
# - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". You can see each scenario in the UI separately, so you can check how well each application performs. The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
31+
# - +logic+ -> Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain (e-commerce, multimedia, fashion ...) and use case.
32+
#See [this section](https://docs.recombee.com/recommendation_logic.html) for list of available logics and other details.
33+
#
34+
#The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
35+
#
3136
# - +returnProperties+ -> With `returnProperties=true`, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used for easy displaying of the recommended items to the user.
3237
#
3338
#Example response:
@@ -105,6 +110,7 @@ def initialize(user_id, count, optional = {})
105110
@booster = optional['booster']
106111
@cascade_create = optional['cascadeCreate']
107112
@scenario = optional['scenario']
113+
@logic = optional['logic']
108114
@return_properties = optional['returnProperties']
109115
@included_properties = optional['includedProperties']
110116
@diversity = optional['diversity']
@@ -117,7 +123,7 @@ def initialize(user_id, count, optional = {})
117123
@timeout = 3000
118124
@ensure_https = false
119125
@optional.each do |par, _|
120-
fail UnknownOptionalParameter.new(par) unless ["filter","booster","cascadeCreate","scenario","returnProperties","includedProperties","diversity","minRelevance","rotationRate","rotationTime","expertSettings","returnAbGroup"].include? par
126+
fail UnknownOptionalParameter.new(par) unless ["filter","booster","cascadeCreate","scenario","logic","returnProperties","includedProperties","diversity","minRelevance","rotationRate","rotationTime","expertSettings","returnAbGroup"].include? par
121127
end
122128
end
123129

@@ -134,6 +140,7 @@ def body_parameters
134140
p['booster'] = @optional['booster'] if @optional.include? 'booster'
135141
p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
136142
p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
143+
p['logic'] = @optional['logic'] if @optional.include? 'logic'
137144
p['returnProperties'] = @optional['returnProperties'] if @optional.include? 'returnProperties'
138145
p['includedProperties'] = @optional['includedProperties'] if @optional.include? 'includedProperties'
139146
p['diversity'] = @optional['diversity'] if @optional.include? 'diversity'

lib/recombee_api_client/api/recommend_users_to_item.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module RecombeeApiClient
1414
#The returned users are sorted by predicted interest in the item (first user being the most interested).
1515
#
1616
class RecommendUsersToItem < ApiRequest
17-
attr_reader :item_id, :count, :filter, :booster, :cascade_create, :scenario, :return_properties, :included_properties, :diversity, :expert_settings, :return_ab_group
17+
attr_reader :item_id, :count, :filter, :booster, :cascade_create, :scenario, :logic, :return_properties, :included_properties, :diversity, :expert_settings, :return_ab_group
1818
attr_accessor :timeout
1919
attr_accessor :ensure_https
2020

@@ -28,6 +28,11 @@ class RecommendUsersToItem < ApiRequest
2828
# - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes.
2929
# - +cascadeCreate+ -> If item of given *itemId* doesn't exist in the database, it creates the missing item.
3030
# - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". You can see each scenario in the UI separately, so you can check how well each application performs. The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
31+
# - +logic+ -> Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain (e-commerce, multimedia, fashion ...) and use case.
32+
#See [this section](https://docs.recombee.com/recommendation_logic.html) for list of available logics and other details.
33+
#
34+
#The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
35+
#
3136
# - +returnProperties+ -> With `returnProperties=true`, property values of the recommended users are returned along with their IDs in a JSON dictionary. The acquired property values can be used for easy displaying the recommended users.
3237
#
3338
#Example response:
@@ -93,6 +98,7 @@ def initialize(item_id, count, optional = {})
9398
@booster = optional['booster']
9499
@cascade_create = optional['cascadeCreate']
95100
@scenario = optional['scenario']
101+
@logic = optional['logic']
96102
@return_properties = optional['returnProperties']
97103
@included_properties = optional['includedProperties']
98104
@diversity = optional['diversity']
@@ -102,7 +108,7 @@ def initialize(item_id, count, optional = {})
102108
@timeout = 50000
103109
@ensure_https = false
104110
@optional.each do |par, _|
105-
fail UnknownOptionalParameter.new(par) unless ["filter","booster","cascadeCreate","scenario","returnProperties","includedProperties","diversity","expertSettings","returnAbGroup"].include? par
111+
fail UnknownOptionalParameter.new(par) unless ["filter","booster","cascadeCreate","scenario","logic","returnProperties","includedProperties","diversity","expertSettings","returnAbGroup"].include? par
106112
end
107113
end
108114

@@ -119,6 +125,7 @@ def body_parameters
119125
p['booster'] = @optional['booster'] if @optional.include? 'booster'
120126
p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
121127
p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
128+
p['logic'] = @optional['logic'] if @optional.include? 'logic'
122129
p['returnProperties'] = @optional['returnProperties'] if @optional.include? 'returnProperties'
123130
p['includedProperties'] = @optional['includedProperties'] if @optional.include? 'includedProperties'
124131
p['diversity'] = @optional['diversity'] if @optional.include? 'diversity'

lib/recombee_api_client/api/recommend_users_to_user.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module RecombeeApiClient
1414
#The returned users are sorted by similarity (first user being the most similar).
1515
#
1616
class RecommendUsersToUser < ApiRequest
17-
attr_reader :user_id, :count, :filter, :booster, :cascade_create, :scenario, :return_properties, :included_properties, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings, :return_ab_group
17+
attr_reader :user_id, :count, :filter, :booster, :cascade_create, :scenario, :logic, :return_properties, :included_properties, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings, :return_ab_group
1818
attr_accessor :timeout
1919
attr_accessor :ensure_https
2020

@@ -28,6 +28,11 @@ class RecommendUsersToUser < ApiRequest
2828
# - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some users based on the values of their attributes.
2929
# - +cascadeCreate+ -> If the user does not exist in the database, returns a list of non-personalized recommendations and creates the user in the database. This allows for example rotations in the following recommendations for that user, as the user will be already known to the system.
3030
# - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". You can see each scenario in the UI separately, so you can check how well each application performs. The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
31+
# - +logic+ -> Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain (e-commerce, multimedia, fashion ...) and use case.
32+
#See [this section](https://docs.recombee.com/recommendation_logic.html) for list of available logics and other details.
33+
#
34+
#The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
35+
#
3136
# - +returnProperties+ -> With `returnProperties=true`, property values of the recommended users are returned along with their IDs in a JSON dictionary. The acquired property values can be used for easy displaying the recommended users.
3237
#
3338
#Example response:
@@ -99,6 +104,7 @@ def initialize(user_id, count, optional = {})
99104
@booster = optional['booster']
100105
@cascade_create = optional['cascadeCreate']
101106
@scenario = optional['scenario']
107+
@logic = optional['logic']
102108
@return_properties = optional['returnProperties']
103109
@included_properties = optional['includedProperties']
104110
@diversity = optional['diversity']
@@ -111,7 +117,7 @@ def initialize(user_id, count, optional = {})
111117
@timeout = 50000
112118
@ensure_https = false
113119
@optional.each do |par, _|
114-
fail UnknownOptionalParameter.new(par) unless ["filter","booster","cascadeCreate","scenario","returnProperties","includedProperties","diversity","minRelevance","rotationRate","rotationTime","expertSettings","returnAbGroup"].include? par
120+
fail UnknownOptionalParameter.new(par) unless ["filter","booster","cascadeCreate","scenario","logic","returnProperties","includedProperties","diversity","minRelevance","rotationRate","rotationTime","expertSettings","returnAbGroup"].include? par
115121
end
116122
end
117123

@@ -128,6 +134,7 @@ def body_parameters
128134
p['booster'] = @optional['booster'] if @optional.include? 'booster'
129135
p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
130136
p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
137+
p['logic'] = @optional['logic'] if @optional.include? 'logic'
131138
p['returnProperties'] = @optional['returnProperties'] if @optional.include? 'returnProperties'
132139
p['includedProperties'] = @optional['includedProperties'] if @optional.include? 'includedProperties'
133140
p['diversity'] = @optional['diversity'] if @optional.include? 'diversity'

lib/recombee_api_client/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module RecombeeApiClient
2-
VERSION = '2.3.0'
2+
VERSION = '2.4.0'
33
end

0 commit comments

Comments
 (0)