most-client 1.0.36__py3-none-any.whl → 1.0.37__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/__init__.py CHANGED
@@ -2,3 +2,6 @@ from .api import MostClient
2
2
  from .async_api import AsyncMostClient
3
3
  from .trainer_api import Trainer
4
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
most/api.py CHANGED
@@ -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
 
@@ -384,7 +384,8 @@ class MostClient(object):
384
384
 
385
385
  def export(self, audio_ids: List[str],
386
386
  aggregated_by: Optional[str] = None,
387
- aggregation_title: Optional[str] = None) -> str:
387
+ aggregation_title: Optional[str] = None,
388
+ modify_scores: bool = False) -> str:
388
389
  if aggregation_title is None:
389
390
  aggregation_title = aggregated_by
390
391
 
@@ -394,12 +395,13 @@ class MostClient(object):
394
395
  resp = self.get(f"/{self.client_id}/model/{self.model_id}/export",
395
396
  params={'audio_ids': ','.join(audio_ids),
396
397
  'aggregated_by': aggregated_by,
397
- 'aggregation_title': aggregation_title})
398
+ 'aggregation_title': aggregation_title,
399
+ 'modify_scores': modify_scores})
398
400
  return resp.url
399
401
 
400
402
  def store_info(self,
401
403
  audio_id: str,
402
- data: Dict[str, str]):
404
+ data: Dict[str, str]) -> StoredAudioData:
403
405
  if not is_valid_id(audio_id):
404
406
  raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
405
407
 
@@ -409,7 +411,7 @@ class MostClient(object):
409
411
  })
410
412
  return self.retort.load(resp.json(), StoredAudioData)
411
413
 
412
- def fetch_info(self, audio_id: str) -> Dict[str, str]:
414
+ def fetch_info(self, audio_id: str) -> StoredAudioData:
413
415
  if not is_valid_id(audio_id):
414
416
  raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
415
417
 
@@ -446,21 +448,6 @@ class MostClient(object):
446
448
  raise RuntimeError("Audio can't be indexed")
447
449
  return None
448
450
 
449
- def search(self,
450
- query: str,
451
- filter: SearchParams,
452
- limit: int = 10) -> List[Audio]:
453
- resp = self.post(f"/{self.client_id}/model/{self.model_id}/search",
454
- json={
455
- "query": query,
456
- "filter": filter.to_dict(),
457
- "limit": limit,
458
- })
459
- if resp.status_code >= 400:
460
- raise RuntimeError("Audio can't be indexed")
461
- audio_list = resp.json()
462
- return self.retort.load(audio_list, List[Audio])
463
-
464
451
  def get_usage(self,
465
452
  start_dt: datetime,
466
453
  end_dt: datetime):
most/async_api.py CHANGED
@@ -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
 
@@ -394,7 +394,8 @@ class AsyncMostClient(object):
394
394
 
395
395
  async def export(self, audio_ids: List[str],
396
396
  aggregated_by: Optional[str] = None,
397
- aggregation_title: Optional[str] = None) -> str:
397
+ aggregation_title: Optional[str] = None,
398
+ modify_scores: bool = False) -> str:
398
399
  if aggregation_title is None:
399
400
  aggregation_title = aggregated_by
400
401
 
@@ -404,19 +405,20 @@ class AsyncMostClient(object):
404
405
  resp = await self.get(f"/{self.client_id}/model/{self.model_id}/export",
405
406
  params={'audio_ids': ','.join(audio_ids),
406
407
  "aggregated_by": aggregated_by,
407
- "aggregation_title": aggregation_title})
408
+ "aggregation_title": aggregation_title,
409
+ "modify_scores": modify_scores})
408
410
  return resp.next_request.url
409
411
 
410
412
  async def store_info(self,
411
413
  audio_id: str,
412
- data: Dict[str, str]):
414
+ data: Dict[str, str]) -> StoredAudioData:
413
415
  resp = await self.post(f"/{self.client_id}/audio/{audio_id}/info",
414
416
  json={
415
417
  "data": data,
416
418
  })
417
419
  return self.retort.load(resp.json(), StoredAudioData)
418
420
 
419
- async def fetch_info(self, audio_id: str) -> Dict[str, str]:
421
+ async def fetch_info(self, audio_id: str) -> StoredAudioData:
420
422
  if not is_valid_id(audio_id):
421
423
  raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
422
424
  resp = await self.get(f"/{self.client_id}/audio/{audio_id}/info")
@@ -452,21 +454,6 @@ class AsyncMostClient(object):
452
454
  raise RuntimeError("Audio can't be indexed")
453
455
  return None
454
456
 
455
- async def search(self,
456
- query: str,
457
- filter: SearchParams,
458
- limit: int = 10) -> List[Audio]:
459
- resp = await self.post(f"/{self.client_id}/model/{self.model_id}/search",
460
- json={
461
- "query": query,
462
- "filter": filter.to_dict(),
463
- "limit": limit,
464
- })
465
- if resp.status_code >= 400:
466
- raise RuntimeError("Audio can't be indexed")
467
- audio_list = resp.json()
468
- return self.retort.load(audio_list, List[Audio])
469
-
470
457
  async def get_usage(self,
471
458
  start_dt: datetime,
472
459
  end_dt: datetime):
most/async_searcher.py ADDED
@@ -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])
most/search_types.py ADDED
@@ -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)
most/searcher.py ADDED
@@ -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])
most/types.py CHANGED
@@ -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.36
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,16 @@
1
+ most/__init__.py,sha256=yoPKMxjZYAzrVqZ7l9rN0Skh0HPuttPX7ub0wlZMby4,351
2
+ most/_constrants.py,sha256=SlHKcBoXwe_sPzk8tdbb7lqhQz-Bfo__FhSoeFWodZE,217
3
+ most/api.py,sha256=fwVmqyuCGhALQFOsgRW7IyX7ELY4sePPA5uHFRprCKQ,19052
4
+ most/async_api.py,sha256=Kgy4sHZMLr4FD3dOop1BwfrNHeg5n7Ny0v7ZiYv1_ig,20219
5
+ most/async_searcher.py,sha256=C0zViW20K7OhKO1BzBZktTbMJYBBvor3uK6LAHZTxz0,2238
6
+ most/async_trainer_api.py,sha256=99rED8RjnOn8VezeEgrTgoVfQrO7DdmOE2Jajumno2g,1052
7
+ most/score_calculation.py,sha256=1XU1LfIH5LSCwAbAaKkr-EjH5qOTXrJKOUvhCCawka4,1054
8
+ most/search_types.py,sha256=fuuIkWEuYPTqljl-EMcoNgL5SOiHOVx9j5iH46ecVp8,1857
9
+ most/searcher.py,sha256=9UdiSlScsE6EPc6RpK8xkRLeB5gHNxgPQpXTJ17i3lQ,2135
10
+ most/trainer_api.py,sha256=ZwOv4mhROfY97n6i7IY_ZpafsuNRazOqMBAf2dh708k,992
11
+ most/types.py,sha256=og32qmGnUGTvC0qTH2wzLnhYKeFTIcEmkpIDnclmhYM,5226
12
+ most_client-1.0.37.dist-info/METADATA,sha256=VdEUqqsSRBSfiCdpwYh3bGdKcundkUeHReMTjCbHd2s,1047
13
+ most_client-1.0.37.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
14
+ most_client-1.0.37.dist-info/top_level.txt,sha256=2g5fk02LKkM1hV3pVVti_LQ60TToLBcR2zQ3JEKGVk8,5
15
+ most_client-1.0.37.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
16
+ most_client-1.0.37.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (79.0.1)
2
+ Generator: setuptools (80.4.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,13 +0,0 @@
1
- most/__init__.py,sha256=b0EXXaPA4kmt-FtGXKRWZr7SCwjipMLcpC6uT5WRIdY,144
2
- most/_constrants.py,sha256=SlHKcBoXwe_sPzk8tdbb7lqhQz-Bfo__FhSoeFWodZE,217
3
- most/api.py,sha256=vg7zYsRebQjVOmTLRQE6jqmK-zG1j-k-KMN68gzFpk4,19538
4
- most/async_api.py,sha256=iRIjHLVkrjBKimlVmz5Ev_pPNB0dwCa5QgKRy1rCF3c,20753
5
- most/async_trainer_api.py,sha256=99rED8RjnOn8VezeEgrTgoVfQrO7DdmOE2Jajumno2g,1052
6
- most/score_calculation.py,sha256=1XU1LfIH5LSCwAbAaKkr-EjH5qOTXrJKOUvhCCawka4,1054
7
- most/trainer_api.py,sha256=ZwOv4mhROfY97n6i7IY_ZpafsuNRazOqMBAf2dh708k,992
8
- most/types.py,sha256=KP34dzS8ayQUhToIxwxTL9O8-7TZz1ySfJzA3ZNGIGw,4921
9
- most_client-1.0.36.dist-info/METADATA,sha256=GnPH3grUAX3tLjJKswpB1_vDWtZ8i59zX0miAxZTRx8,1027
10
- most_client-1.0.36.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
11
- most_client-1.0.36.dist-info/top_level.txt,sha256=2g5fk02LKkM1hV3pVVti_LQ60TToLBcR2zQ3JEKGVk8,5
12
- most_client-1.0.36.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
13
- most_client-1.0.36.dist-info/RECORD,,