Skip to content

Commit 5ccce05

Browse files
committed
Release: v6.1.0
- Added support for `reqlExpressions` on recommended item segments
1 parent 348aeaf commit 5ccce05

14 files changed

+282
-2
lines changed

recombee_api_client/api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def __get_base_uri(options: dict, region: str) -> str:
105105

106106
@staticmethod
107107
def __get_http_headers(additional_headers: dict = None) -> dict:
108-
headers = {"User-Agent": "recombee-python-api-client/6.0.0"}
108+
headers = {"User-Agent": "recombee-python-api-client/6.1.0"}
109109
if additional_headers:
110110
headers.update(additional_headers)
111111
return headers

recombee_api_client/api_requests/recommend_item_segments_to_item.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,69 @@ class RecommendItemSegmentsToItem(Request):
101101
:param return_ab_group: If there is a custom AB-testing running, return the name of the group to which the request belongs.
102102
103103
104+
:param reql_expressions: A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment.
105+
106+
This can be used to compute additional properties of the recommended Item Segments.
107+
108+
109+
The keys are the names of the expressions, and the values are the actual ReQL expressions.
110+
111+
112+
Example request:
113+
114+
```json
115+
116+
E{lb}
117+
118+
"reqlExpressions": E{lb}
119+
120+
"countItems": "size(segment_items(\"categories\", 'segmentId'))"
121+
E{rb}
122+
E{rb}
123+
124+
```
125+
126+
127+
Example response:
128+
129+
```json
130+
131+
E{lb}
132+
133+
"recommId": "a7ac55a4-8d6e-4f19-addc-abac4164d8a8",
134+
135+
"recomms":
136+
137+
[
138+
139+
E{lb}
140+
141+
"id": "category-fantasy-books",
142+
143+
"reqlEvaluations": E{lb}
144+
145+
"countItems": 486
146+
E{rb}
147+
E{rb},
148+
149+
E{lb}
150+
151+
"id": "category-sci-fi-costumes",
152+
153+
"reqlEvaluations": E{lb}
154+
155+
"countItems": 19
156+
E{rb}
157+
E{rb}
158+
159+
],
160+
161+
"numberNextRecommsCalls": 0
162+
E{rb}
163+
164+
```
165+
166+
104167
"""
105168

106169
def __init__(
@@ -115,6 +178,7 @@ def __init__(
115178
logic: Logic = DEFAULT,
116179
expert_settings: dict = DEFAULT,
117180
return_ab_group: bool = DEFAULT,
181+
reql_expressions: dict = DEFAULT,
118182
):
119183
super().__init__(
120184
path="/recomms/items/%s/item-segments/" % (item_id),
@@ -132,6 +196,7 @@ def __init__(
132196
self.logic = logic
133197
self.expert_settings = expert_settings
134198
self.return_ab_group = return_ab_group
199+
self.reql_expressions = reql_expressions
135200

136201
def get_body_parameters(self) -> dict:
137202
"""
@@ -154,6 +219,8 @@ def get_body_parameters(self) -> dict:
154219
p["expertSettings"] = serialize_to_json(self.expert_settings)
155220
if self.return_ab_group is not DEFAULT:
156221
p["returnAbGroup"] = serialize_to_json(self.return_ab_group)
222+
if self.reql_expressions is not DEFAULT:
223+
p["reqlExpressions"] = serialize_to_json(self.reql_expressions)
157224

158225
return p
159226

recombee_api_client/api_requests/recommend_item_segments_to_item_segment.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,69 @@ class RecommendItemSegmentsToItemSegment(Request):
100100
:param return_ab_group: If there is a custom AB-testing running, return the name of the group to which the request belongs.
101101
102102
103+
:param reql_expressions: A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment.
104+
105+
This can be used to compute additional properties of the recommended Item Segments.
106+
107+
108+
The keys are the names of the expressions, and the values are the actual ReQL expressions.
109+
110+
111+
Example request:
112+
113+
```json
114+
115+
E{lb}
116+
117+
"reqlExpressions": E{lb}
118+
119+
"countItems": "size(segment_items(\"categories\", 'segmentId'))"
120+
E{rb}
121+
E{rb}
122+
123+
```
124+
125+
126+
Example response:
127+
128+
```json
129+
130+
E{lb}
131+
132+
"recommId": "a7ac55a4-8d6e-4f19-addc-abac4164d8a8",
133+
134+
"recomms":
135+
136+
[
137+
138+
E{lb}
139+
140+
"id": "category-fantasy-books",
141+
142+
"reqlEvaluations": E{lb}
143+
144+
"countItems": 486
145+
E{rb}
146+
E{rb},
147+
148+
E{lb}
149+
150+
"id": "category-sci-fi-costumes",
151+
152+
"reqlEvaluations": E{lb}
153+
154+
"countItems": 19
155+
E{rb}
156+
E{rb}
157+
158+
],
159+
160+
"numberNextRecommsCalls": 0
161+
E{rb}
162+
163+
```
164+
165+
103166
"""
104167

105168
def __init__(
@@ -114,6 +177,7 @@ def __init__(
114177
logic: Logic = DEFAULT,
115178
expert_settings: dict = DEFAULT,
116179
return_ab_group: bool = DEFAULT,
180+
reql_expressions: dict = DEFAULT,
117181
):
118182
super().__init__(
119183
path="/recomms/item-segments/item-segments/",
@@ -131,6 +195,7 @@ def __init__(
131195
self.logic = logic
132196
self.expert_settings = expert_settings
133197
self.return_ab_group = return_ab_group
198+
self.reql_expressions = reql_expressions
134199

135200
def get_body_parameters(self) -> dict:
136201
"""
@@ -154,6 +219,8 @@ def get_body_parameters(self) -> dict:
154219
p["expertSettings"] = serialize_to_json(self.expert_settings)
155220
if self.return_ab_group is not DEFAULT:
156221
p["returnAbGroup"] = serialize_to_json(self.return_ab_group)
222+
if self.reql_expressions is not DEFAULT:
223+
p["reqlExpressions"] = serialize_to_json(self.reql_expressions)
157224

158225
return p
159226

recombee_api_client/api_requests/recommend_item_segments_to_user.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,69 @@ class RecommendItemSegmentsToUser(Request):
7070
:param return_ab_group: If there is a custom AB-testing running, return the name of the group to which the request belongs.
7171
7272
73+
:param reql_expressions: A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment.
74+
75+
This can be used to compute additional properties of the recommended Item Segments.
76+
77+
78+
The keys are the names of the expressions, and the values are the actual ReQL expressions.
79+
80+
81+
Example request:
82+
83+
```json
84+
85+
E{lb}
86+
87+
"reqlExpressions": E{lb}
88+
89+
"countItems": "size(segment_items(\"categories\", 'segmentId'))"
90+
E{rb}
91+
E{rb}
92+
93+
```
94+
95+
96+
Example response:
97+
98+
```json
99+
100+
E{lb}
101+
102+
"recommId": "a7ac55a4-8d6e-4f19-addc-abac4164d8a8",
103+
104+
"recomms":
105+
106+
[
107+
108+
E{lb}
109+
110+
"id": "category-fantasy-books",
111+
112+
"reqlEvaluations": E{lb}
113+
114+
"countItems": 486
115+
E{rb}
116+
E{rb},
117+
118+
E{lb}
119+
120+
"id": "category-sci-fi-costumes",
121+
122+
"reqlEvaluations": E{lb}
123+
124+
"countItems": 19
125+
E{rb}
126+
E{rb}
127+
128+
],
129+
130+
"numberNextRecommsCalls": 0
131+
E{rb}
132+
133+
```
134+
135+
73136
"""
74137

75138
def __init__(
@@ -83,6 +146,7 @@ def __init__(
83146
logic: Logic = DEFAULT,
84147
expert_settings: dict = DEFAULT,
85148
return_ab_group: bool = DEFAULT,
149+
reql_expressions: dict = DEFAULT,
86150
):
87151
super().__init__(
88152
path="/recomms/users/%s/item-segments/" % (user_id),
@@ -99,6 +163,7 @@ def __init__(
99163
self.logic = logic
100164
self.expert_settings = expert_settings
101165
self.return_ab_group = return_ab_group
166+
self.reql_expressions = reql_expressions
102167

103168
def get_body_parameters(self) -> dict:
104169
"""
@@ -120,6 +185,8 @@ def get_body_parameters(self) -> dict:
120185
p["expertSettings"] = serialize_to_json(self.expert_settings)
121186
if self.return_ab_group is not DEFAULT:
122187
p["returnAbGroup"] = serialize_to_json(self.return_ab_group)
188+
if self.reql_expressions is not DEFAULT:
189+
p["reqlExpressions"] = serialize_to_json(self.reql_expressions)
123190

124191
return p
125192

recombee_api_client/api_requests/search_item_segments.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,69 @@ class SearchItemSegments(Request):
7171
:param return_ab_group: If there is a custom AB-testing running, return the name of the group to which the request belongs.
7272
7373
74+
:param reql_expressions: A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment.
75+
76+
This can be used to compute additional properties of the recommended Item Segments.
77+
78+
79+
The keys are the names of the expressions, and the values are the actual ReQL expressions.
80+
81+
82+
Example request:
83+
84+
```json
85+
86+
E{lb}
87+
88+
"reqlExpressions": E{lb}
89+
90+
"countItems": "size(segment_items(\"categories\", 'segmentId'))"
91+
E{rb}
92+
E{rb}
93+
94+
```
95+
96+
97+
Example response:
98+
99+
```json
100+
101+
E{lb}
102+
103+
"recommId": "a7ac55a4-8d6e-4f19-addc-abac4164d8a8",
104+
105+
"recomms":
106+
107+
[
108+
109+
E{lb}
110+
111+
"id": "category-fantasy-books",
112+
113+
"reqlEvaluations": E{lb}
114+
115+
"countItems": 486
116+
E{rb}
117+
E{rb},
118+
119+
E{lb}
120+
121+
"id": "category-sci-fi-costumes",
122+
123+
"reqlEvaluations": E{lb}
124+
125+
"countItems": 19
126+
E{rb}
127+
E{rb}
128+
129+
],
130+
131+
"numberNextRecommsCalls": 0
132+
E{rb}
133+
134+
```
135+
136+
74137
"""
75138

76139
def __init__(
@@ -85,6 +148,7 @@ def __init__(
85148
logic: Logic = DEFAULT,
86149
expert_settings: dict = DEFAULT,
87150
return_ab_group: bool = DEFAULT,
151+
reql_expressions: dict = DEFAULT,
88152
):
89153
super().__init__(
90154
path="/search/users/%s/item-segments/" % (user_id),
@@ -102,6 +166,7 @@ def __init__(
102166
self.logic = logic
103167
self.expert_settings = expert_settings
104168
self.return_ab_group = return_ab_group
169+
self.reql_expressions = reql_expressions
105170

106171
def get_body_parameters(self) -> dict:
107172
"""
@@ -124,6 +189,8 @@ def get_body_parameters(self) -> dict:
124189
p["expertSettings"] = serialize_to_json(self.expert_settings)
125190
if self.return_ab_group is not DEFAULT:
126191
p["returnAbGroup"] = serialize_to_json(self.return_ab_group)
192+
if self.reql_expressions is not DEFAULT:
193+
p["reqlExpressions"] = serialize_to_json(self.reql_expressions)
127194

128195
return p
129196

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
setup(
1212
name="recombee-api-client",
13-
version="6.0.0",
13+
version="6.1.0",
1414
description="Client for Recombee recommendation API",
1515
long_description=long_description,
1616
url="https://github.com/Recombee/python-api-client",

0 commit comments

Comments
 (0)