most-client 1.0.41__tar.gz → 1.0.43__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 (27) hide show
  1. {most_client-1.0.41/most_client.egg-info → most_client-1.0.43}/PKG-INFO +1 -1
  2. {most_client-1.0.41 → most_client-1.0.43}/most/__init__.py +6 -1
  3. {most_client-1.0.41 → most_client-1.0.43}/most/api.py +9 -3
  4. {most_client-1.0.41 → most_client-1.0.43}/most/async_api.py +8 -3
  5. most_client-1.0.43/most/async_catalog.py +28 -0
  6. most_client-1.0.43/most/async_glossary.py +32 -0
  7. most_client-1.0.43/most/catalog.py +28 -0
  8. most_client-1.0.43/most/glossary.py +32 -0
  9. {most_client-1.0.41 → most_client-1.0.43}/most/search_types.py +7 -1
  10. {most_client-1.0.41 → most_client-1.0.43}/most/types.py +31 -0
  11. {most_client-1.0.41 → most_client-1.0.43/most_client.egg-info}/PKG-INFO +1 -1
  12. {most_client-1.0.41 → most_client-1.0.43}/most_client.egg-info/SOURCES.txt +4 -0
  13. {most_client-1.0.41 → most_client-1.0.43}/setup.py +1 -1
  14. {most_client-1.0.41 → most_client-1.0.43}/MANIFEST.in +0 -0
  15. {most_client-1.0.41 → most_client-1.0.43}/README.md +0 -0
  16. {most_client-1.0.41 → most_client-1.0.43}/most/_constrants.py +0 -0
  17. {most_client-1.0.41 → most_client-1.0.43}/most/async_searcher.py +0 -0
  18. {most_client-1.0.41 → most_client-1.0.43}/most/async_trainer_api.py +0 -0
  19. {most_client-1.0.41 → most_client-1.0.43}/most/score_calculation.py +0 -0
  20. {most_client-1.0.41 → most_client-1.0.43}/most/searcher.py +0 -0
  21. {most_client-1.0.41 → most_client-1.0.43}/most/trainer_api.py +0 -0
  22. {most_client-1.0.41 → most_client-1.0.43}/most_client.egg-info/dependency_links.txt +0 -0
  23. {most_client-1.0.41 → most_client-1.0.43}/most_client.egg-info/requires.txt +0 -0
  24. {most_client-1.0.41 → most_client-1.0.43}/most_client.egg-info/top_level.txt +0 -0
  25. {most_client-1.0.41 → most_client-1.0.43}/most_client.egg-info/zip-safe +0 -0
  26. {most_client-1.0.41 → most_client-1.0.43}/requirements.txt +0 -0
  27. {most_client-1.0.41 → most_client-1.0.43}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: most-client
3
- Version: 1.0.41
3
+ Version: 1.0.43
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
@@ -4,4 +4,9 @@ from .trainer_api import Trainer
4
4
  from .async_trainer_api import AsyncTrainer
5
5
  from .searcher import MostSearcher
6
6
  from .async_searcher import AsyncMostClient
7
- from .search_types import SearchParams, IDCondition, ChannelsCondition, DurationCondition, ResultsCondition, StoredInfoCondition
7
+ from .search_types import SearchParams, IDCondition, ChannelsCondition, DurationCondition, ResultsCondition, StoredInfoCondition, TagsCondition
8
+ from .glossary import Glossary
9
+ from .async_glossary import AsyncGlossary
10
+ from .catalog import Catalog
11
+ from .async_catalog import AsyncCatalog
12
+ from .types import GlossaryNGram, Item
@@ -3,7 +3,7 @@ import os
3
3
  import uuid
4
4
  from datetime import datetime, timezone
5
5
  from pathlib import Path
6
- from typing import Dict, List, Optional, Union
6
+ from typing import Dict, List, Optional, Union, Literal
7
7
  import json5
8
8
  import httpx
9
9
  from adaptix import Retort, loader
@@ -361,14 +361,20 @@ class MostClient(object):
361
361
  resp = self.get(f"/{self.client_id}/audio/{audio_id}/model/{self.model_id}/text")
362
362
  return self.retort.load(resp.json(), Result)
363
363
 
364
- def fetch_dialog(self, audio_id) -> DialogResult:
364
+ def fetch_dialog(self, audio_id,
365
+ transcribator_name: Optional[Literal["GroundTruth"]] = None) -> DialogResult:
365
366
  if not is_valid_id(self.model_id):
366
367
  raise RuntimeError("Please choose valid model to apply. [try list_models()]")
367
368
 
368
369
  if not is_valid_id(audio_id):
369
370
  raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
370
371
 
371
- resp = self.get(f"/{self.client_id}/audio/{audio_id}/model/{self.model_id}/dialog")
372
+ params = {}
373
+ if transcribator_name is not None:
374
+ params["transcribator_name"] = transcribator_name
375
+
376
+ resp = self.get(f"/{self.client_id}/audio/{audio_id}/model/{self.model_id}/dialog",
377
+ params=params)
372
378
  return self.retort.load(resp.json(), DialogResult)
373
379
 
374
380
  def update_dialog(self, audio_id, dialog: Dialog) -> DialogResult:
@@ -3,7 +3,7 @@ import os
3
3
  import uuid
4
4
  from datetime import datetime, timezone
5
5
  from pathlib import Path
6
- from typing import Dict, List, Optional, Union
6
+ from typing import Dict, List, Optional, Union, Literal
7
7
  import httpx
8
8
  import json5
9
9
  from adaptix import Retort, loader
@@ -374,14 +374,19 @@ class AsyncMostClient(object):
374
374
  resp = await self.get(f"/{self.client_id}/audio/{audio_id}/model/{self.model_id}/text")
375
375
  return self.retort.load(resp.json(), Result)
376
376
 
377
- async def fetch_dialog(self, audio_id) -> DialogResult:
377
+ async def fetch_dialog(self, audio_id,
378
+ transcribator_name: Optional[Literal["GroundTruth"]] = None) -> DialogResult:
378
379
  if not is_valid_id(self.model_id):
379
380
  raise RuntimeError("Please choose valid model to apply. [try list_models()]")
380
381
 
381
382
  if not is_valid_id(audio_id):
382
383
  raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
383
384
 
384
- resp = await self.get(f"/{self.client_id}/audio/{audio_id}/model/{self.model_id}/dialog")
385
+ params = {}
386
+ if transcribator_name is not None:
387
+ params["transcribator_name"] = transcribator_name
388
+ resp = await self.get(f"/{self.client_id}/audio/{audio_id}/model/{self.model_id}/dialog",
389
+ params=params)
385
390
  return self.retort.load(resp.json(), DialogResult)
386
391
 
387
392
  async def update_dialog(self, audio_id, dialog: Dialog) -> DialogResult:
@@ -0,0 +1,28 @@
1
+ from typing import List
2
+
3
+ from .async_api import AsyncMostClient
4
+ from .types import Item
5
+
6
+
7
+ class AsyncCatalog(object):
8
+ def __init__(self, client: AsyncMostClient):
9
+ super(AsyncCatalog, self).__init__()
10
+ self.client = client
11
+
12
+ async def add_items(self, items: List[Item] | Item) -> List[Item]:
13
+ if not isinstance(items, list):
14
+ items = [items]
15
+ resp = await self.client.post(f"/{self.client.client_id}/upload_items",
16
+ json=[item.to_dict() for item in items])
17
+ return self.client.retort.load(resp.json(), List[Item])
18
+
19
+ async def list_items(self) -> List[Item]:
20
+ resp = await self.client.get(f"/{self.client.client_id}/items")
21
+ return self.client.retort.load(resp.json(), List[Item])
22
+
23
+ async def delete_items(self, item_ids: List[str]):
24
+ if not isinstance(item_ids, list):
25
+ item_ids = [item_ids]
26
+ await self.client.post(f"/{self.client.client_id}/delete_items",
27
+ json=item_ids)
28
+ return self
@@ -0,0 +1,32 @@
1
+ from typing import List
2
+
3
+ from .async_api import AsyncMostClient
4
+ from .types import GlossaryNGram
5
+
6
+
7
+ class AsyncGlossary(object):
8
+ def __init__(self, client: AsyncMostClient):
9
+ super(AsyncGlossary, self).__init__()
10
+ self.client = client
11
+
12
+ async def add_ngrams(self, ngrams: List[GlossaryNGram] | GlossaryNGram) -> List[GlossaryNGram]:
13
+ if not isinstance(ngrams, list):
14
+ ngrams = [ngrams]
15
+ resp = await self.client.post(f"/{self.client.client_id}/upload_glossary",
16
+ json=[ngram.to_dict() for ngram in ngrams])
17
+ return self.client.retort.load(resp.json(), List[GlossaryNGram])
18
+
19
+ async def list_ngrams(self) -> List[GlossaryNGram]:
20
+ resp = await self.client.get(f"/{self.client.client_id}/glossary")
21
+ return self.client.retort.load(resp.json(), List[GlossaryNGram])
22
+
23
+ async def del_ngrams(self, ngram_ids: List[str] | str):
24
+ if not isinstance(ngram_ids, list):
25
+ ngram_ids = [ngram_ids]
26
+ await self.client.post(f"/{self.client.client_id}/delete_glossary_ngrams",
27
+ json=ngram_ids)
28
+ return self
29
+
30
+ async def drop(self):
31
+ await self.client.post(f"/{self.client.client_id}/delete_glossary")
32
+ return self
@@ -0,0 +1,28 @@
1
+ from typing import List
2
+
3
+ from .api import MostClient
4
+ from .types import Item
5
+
6
+
7
+ class Catalog(object):
8
+ def __init__(self, client: MostClient):
9
+ super(Catalog, self).__init__()
10
+ self.client = client
11
+
12
+ def add_items(self, items: List[Item] | Item) -> List[Item]:
13
+ if not isinstance(items, list):
14
+ items = [items]
15
+ resp = self.client.post(f"/{self.client.client_id}/upload_items",
16
+ json=[item.to_dict() for item in items])
17
+ return self.client.retort.load(resp.json(), List[Item])
18
+
19
+ def list_items(self) -> List[Item]:
20
+ resp = self.client.get(f"/{self.client.client_id}/items")
21
+ return self.client.retort.load(resp.json(), List[Item])
22
+
23
+ def delete_items(self, item_ids: List[str]):
24
+ if not isinstance(item_ids, list):
25
+ item_ids = [item_ids]
26
+ self.client.post(f"/{self.client.client_id}/delete_items",
27
+ json=item_ids)
28
+ return self
@@ -0,0 +1,32 @@
1
+ from typing import List
2
+
3
+ from .api import MostClient
4
+ from .types import GlossaryNGram
5
+
6
+
7
+ class Glossary(object):
8
+ def __init__(self, client: MostClient):
9
+ super(Glossary, self).__init__()
10
+ self.client = client
11
+
12
+ def add_ngrams(self, ngrams: List[GlossaryNGram] | GlossaryNGram) -> List[GlossaryNGram]:
13
+ if not isinstance(ngrams, list):
14
+ ngrams = [ngrams]
15
+ resp = self.client.post(f"/{self.client.client_id}/upload_glossary",
16
+ json=[ngram.to_dict() for ngram in ngrams])
17
+ return self.client.retort.load(resp.json(), List[GlossaryNGram])
18
+
19
+ def list_ngrams(self) -> List[GlossaryNGram]:
20
+ resp = self.client.get(f"/{self.client.client_id}/glossary")
21
+ return self.client.retort.load(resp.json(), List[GlossaryNGram])
22
+
23
+ def del_ngrams(self, ngram_ids: List[str] | str):
24
+ if not isinstance(ngram_ids, list):
25
+ ngram_ids = [ngram_ids]
26
+ self.client.post(f"/{self.client.client_id}/delete_glossary_ngrams",
27
+ json=ngram_ids)
28
+ return self
29
+
30
+ def drop(self):
31
+ self.client.post(f"/{self.client.client_id}/delete_glossary")
32
+ return self
@@ -1,5 +1,5 @@
1
1
  from dataclasses import dataclass, field
2
- from typing import List, Optional
2
+ from typing import List, Optional, Literal
3
3
  from dataclasses_json import DataClassJsonMixin, dataclass_json
4
4
 
5
5
 
@@ -10,12 +10,14 @@ class IDCondition(DataClassJsonMixin):
10
10
  in_set: Optional[List[str]] = None
11
11
  greater_than: Optional[str] = None
12
12
  less_than: Optional[str] = None
13
+ type: Literal["IDCondition"] = "IDCondition"
13
14
 
14
15
 
15
16
  @dataclass_json
16
17
  @dataclass
17
18
  class ChannelsCondition(DataClassJsonMixin):
18
19
  equal: Optional[int] = None
20
+ type: Literal["ChannelsCondition"] = "ChannelsCondition"
19
21
 
20
22
 
21
23
  @dataclass_json
@@ -23,12 +25,14 @@ class ChannelsCondition(DataClassJsonMixin):
23
25
  class DurationCondition(DataClassJsonMixin):
24
26
  greater_than: Optional[int] = None
25
27
  less_than: Optional[int] = None
28
+ type: Literal["DurationCondition"] = "DurationCondition"
26
29
 
27
30
 
28
31
  @dataclass_json
29
32
  @dataclass
30
33
  class TagsCondition(DataClassJsonMixin):
31
34
  in_set: Optional[List[str]] = None
35
+ type: Literal["TagsCondition"] = "TagsCondition"
32
36
 
33
37
 
34
38
  @dataclass_json
@@ -40,6 +44,7 @@ class StoredInfoCondition(DataClassJsonMixin):
40
44
  ends_with: Optional[str] = None
41
45
  greater_than: Optional[int | str | float] = None
42
46
  less_than: Optional[int | str | float] = None
47
+ type: Literal["StoredInfoCondition"] = "StoredInfoCondition"
43
48
 
44
49
 
45
50
  @dataclass_json
@@ -52,6 +57,7 @@ class ResultsCondition(DataClassJsonMixin):
52
57
  score_in_set: Optional[List[int]] = None
53
58
  score_greater_than: Optional[int] = None
54
59
  score_less_than: Optional[int] = None
60
+ type: Literal["ResultsCondition"] = "ResultsCondition"
55
61
 
56
62
  def create_from(self, client,
57
63
  column: str, subcolumn: str,
@@ -114,6 +114,37 @@ class Dialog(DataClassJsonMixin):
114
114
  return ''.join([segment.to_text()
115
115
  for segment in self.segments])
116
116
 
117
+ def to_raw_text(self):
118
+ return ' '.join([segment.text
119
+ for segment in self.segments])
120
+
121
+ def to_raw_speaker_text(self, speaker):
122
+ return ' '.join([segment.text
123
+ for segment in self.segments
124
+ if segment.speaker == speaker])
125
+
126
+ def get_speaker_names(self):
127
+ return list(set([segment.speaker
128
+ for segment in self.segments]))
129
+
130
+
131
+ @dataclass_json
132
+ @dataclass
133
+ class GlossaryNGram(DataClassJsonMixin):
134
+ original: List[str]
135
+ pronunciation: List[str]
136
+ weight: float = 2
137
+ id: Optional[str] = None
138
+
139
+
140
+ @dataclass_json
141
+ @dataclass
142
+ class Item(DataClassJsonMixin):
143
+ title: str
144
+ pronunciation: str
145
+ metadata: Dict[str, str]
146
+ id: Optional[str] = None
147
+
117
148
 
118
149
  @dataclass_json
119
150
  @dataclass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: most-client
3
- Version: 1.0.41
3
+ Version: 1.0.43
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
@@ -6,8 +6,12 @@ most/__init__.py
6
6
  most/_constrants.py
7
7
  most/api.py
8
8
  most/async_api.py
9
+ most/async_catalog.py
10
+ most/async_glossary.py
9
11
  most/async_searcher.py
10
12
  most/async_trainer_api.py
13
+ most/catalog.py
14
+ most/glossary.py
11
15
  most/score_calculation.py
12
16
  most/search_types.py
13
17
  most/searcher.py
@@ -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.41',
11
+ version='1.0.43',
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',
File without changes
File without changes
File without changes