most-client 1.0.17__py3-none-any.whl → 1.0.19__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
most/api.py CHANGED
@@ -17,7 +17,7 @@ from most.types import (
17
17
  Script,
18
18
  StoredAudioData,
19
19
  Text,
20
- is_valid_id,
20
+ is_valid_id, SearchParams,
21
21
  )
22
22
 
23
23
 
@@ -241,12 +241,19 @@ class MostClient(object):
241
241
  resp = self.get(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/dialog")
242
242
  return self.retort.load(resp.json(), DialogResult)
243
243
 
244
- def export(self, audio_ids: List[str]) -> str:
244
+ def export(self, audio_ids: List[str],
245
+ aggregated_by: Optional[str] = None,
246
+ aggregation_title: Optional[str] = None) -> str:
247
+ if aggregation_title is None:
248
+ aggregation_title = aggregated_by
249
+
245
250
  if not is_valid_id(self.model_id):
246
251
  raise RuntimeError("Please choose valid model to apply. [try list_models()]")
247
252
 
248
253
  resp = self.get(f"https://api.the-most.ai/api/external/{self.client_id}/model/{self.model_id}/export",
249
- params={'audio_ids': ','.join(audio_ids)})
254
+ params={'audio_ids': ','.join(audio_ids),
255
+ 'aggregated_by': aggregated_by,
256
+ 'aggregation_title': aggregation_title})
250
257
  return resp.url
251
258
 
252
259
  def store_info(self,
@@ -289,3 +296,24 @@ class MostClient(object):
289
296
  audio = AudioSegment.from_file(io.BytesIO(resp.content),
290
297
  format=format)
291
298
  return audio
299
+
300
+ def index_audio(self, audio_id: str) -> None:
301
+ resp = self.post(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/indexing")
302
+ if resp.status_code >= 400:
303
+ raise RuntimeError("Audio can't be indexed")
304
+ return None
305
+
306
+ def search(self,
307
+ query: str,
308
+ filter: SearchParams,
309
+ limit: int = 10) -> List[Audio]:
310
+ resp = self.post(f"https://api.the-most.ai/api/external/{self.client_id}/model/{self.model_id}/search",
311
+ json={
312
+ "query": query,
313
+ "filter": filter.to_dict(),
314
+ "limit": limit,
315
+ })
316
+ if resp.status_code >= 400:
317
+ raise RuntimeError("Audio can't be indexed")
318
+ audio_list = resp.json()
319
+ return self.retort.load(audio_list, List[Audio])
most/async_api.py CHANGED
@@ -17,7 +17,7 @@ from most.types import (
17
17
  Script,
18
18
  StoredAudioData,
19
19
  Text,
20
- is_valid_id,
20
+ is_valid_id, SearchParams,
21
21
  )
22
22
 
23
23
 
@@ -250,12 +250,19 @@ class AsyncMostClient(object):
250
250
  resp = await self.get(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/dialog")
251
251
  return self.retort.load(resp.json(), DialogResult)
252
252
 
253
- async def export(self, audio_ids: List[str]) -> str:
253
+ async def export(self, audio_ids: List[str],
254
+ aggregated_by: Optional[str] = None,
255
+ aggregation_title: Optional[str] = None) -> str:
256
+ if aggregation_title is None:
257
+ aggregation_title = aggregated_by
258
+
254
259
  if not is_valid_id(self.model_id):
255
260
  raise RuntimeError("Please choose valid model to apply. [try list_models()]")
256
261
 
257
262
  resp = await self.get(f"https://api.the-most.ai/api/external/{self.client_id}/model/{self.model_id}/export",
258
- params={'audio_ids': ','.join(audio_ids)})
263
+ params={'audio_ids': ','.join(audio_ids),
264
+ "aggregated_by": aggregated_by,
265
+ "aggregation_title": aggregation_title})
259
266
  return resp.next_request.url
260
267
 
261
268
  async def store_info(self,
@@ -294,3 +301,24 @@ class AsyncMostClient(object):
294
301
  audio = AudioSegment.from_file(io.BytesIO(resp.content),
295
302
  format=format)
296
303
  return audio
304
+
305
+ async def index_audio(self, audio_id: str) -> None:
306
+ resp = await self.post(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/indexing")
307
+ if resp.status_code >= 400:
308
+ raise RuntimeError("Audio can't be indexed")
309
+ return None
310
+
311
+ async def search(self,
312
+ query: str,
313
+ filter: SearchParams,
314
+ limit: int = 10) -> List[Audio]:
315
+ resp = await self.post(f"https://api.the-most.ai/api/external/{self.client_id}/model/{self.model_id}/search",
316
+ json={
317
+ "query": query,
318
+ "filter": filter.to_dict(),
319
+ "limit": limit,
320
+ })
321
+ if resp.status_code >= 400:
322
+ raise RuntimeError("Audio can't be indexed")
323
+ audio_list = resp.json()
324
+ return self.retort.load(audio_list, List[Audio])
most/types.py CHANGED
@@ -113,6 +113,32 @@ class DialogResult(DataClassJsonMixin):
113
113
  results: Optional[List[ColumnResult]]
114
114
 
115
115
 
116
+ @dataclass_json
117
+ @dataclass
118
+ class StoredInfoCondition(DataClassJsonMixin):
119
+ key: str
120
+ match: Optional[str] = None
121
+ starts_with: Optional[str] = None
122
+ ends_with: Optional[str] = None
123
+
124
+
125
+ @dataclass_json
126
+ @dataclass
127
+ class ResultsCondition(DataClassJsonMixin):
128
+ column: str
129
+ subcolumn: str
130
+ score_greater_than: Optional[int] = None
131
+ score_less_than: Optional[int] = None
132
+
133
+
134
+ @dataclass_json
135
+ @dataclass
136
+ class SearchParams(DataClassJsonMixin):
137
+ must: List[StoredInfoCondition | ResultsCondition]
138
+ should: List[StoredInfoCondition | ResultsCondition]
139
+ must_not: List[StoredInfoCondition | ResultsCondition]
140
+
141
+
116
142
  def is_valid_objectid(oid: str) -> bool:
117
143
  """
118
144
  Check if a given string is a valid MongoDB ObjectId (24-character hex).
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: most-client
3
- Version: 1.0.17
3
+ Version: 1.0.19
4
4
  Summary: Most AI API for https://the-most.ai
5
5
  Home-page: https://github.com/the-most-ai/most-client
6
6
  Author: George Kasparyants
@@ -0,0 +1,9 @@
1
+ most/__init__.py,sha256=62uFFeM_1VVR83K3bTYWK3PEoqnmFCy9aWYerQ6U4Ds,67
2
+ most/api.py,sha256=fn5Husx-uayQ2MR_I7S1YA9QiCHc7fSFLTIzWqyAJc0,13046
3
+ most/async_api.py,sha256=D4sM9zo7EN5vfoMuI2-FsdNwpht0nLuRej0o4DY5smc,13875
4
+ most/types.py,sha256=M6KZiy0OurFCHSnJnnqrkwmsCjTyrq7nsICIfAhLo-A,3455
5
+ most_client-1.0.19.dist-info/METADATA,sha256=jUYmnk-Qx5LM5vGUiKOLZY8ZA57ZSf4pxVZeJH0ous4,1027
6
+ most_client-1.0.19.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
7
+ most_client-1.0.19.dist-info/top_level.txt,sha256=2g5fk02LKkM1hV3pVVti_LQ60TToLBcR2zQ3JEKGVk8,5
8
+ most_client-1.0.19.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
9
+ most_client-1.0.19.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- most/__init__.py,sha256=62uFFeM_1VVR83K3bTYWK3PEoqnmFCy9aWYerQ6U4Ds,67
2
- most/api.py,sha256=yRGL7lZ5qBWSdaclz-t7fZAJ_k1zu0YbHptUX9uaVdM,11772
3
- most/async_api.py,sha256=xRZPsb64i1d_U0PWIJKC_7fPMjZRPfamvvtSMyFlA5E,12505
4
- most/types.py,sha256=apUz6FHFAHWJNVvRh57wVQk5DFw2XKnLLhkAyWgtvfw,2825
5
- most_client-1.0.17.dist-info/METADATA,sha256=51ED0zyrdWP5OqTlY31mCcXRpBmk39y1BXNWJYx2BMY,1027
6
- most_client-1.0.17.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
7
- most_client-1.0.17.dist-info/top_level.txt,sha256=2g5fk02LKkM1hV3pVVti_LQ60TToLBcR2zQ3JEKGVk8,5
8
- most_client-1.0.17.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
9
- most_client-1.0.17.dist-info/RECORD,,