most-client 1.0.35__tar.gz → 1.0.37__tar.gz

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.
Files changed (24) hide show
  1. {most_client-1.0.35/most_client.egg-info → most_client-1.0.37}/PKG-INFO +2 -1
  2. most_client-1.0.37/most/__init__.py +7 -0
  3. {most_client-1.0.35 → most_client-1.0.37}/most/api.py +19 -20
  4. {most_client-1.0.35 → most_client-1.0.37}/most/async_api.py +19 -20
  5. most_client-1.0.37/most/async_searcher.py +57 -0
  6. most_client-1.0.37/most/search_types.py +59 -0
  7. most_client-1.0.37/most/searcher.py +57 -0
  8. {most_client-1.0.35 → most_client-1.0.37}/most/types.py +18 -28
  9. {most_client-1.0.35 → most_client-1.0.37/most_client.egg-info}/PKG-INFO +2 -1
  10. {most_client-1.0.35 → most_client-1.0.37}/most_client.egg-info/SOURCES.txt +3 -0
  11. {most_client-1.0.35 → most_client-1.0.37}/most_client.egg-info/requires.txt +1 -0
  12. {most_client-1.0.35 → most_client-1.0.37}/requirements.txt +1 -0
  13. {most_client-1.0.35 → most_client-1.0.37}/setup.py +1 -1
  14. most_client-1.0.35/most/__init__.py +0 -4
  15. {most_client-1.0.35 → most_client-1.0.37}/MANIFEST.in +0 -0
  16. {most_client-1.0.35 → most_client-1.0.37}/README.md +0 -0
  17. {most_client-1.0.35 → most_client-1.0.37}/most/_constrants.py +0 -0
  18. {most_client-1.0.35 → most_client-1.0.37}/most/async_trainer_api.py +0 -0
  19. {most_client-1.0.35 → most_client-1.0.37}/most/score_calculation.py +0 -0
  20. {most_client-1.0.35 → most_client-1.0.37}/most/trainer_api.py +0 -0
  21. {most_client-1.0.35 → most_client-1.0.37}/most_client.egg-info/dependency_links.txt +0 -0
  22. {most_client-1.0.35 → most_client-1.0.37}/most_client.egg-info/top_level.txt +0 -0
  23. {most_client-1.0.35 → most_client-1.0.37}/most_client.egg-info/zip-safe +0 -0
  24. {most_client-1.0.35 → most_client-1.0.37}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: most-client
3
- Version: 1.0.35
3
+ Version: 1.0.37
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
@@ -27,6 +27,7 @@ Requires-Dist: tox
27
27
  Requires-Dist: twine
28
28
  Requires-Dist: httpx
29
29
  Requires-Dist: pydub
30
+ Requires-Dist: bson
30
31
  Dynamic: author
31
32
  Dynamic: author-email
32
33
  Dynamic: classifier
@@ -0,0 +1,7 @@
1
+ from .api import MostClient
2
+ from .async_api import AsyncMostClient
3
+ from .trainer_api import Trainer
4
+ from .async_trainer_api import AsyncTrainer
5
+ from .searcher import MostSearcher
6
+ from .async_searcher import AsyncMostClient
7
+ from .search_types import SearchParams, IDCondition, ChannelsCondition, DurationCondition, ResultsCondition, StoredInfoCondition
@@ -18,7 +18,7 @@ from most.types import (
18
18
  Script,
19
19
  StoredAudioData,
20
20
  Text,
21
- is_valid_id, SearchParams, ScriptScoreMapping, Dialog, Usage,
21
+ is_valid_id, ScriptScoreMapping, Dialog, Usage,
22
22
  )
23
23
 
24
24
 
@@ -283,6 +283,18 @@ class MostClient(object):
283
283
  result = self.score_modifier.modify(result)
284
284
  return result
285
285
 
286
+ def transcribe_later(self, audio_id,
287
+ overwrite: bool = False) -> DialogResult:
288
+ if not is_valid_id(self.model_id):
289
+ raise RuntimeError("Please choose valid model to apply. [try list_models()]")
290
+
291
+ if not is_valid_id(audio_id):
292
+ raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
293
+
294
+ resp = self.post(f"/{self.client_id}/audio/{audio_id}/model/{self.model_id}/transcribe_async",
295
+ params={"overwrite": overwrite})
296
+ return self.retort.load(resp.json(), DialogResult)
297
+
286
298
  def apply_later(self, audio_id,
287
299
  modify_scores: bool = False,
288
300
  overwrite: bool = False) -> Result:
@@ -372,7 +384,8 @@ class MostClient(object):
372
384
 
373
385
  def export(self, audio_ids: List[str],
374
386
  aggregated_by: Optional[str] = None,
375
- aggregation_title: Optional[str] = None) -> str:
387
+ aggregation_title: Optional[str] = None,
388
+ modify_scores: bool = False) -> str:
376
389
  if aggregation_title is None:
377
390
  aggregation_title = aggregated_by
378
391
 
@@ -382,12 +395,13 @@ class MostClient(object):
382
395
  resp = self.get(f"/{self.client_id}/model/{self.model_id}/export",
383
396
  params={'audio_ids': ','.join(audio_ids),
384
397
  'aggregated_by': aggregated_by,
385
- 'aggregation_title': aggregation_title})
398
+ 'aggregation_title': aggregation_title,
399
+ 'modify_scores': modify_scores})
386
400
  return resp.url
387
401
 
388
402
  def store_info(self,
389
403
  audio_id: str,
390
- data: Dict[str, str]):
404
+ data: Dict[str, str]) -> StoredAudioData:
391
405
  if not is_valid_id(audio_id):
392
406
  raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
393
407
 
@@ -397,7 +411,7 @@ class MostClient(object):
397
411
  })
398
412
  return self.retort.load(resp.json(), StoredAudioData)
399
413
 
400
- def fetch_info(self, audio_id: str) -> Dict[str, str]:
414
+ def fetch_info(self, audio_id: str) -> StoredAudioData:
401
415
  if not is_valid_id(audio_id):
402
416
  raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
403
417
 
@@ -434,21 +448,6 @@ class MostClient(object):
434
448
  raise RuntimeError("Audio can't be indexed")
435
449
  return None
436
450
 
437
- def search(self,
438
- query: str,
439
- filter: SearchParams,
440
- limit: int = 10) -> List[Audio]:
441
- resp = self.post(f"/{self.client_id}/model/{self.model_id}/search",
442
- json={
443
- "query": query,
444
- "filter": filter.to_dict(),
445
- "limit": limit,
446
- })
447
- if resp.status_code >= 400:
448
- raise RuntimeError("Audio can't be indexed")
449
- audio_list = resp.json()
450
- return self.retort.load(audio_list, List[Audio])
451
-
452
451
  def get_usage(self,
453
452
  start_dt: datetime,
454
453
  end_dt: datetime):
@@ -18,7 +18,7 @@ from most.types import (
18
18
  Script,
19
19
  StoredAudioData,
20
20
  Text,
21
- is_valid_id, SearchParams, ScriptScoreMapping, Dialog, Usage,
21
+ is_valid_id, ScriptScoreMapping, Dialog, Usage,
22
22
  )
23
23
 
24
24
 
@@ -293,6 +293,18 @@ class AsyncMostClient(object):
293
293
  result = self.score_modifier.modify(result)
294
294
  return result
295
295
 
296
+ async def transcribe_later(self, audio_id,
297
+ overwrite: bool = False) -> DialogResult:
298
+ if not is_valid_id(self.model_id):
299
+ raise RuntimeError("Please choose valid model to apply. [try list_models()]")
300
+
301
+ if not is_valid_id(audio_id):
302
+ raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
303
+
304
+ resp = await self.post(f"/{self.client_id}/audio/{audio_id}/model/{self.model_id}/transcribe_async",
305
+ params={"overwrite": overwrite})
306
+ return self.retort.load(resp.json(), DialogResult)
307
+
296
308
  async def apply_later(self, audio_id,
297
309
  modify_scores: bool = False,
298
310
  overwrite: bool = False) -> Result:
@@ -382,7 +394,8 @@ class AsyncMostClient(object):
382
394
 
383
395
  async def export(self, audio_ids: List[str],
384
396
  aggregated_by: Optional[str] = None,
385
- aggregation_title: Optional[str] = None) -> str:
397
+ aggregation_title: Optional[str] = None,
398
+ modify_scores: bool = False) -> str:
386
399
  if aggregation_title is None:
387
400
  aggregation_title = aggregated_by
388
401
 
@@ -392,19 +405,20 @@ class AsyncMostClient(object):
392
405
  resp = await self.get(f"/{self.client_id}/model/{self.model_id}/export",
393
406
  params={'audio_ids': ','.join(audio_ids),
394
407
  "aggregated_by": aggregated_by,
395
- "aggregation_title": aggregation_title})
408
+ "aggregation_title": aggregation_title,
409
+ "modify_scores": modify_scores})
396
410
  return resp.next_request.url
397
411
 
398
412
  async def store_info(self,
399
413
  audio_id: str,
400
- data: Dict[str, str]):
414
+ data: Dict[str, str]) -> StoredAudioData:
401
415
  resp = await self.post(f"/{self.client_id}/audio/{audio_id}/info",
402
416
  json={
403
417
  "data": data,
404
418
  })
405
419
  return self.retort.load(resp.json(), StoredAudioData)
406
420
 
407
- async def fetch_info(self, audio_id: str) -> Dict[str, str]:
421
+ async def fetch_info(self, audio_id: str) -> StoredAudioData:
408
422
  if not is_valid_id(audio_id):
409
423
  raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
410
424
  resp = await self.get(f"/{self.client_id}/audio/{audio_id}/info")
@@ -440,21 +454,6 @@ class AsyncMostClient(object):
440
454
  raise RuntimeError("Audio can't be indexed")
441
455
  return None
442
456
 
443
- async def search(self,
444
- query: str,
445
- filter: SearchParams,
446
- limit: int = 10) -> List[Audio]:
447
- resp = await self.post(f"/{self.client_id}/model/{self.model_id}/search",
448
- json={
449
- "query": query,
450
- "filter": filter.to_dict(),
451
- "limit": limit,
452
- })
453
- if resp.status_code >= 400:
454
- raise RuntimeError("Audio can't be indexed")
455
- audio_list = resp.json()
456
- return self.retort.load(audio_list, List[Audio])
457
-
458
457
  async def get_usage(self,
459
458
  start_dt: datetime,
460
459
  end_dt: datetime):
@@ -0,0 +1,57 @@
1
+ from typing import List, Literal, Optional
2
+ from . import AsyncMostClient
3
+ from .types import Audio
4
+ from .search_types import SearchParams
5
+
6
+
7
+ class AsyncMostSearcher(object):
8
+ def __init__(self, client: AsyncMostClient,
9
+ data_source: Literal["text", "audio"]):
10
+ self.client = client
11
+ self.data_source = data_source
12
+
13
+ async def count(self,
14
+ filter: Optional[SearchParams] = None):
15
+ if filter is None:
16
+ filter = SearchParams()
17
+
18
+ resp = await self.client.get(f"/{self.client.client_id}/{self.data_source}/count",
19
+ params={
20
+ "filter": filter.to_json(),
21
+ })
22
+ if resp.status_code >= 400:
23
+ raise RuntimeError("Audio can't be indexed")
24
+ return resp.json()
25
+
26
+
27
+ async def distinct(self,
28
+ key: str,
29
+ filter: Optional[SearchParams] = None) -> List[str]:
30
+ """
31
+ Distinct values of key.
32
+ :param key: key should be stored in info (fetch_info, store_info)
33
+ :return:
34
+ """
35
+ if filter is None:
36
+ filter = SearchParams()
37
+ resp = await self.client.get(f"/{self.client.client_id}/{self.data_source}/distinct",
38
+ params={"filter": filter.to_json(),
39
+ "key": key})
40
+ if resp.status_code >= 400:
41
+ raise RuntimeError("Key is not valid")
42
+ return resp.json()
43
+
44
+ async def search(self,
45
+ filter: Optional[SearchParams] = None,
46
+ limit: int = 10) -> List[Audio]:
47
+ if filter is None:
48
+ filter = SearchParams()
49
+ resp = await self.client.get(f"/{self.client.client_id}/{self.data_source}/search",
50
+ params={
51
+ "filter": filter.to_json(),
52
+ "limit": limit,
53
+ })
54
+ if resp.status_code >= 400:
55
+ raise RuntimeError("Audio can't be indexed")
56
+ audio_list = resp.json()
57
+ return self.client.retort.load(audio_list, List[Audio])
@@ -0,0 +1,59 @@
1
+ import re
2
+ from dataclasses import dataclass, field
3
+ from datetime import datetime
4
+ from typing import Dict, List, Literal, Optional, Union
5
+
6
+ from bson import ObjectId
7
+ from dataclasses_json import DataClassJsonMixin, dataclass_json
8
+
9
+
10
+ @dataclass_json
11
+ @dataclass
12
+ class IDCondition(DataClassJsonMixin):
13
+ equal: Optional[ObjectId] = None
14
+ in_set: Optional[List[ObjectId]] = None
15
+ greater_than: Optional[ObjectId] = None
16
+ less_than: Optional[ObjectId] = None
17
+
18
+
19
+ @dataclass_json
20
+ @dataclass
21
+ class ChannelsCondition(DataClassJsonMixin):
22
+ equal: Optional[int] = None
23
+
24
+
25
+ @dataclass_json
26
+ @dataclass
27
+ class DurationCondition(DataClassJsonMixin):
28
+ greater_than: Optional[int] = None
29
+ less_than: Optional[int] = None
30
+
31
+
32
+ @dataclass_json
33
+ @dataclass
34
+ class StoredInfoCondition(DataClassJsonMixin):
35
+ key: str
36
+ match: Optional[str] = None
37
+ starts_with: Optional[str] = None
38
+ ends_with: Optional[str] = None
39
+
40
+
41
+ @dataclass_json
42
+ @dataclass
43
+ class ResultsCondition(DataClassJsonMixin):
44
+ column_idx: int
45
+ subcolumn_idx: int
46
+ model_id: str
47
+ score_equal: Optional[int] = None
48
+ score_in_set: Optional[List[int]] = None
49
+ score_greater_than: Optional[int] = None
50
+ score_less_than: Optional[int] = None
51
+
52
+
53
+ @dataclass_json
54
+ @dataclass
55
+ class SearchParams(DataClassJsonMixin):
56
+ must: List[StoredInfoCondition | ResultsCondition | DurationCondition | ChannelsCondition | IDCondition ] = field(default_factory=list)
57
+ should: List[StoredInfoCondition | ResultsCondition | DurationCondition | ChannelsCondition | IDCondition ] = field(default_factory=list)
58
+ must_not: List[StoredInfoCondition | ResultsCondition | DurationCondition | ChannelsCondition | IDCondition ] = field(default_factory=list)
59
+ should_not: List[StoredInfoCondition | ResultsCondition | DurationCondition | ChannelsCondition | IDCondition ] = field(default_factory=list)
@@ -0,0 +1,57 @@
1
+ from typing import List, Literal, Optional
2
+
3
+ from .api import MostClient
4
+ from .search_types import SearchParams
5
+ from .types import Audio, Text
6
+
7
+
8
+ class MostSearcher(object):
9
+ def __init__(self, client: MostClient,
10
+ data_source: Literal["text", "audio"]):
11
+ self.client = client
12
+ self.data_source = data_source
13
+
14
+ def count(self,
15
+ filter: Optional[SearchParams] = None):
16
+ if filter is None:
17
+ filter = SearchParams()
18
+
19
+ resp = self.client.get(f"/{self.client.client_id}/{self.data_source}/count",
20
+ params={
21
+ "filter": filter.to_json(),
22
+ })
23
+ if resp.status_code >= 400:
24
+ raise RuntimeError("Audio can't be indexed")
25
+ return resp.json()
26
+
27
+ def distinct(self,
28
+ key: str,
29
+ filter: Optional[SearchParams] = None) -> List[str]:
30
+ """
31
+ Distinct values of key.
32
+ :param key: key should be stored in info (fetch_info, store_info)
33
+ :return:
34
+ """
35
+ if filter is None:
36
+ filter = SearchParams()
37
+ resp = self.client.get(f"/{self.client.client_id}/{self.data_source}/distinct",
38
+ params={"filter": filter.to_json(),
39
+ "key": key})
40
+ if resp.status_code >= 400:
41
+ raise RuntimeError("Key is not valid")
42
+ return resp.json()
43
+
44
+ def search(self,
45
+ filter: Optional[SearchParams] = None,
46
+ limit: int = 10) -> List[Audio | Text]:
47
+ if filter is None:
48
+ filter = SearchParams()
49
+ resp = self.client.get(f"/{self.client.client_id}/{self.data_source}/search",
50
+ params={
51
+ "filter": filter.to_json(),
52
+ "limit": limit,
53
+ })
54
+ if resp.status_code >= 400:
55
+ raise RuntimeError("Audio can't be indexed")
56
+ audio_list = resp.json()
57
+ return self.client.retort.load(audio_list, List[Audio])
@@ -1,8 +1,8 @@
1
1
  import re
2
2
  from dataclasses import dataclass
3
3
  from datetime import datetime
4
- from typing import Dict, List, Literal, Optional, Union
5
-
4
+ from typing import Dict, List, Literal, Optional
5
+ from .search_types import ResultsCondition
6
6
  from dataclasses_json import DataClassJsonMixin, dataclass_json
7
7
 
8
8
 
@@ -53,6 +53,22 @@ class Column(DataClassJsonMixin):
53
53
  class Script(DataClassJsonMixin):
54
54
  columns: List[Column]
55
55
 
56
+ def create_results_condition(self,
57
+ model_id: str,
58
+ column: str, subcolumn: str,
59
+ score_equal: Optional[int] = None,
60
+ score_greater_than: Optional[int] = None,
61
+ score_less_than: Optional[int] = None) -> ResultsCondition:
62
+
63
+ column_idx = [column.name for column in self.columns].index(column)
64
+ subcolumn_idx = self.columns[column_idx].subcolumns.index(subcolumn)
65
+ return ResultsCondition(model_id=model_id,
66
+ column_idx=column_idx,
67
+ subcolumn_idx=subcolumn_idx,
68
+ score_equal=score_equal,
69
+ score_greater_than=score_greater_than,
70
+ score_less_than=score_less_than)
71
+
56
72
 
57
73
  @dataclass_json
58
74
  @dataclass
@@ -125,32 +141,6 @@ class DialogResult(DataClassJsonMixin):
125
141
  results: Optional[List[ColumnResult]] = None
126
142
 
127
143
 
128
- @dataclass_json
129
- @dataclass
130
- class StoredInfoCondition(DataClassJsonMixin):
131
- key: str
132
- match: Optional[str] = None
133
- starts_with: Optional[str] = None
134
- ends_with: Optional[str] = None
135
-
136
-
137
- @dataclass_json
138
- @dataclass
139
- class ResultsCondition(DataClassJsonMixin):
140
- column: str
141
- subcolumn: str
142
- score_greater_than: Optional[int] = None
143
- score_less_than: Optional[int] = None
144
-
145
-
146
- @dataclass_json
147
- @dataclass
148
- class SearchParams(DataClassJsonMixin):
149
- must: List[StoredInfoCondition | ResultsCondition]
150
- should: List[StoredInfoCondition | ResultsCondition]
151
- must_not: List[StoredInfoCondition | ResultsCondition]
152
-
153
-
154
144
  @dataclass_json
155
145
  @dataclass
156
146
  class HumanFeedback(DataClassJsonMixin):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: most-client
3
- Version: 1.0.35
3
+ Version: 1.0.37
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
@@ -27,6 +27,7 @@ Requires-Dist: tox
27
27
  Requires-Dist: twine
28
28
  Requires-Dist: httpx
29
29
  Requires-Dist: pydub
30
+ Requires-Dist: bson
30
31
  Dynamic: author
31
32
  Dynamic: author-email
32
33
  Dynamic: classifier
@@ -6,8 +6,11 @@ most/__init__.py
6
6
  most/_constrants.py
7
7
  most/api.py
8
8
  most/async_api.py
9
+ most/async_searcher.py
9
10
  most/async_trainer_api.py
10
11
  most/score_calculation.py
12
+ most/search_types.py
13
+ most/searcher.py
11
14
  most/trainer_api.py
12
15
  most/types.py
13
16
  most_client.egg-info/PKG-INFO
@@ -13,3 +13,4 @@ tox
13
13
  twine
14
14
  httpx
15
15
  pydub
16
+ bson
@@ -13,3 +13,4 @@ tox
13
13
  twine
14
14
  httpx
15
15
  pydub
16
+ bson
@@ -8,7 +8,7 @@ with open('requirements.txt', 'r') as f:
8
8
 
9
9
  setup(
10
10
  name='most-client',
11
- version='1.0.35',
11
+ version='1.0.37',
12
12
  python_requires=f'>=3.6',
13
13
  description='Most AI API for https://the-most.ai',
14
14
  url='https://github.com/the-most-ai/most-client',
@@ -1,4 +0,0 @@
1
- from .api import MostClient
2
- from .async_api import AsyncMostClient
3
- from .trainer_api import Trainer
4
- from .async_trainer_api import AsyncTrainer
File without changes
File without changes
File without changes