most-client 1.0.42__py3-none-any.whl → 1.0.44__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
@@ -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, TagsCondition
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
most/async_catalog.py ADDED
@@ -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
most/async_glossary.py CHANGED
@@ -6,13 +6,27 @@ from .types import GlossaryNGram
6
6
 
7
7
  class AsyncGlossary(object):
8
8
  def __init__(self, client: AsyncMostClient):
9
+ super(AsyncGlossary, self).__init__()
9
10
  self.client = client
10
11
 
11
- async def add_ngram(self, ngram: GlossaryNGram):
12
- pass
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])
13
18
 
14
19
  async def list_ngrams(self) -> List[GlossaryNGram]:
15
- return []
20
+ resp = await self.client.get(f"/{self.client.client_id}/glossary")
21
+ return self.client.retort.load(resp.json(), List[GlossaryNGram])
16
22
 
17
- async def del_ngram(self, ngram_id: str):
18
- pass
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
most/catalog.py ADDED
@@ -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
most/glossary.py CHANGED
@@ -6,13 +6,27 @@ from .types import GlossaryNGram
6
6
 
7
7
  class Glossary(object):
8
8
  def __init__(self, client: MostClient):
9
+ super(Glossary, self).__init__()
9
10
  self.client = client
10
11
 
11
- def add_ngram(self, ngram: GlossaryNGram):
12
- pass
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])
13
18
 
14
19
  def list_ngrams(self) -> List[GlossaryNGram]:
15
- return []
20
+ resp = self.client.get(f"/{self.client.client_id}/glossary")
21
+ return self.client.retort.load(resp.json(), List[GlossaryNGram])
16
22
 
17
- def del_ngram(self, ngram_id: str):
18
- pass
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
most/types.py CHANGED
@@ -131,8 +131,18 @@ class Dialog(DataClassJsonMixin):
131
131
  @dataclass_json
132
132
  @dataclass
133
133
  class GlossaryNGram(DataClassJsonMixin):
134
- pronunciation: List[str]
135
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]
136
146
  id: Optional[str] = None
137
147
 
138
148
 
@@ -193,6 +203,13 @@ def is_valid_objectid(oid: str) -> bool:
193
203
  return bool(re.fullmatch(r"^[0-9a-fA-F]{24}$", oid))
194
204
 
195
205
 
206
+ def is_valid_english_word(text: str) -> bool:
207
+ """
208
+ Returns True if the text starts with a letter and contains only English letters and digits.
209
+ """
210
+ return bool(re.fullmatch(r"[A-Za-z][A-Za-z0-9]*", text))
211
+
212
+
196
213
  def is_valid_id(smth_id: Optional[str]) -> bool:
197
214
  if smth_id is None:
198
215
  return False
@@ -200,4 +217,4 @@ def is_valid_id(smth_id: Optional[str]) -> bool:
200
217
  if smth_id.startswith("most-"):
201
218
  smth_id = smth_id[5:]
202
219
 
203
- return is_valid_objectid(smth_id)
220
+ return is_valid_objectid(smth_id) or is_valid_english_word(smth_id)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: most-client
3
- Version: 1.0.42
3
+ Version: 1.0.44
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,20 @@
1
+ most/__init__.py,sha256=ZA2n_h824tfGd5tFl3RsD0noUyv_T08fBoBxMEgxmzs,548
2
+ most/_constrants.py,sha256=SlHKcBoXwe_sPzk8tdbb7lqhQz-Bfo__FhSoeFWodZE,217
3
+ most/api.py,sha256=-DZK8TZ7_OdgUZTknqLW27i8YigXKM33W0vjr8b92gE,19401
4
+ most/async_api.py,sha256=RJkdQGuNJ9s-PuyHbcuVqGmp_GN5ry8bWbVzi8k4ed0,20696
5
+ most/async_catalog.py,sha256=LgQ5zghQtDMnqq-WjmRHqZkqcdixZnHtmoRaVv74VKM,1059
6
+ most/async_glossary.py,sha256=nehgkQvqENxT5vnmMiRLSWgD0jFr2Hzs7yqNZfC9ahs,1281
7
+ most/async_searcher.py,sha256=C0zViW20K7OhKO1BzBZktTbMJYBBvor3uK6LAHZTxz0,2238
8
+ most/async_trainer_api.py,sha256=99rED8RjnOn8VezeEgrTgoVfQrO7DdmOE2Jajumno2g,1052
9
+ most/catalog.py,sha256=XFu-pZdPyxyBcLDl9O3yiYvESXUolXTm0jsQKrQlHxc,985
10
+ most/glossary.py,sha256=64ld6cyvBe8jYW7OR1AVDoEPEAif5PFYu0Hgyng3Gkg,1195
11
+ most/score_calculation.py,sha256=vLtGqXrR43xZhGjrH5dpQZfWX1q3s74LvTaHn-SKBAg,3254
12
+ most/search_types.py,sha256=GFwXaDJV4qI_gaFZToLMHoYH-JXVfIVwfVTgJ7RDWoY,7211
13
+ most/searcher.py,sha256=9UdiSlScsE6EPc6RpK8xkRLeB5gHNxgPQpXTJ17i3lQ,2135
14
+ most/trainer_api.py,sha256=ZwOv4mhROfY97n6i7IY_ZpafsuNRazOqMBAf2dh708k,992
15
+ most/types.py,sha256=7o8uqhQd8FbO7H50TMJPbSIG4VyyX-LumWYRlHeqwgg,5343
16
+ most_client-1.0.44.dist-info/METADATA,sha256=yZy3T34ZtdnW-C28iBLyf0kTEjKq0tA6-Wdha3gRF74,1027
17
+ most_client-1.0.44.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
18
+ most_client-1.0.44.dist-info/top_level.txt,sha256=2g5fk02LKkM1hV3pVVti_LQ60TToLBcR2zQ3JEKGVk8,5
19
+ most_client-1.0.44.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
20
+ most_client-1.0.44.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.7.1)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,18 +0,0 @@
1
- most/__init__.py,sha256=UPx7vJhrRrSNsROGFJQr6-7Lw55qit0z-PIORw_HHFg,366
2
- most/_constrants.py,sha256=SlHKcBoXwe_sPzk8tdbb7lqhQz-Bfo__FhSoeFWodZE,217
3
- most/api.py,sha256=-DZK8TZ7_OdgUZTknqLW27i8YigXKM33W0vjr8b92gE,19401
4
- most/async_api.py,sha256=RJkdQGuNJ9s-PuyHbcuVqGmp_GN5ry8bWbVzi8k4ed0,20696
5
- most/async_glossary.py,sha256=kYb-6lptBJuBSHL1-dIPIEeT5RKuUkzyCAJWmKoZ7ec,408
6
- most/async_searcher.py,sha256=C0zViW20K7OhKO1BzBZktTbMJYBBvor3uK6LAHZTxz0,2238
7
- most/async_trainer_api.py,sha256=99rED8RjnOn8VezeEgrTgoVfQrO7DdmOE2Jajumno2g,1052
8
- most/glossary.py,sha256=EO6TNJThqimU_gs7zN87JX0QKkSXbLtojPox57SL4XE,369
9
- most/score_calculation.py,sha256=vLtGqXrR43xZhGjrH5dpQZfWX1q3s74LvTaHn-SKBAg,3254
10
- most/search_types.py,sha256=GFwXaDJV4qI_gaFZToLMHoYH-JXVfIVwfVTgJ7RDWoY,7211
11
- most/searcher.py,sha256=9UdiSlScsE6EPc6RpK8xkRLeB5gHNxgPQpXTJ17i3lQ,2135
12
- most/trainer_api.py,sha256=ZwOv4mhROfY97n6i7IY_ZpafsuNRazOqMBAf2dh708k,992
13
- most/types.py,sha256=mxE2KbvP88TzI6s6Aw_6JkV4uQXXEGG_hM310QOG-bo,4909
14
- most_client-1.0.42.dist-info/METADATA,sha256=iF1o_VepUfy-s1rJZw-BcF0S5Rq2QpdK1goJwFRfsdI,1027
15
- most_client-1.0.42.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
16
- most_client-1.0.42.dist-info/top_level.txt,sha256=2g5fk02LKkM1hV3pVVti_LQ60TToLBcR2zQ3JEKGVk8,5
17
- most_client-1.0.42.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
18
- most_client-1.0.42.dist-info/RECORD,,