most-client 1.0.10__py3-none-any.whl → 1.0.12__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 +40 -15
- most/async_api.py +38 -15
- most/types.py +16 -0
- {most_client-1.0.10.dist-info → most_client-1.0.12.dist-info}/METADATA +2 -1
- most_client-1.0.12.dist-info/RECORD +9 -0
- most_client-1.0.10.dist-info/RECORD +0 -9
- {most_client-1.0.10.dist-info → most_client-1.0.12.dist-info}/WHEEL +0 -0
- {most_client-1.0.10.dist-info → most_client-1.0.12.dist-info}/top_level.txt +0 -0
- {most_client-1.0.10.dist-info → most_client-1.0.12.dist-info}/zip-safe +0 -0
most/api.py
CHANGED
@@ -2,7 +2,7 @@ from typing import List, Dict
|
|
2
2
|
import json5
|
3
3
|
import requests
|
4
4
|
from adaptix import Retort
|
5
|
-
from most.types import Audio, Result, Script, JobStatus, Text, StoredAudioData
|
5
|
+
from most.types import Audio, Result, Script, JobStatus, Text, StoredAudioData, is_valid_id
|
6
6
|
from pathlib import Path
|
7
7
|
|
8
8
|
|
@@ -144,8 +144,9 @@ class MostClient(object):
|
|
144
144
|
return self.retort.load(audio_list, List[Audio])
|
145
145
|
|
146
146
|
def get_model_script(self) -> Script:
|
147
|
-
if self.model_id
|
148
|
-
raise RuntimeError("Please choose
|
147
|
+
if not is_valid_id(self.model_id):
|
148
|
+
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
149
|
+
|
149
150
|
resp = self.get(f"https://api.the-most.ai/api/external/{self.client_id}/model/{self.model_id}/script")
|
150
151
|
return self.retort.load(resp.json(), Script)
|
151
152
|
|
@@ -155,40 +156,58 @@ class MostClient(object):
|
|
155
156
|
for model in resp.json()]
|
156
157
|
|
157
158
|
def apply(self, audio_id) -> Result:
|
158
|
-
if self.model_id
|
159
|
-
raise RuntimeError("Please choose
|
159
|
+
if not is_valid_id(self.model_id):
|
160
|
+
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
161
|
+
|
162
|
+
if not is_valid_id(audio_id):
|
163
|
+
raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
|
164
|
+
|
160
165
|
resp = self.post(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/apply")
|
161
166
|
return self.retort.load(resp.json(), Result)
|
162
167
|
|
163
168
|
def apply_later(self, audio_id) -> Result:
|
164
|
-
if self.model_id
|
165
|
-
raise RuntimeError("Please choose
|
169
|
+
if not is_valid_id(self.model_id):
|
170
|
+
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
171
|
+
|
172
|
+
if not is_valid_id(audio_id):
|
173
|
+
raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
|
174
|
+
|
166
175
|
resp = self.post(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/apply_async")
|
167
176
|
return self.retort.load(resp.json(), Result)
|
168
177
|
|
169
178
|
def get_job_status(self, audio_id) -> JobStatus:
|
170
|
-
if self.model_id
|
171
|
-
raise RuntimeError("Please choose
|
179
|
+
if not is_valid_id(self.model_id):
|
180
|
+
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
181
|
+
|
182
|
+
if not is_valid_id(audio_id):
|
183
|
+
raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
|
184
|
+
|
172
185
|
resp = self.post(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/apply_status")
|
173
186
|
return self.retort.load(resp.json(), JobStatus)
|
174
187
|
|
175
188
|
def fetch_results(self, audio_id) -> Result:
|
176
|
-
if self.model_id
|
177
|
-
raise RuntimeError("Please choose
|
189
|
+
if not is_valid_id(self.model_id):
|
190
|
+
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
191
|
+
|
192
|
+
if not is_valid_id(audio_id):
|
193
|
+
raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
|
178
194
|
|
179
195
|
resp = self.get(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/results")
|
180
196
|
return self.retort.load(resp.json(), Result)
|
181
197
|
|
182
198
|
def fetch_text(self, audio_id: str) -> Result:
|
183
|
-
if self.model_id
|
184
|
-
raise RuntimeError("Please choose
|
199
|
+
if not is_valid_id(self.model_id):
|
200
|
+
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
201
|
+
|
202
|
+
if not is_valid_id(audio_id):
|
203
|
+
raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
|
185
204
|
|
186
205
|
resp = self.get(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/text")
|
187
206
|
return self.retort.load(resp.json(), Result)
|
188
207
|
|
189
208
|
def export(self, audio_ids: List[str]) -> str:
|
190
|
-
if self.model_id
|
191
|
-
raise RuntimeError("Please choose
|
209
|
+
if not is_valid_id(self.model_id):
|
210
|
+
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
192
211
|
|
193
212
|
resp = self.get(f"https://api.the-most.ai/api/external/{self.client_id}/model/{self.model_id}/export",
|
194
213
|
params={'audio_ids': ','.join(audio_ids)})
|
@@ -197,6 +216,9 @@ class MostClient(object):
|
|
197
216
|
def store_info(self,
|
198
217
|
audio_id: str,
|
199
218
|
data: Dict[str, str]):
|
219
|
+
if not is_valid_id(audio_id):
|
220
|
+
raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
|
221
|
+
|
200
222
|
resp = self.post(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/info",
|
201
223
|
json={
|
202
224
|
"data": data,
|
@@ -204,6 +226,9 @@ class MostClient(object):
|
|
204
226
|
return self.retort.load(resp.json(), StoredAudioData)
|
205
227
|
|
206
228
|
def fetch_info(self, audio_id: str) -> Dict[str, str]:
|
229
|
+
if not is_valid_id(audio_id):
|
230
|
+
raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
|
231
|
+
|
207
232
|
resp = self.get(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/info")
|
208
233
|
return self.retort.load(resp.json(), StoredAudioData)
|
209
234
|
|
most/async_api.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
from typing import List, Dict
|
2
2
|
import json5
|
3
3
|
from adaptix import Retort
|
4
|
-
from most.types import Audio, Result, Script, JobStatus, Text, StoredAudioData
|
4
|
+
from most.types import Audio, Result, Script, JobStatus, Text, StoredAudioData, is_valid_id
|
5
5
|
from pathlib import Path
|
6
6
|
import httpx
|
7
7
|
|
@@ -72,6 +72,8 @@ class AsyncMostClient(object):
|
|
72
72
|
|
73
73
|
def with_model(self, model_id):
|
74
74
|
client = self.clone()
|
75
|
+
if not is_valid_id(self.model_id):
|
76
|
+
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
75
77
|
client.model_id = model_id
|
76
78
|
return client
|
77
79
|
|
@@ -151,8 +153,9 @@ class AsyncMostClient(object):
|
|
151
153
|
return self.retort.load(audio_list, List[Audio])
|
152
154
|
|
153
155
|
async def get_model_script(self) -> Script:
|
154
|
-
if self.model_id
|
155
|
-
raise RuntimeError("Please choose
|
156
|
+
if not is_valid_id(self.model_id):
|
157
|
+
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
158
|
+
|
156
159
|
resp = await self.get(f"https://api.the-most.ai/api/external/{self.client_id}/model/{self.model_id}/script")
|
157
160
|
return self.retort.load(resp.json(), Script)
|
158
161
|
|
@@ -162,40 +165,58 @@ class AsyncMostClient(object):
|
|
162
165
|
for model in resp.json()]
|
163
166
|
|
164
167
|
async def apply(self, audio_id) -> Result:
|
165
|
-
if self.model_id
|
166
|
-
raise RuntimeError("Please choose
|
168
|
+
if not is_valid_id(self.model_id):
|
169
|
+
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
170
|
+
|
171
|
+
if not is_valid_id(audio_id):
|
172
|
+
raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
|
173
|
+
|
167
174
|
resp = await self.post(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/apply")
|
168
175
|
return self.retort.load(resp.json(), Result)
|
169
176
|
|
170
177
|
async def apply_later(self, audio_id):
|
171
|
-
if self.model_id
|
172
|
-
raise RuntimeError("Please choose
|
178
|
+
if not is_valid_id(self.model_id):
|
179
|
+
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
180
|
+
|
181
|
+
if not is_valid_id(audio_id):
|
182
|
+
raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
|
183
|
+
|
173
184
|
resp = await self.post(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/apply_async")
|
174
185
|
return self.retort.load(resp.json(), Result)
|
175
186
|
|
176
187
|
async def get_job_status(self, audio_id) -> JobStatus:
|
177
|
-
if self.model_id
|
178
|
-
raise RuntimeError("Please choose
|
188
|
+
if not is_valid_id(self.model_id):
|
189
|
+
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
190
|
+
|
191
|
+
if not is_valid_id(audio_id):
|
192
|
+
raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
|
193
|
+
|
179
194
|
resp = await self.post(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/apply_status")
|
180
195
|
return self.retort.load(resp.json(), JobStatus)
|
181
196
|
|
182
197
|
async def fetch_results(self, audio_id) -> Result:
|
183
|
-
if self.model_id
|
184
|
-
raise RuntimeError("Please choose
|
198
|
+
if not is_valid_id(self.model_id):
|
199
|
+
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
200
|
+
|
201
|
+
if not is_valid_id(audio_id):
|
202
|
+
raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
|
185
203
|
|
186
204
|
resp = await self.get(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/results")
|
187
205
|
return self.retort.load(resp.json(), Result)
|
188
206
|
|
189
207
|
async def fetch_text(self, audio_id) -> Result:
|
190
|
-
if self.model_id
|
191
|
-
raise RuntimeError("Please choose
|
208
|
+
if not is_valid_id(self.model_id):
|
209
|
+
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
210
|
+
|
211
|
+
if not is_valid_id(audio_id):
|
212
|
+
raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
|
192
213
|
|
193
214
|
resp = await self.get(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/text")
|
194
215
|
return self.retort.load(resp.json(), Result)
|
195
216
|
|
196
217
|
async def export(self, audio_ids: List[str]) -> str:
|
197
|
-
if self.model_id
|
198
|
-
raise RuntimeError("Please choose
|
218
|
+
if not is_valid_id(self.model_id):
|
219
|
+
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
199
220
|
|
200
221
|
resp = await self.get(f"https://api.the-most.ai/api/external/{self.client_id}/model/{self.model_id}/export",
|
201
222
|
params={'audio_ids': ','.join(audio_ids)})
|
@@ -211,6 +232,8 @@ class AsyncMostClient(object):
|
|
211
232
|
return self.retort.load(resp.json(), StoredAudioData)
|
212
233
|
|
213
234
|
async def fetch_info(self, audio_id: str) -> Dict[str, str]:
|
235
|
+
if not is_valid_id(audio_id):
|
236
|
+
raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
|
214
237
|
resp = await self.get(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/info")
|
215
238
|
return self.retort.load(resp.json(), StoredAudioData)
|
216
239
|
|
most/types.py
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
from dataclasses import dataclass
|
2
|
+
|
3
|
+
from bson import ObjectId
|
2
4
|
from dataclasses_json import dataclass_json, DataClassJsonMixin
|
3
5
|
from typing import Optional, List, Literal, Dict
|
4
6
|
|
@@ -73,3 +75,17 @@ class Result(DataClassJsonMixin):
|
|
73
75
|
subcolumns=[subcolumn_result.name
|
74
76
|
for subcolumn_result in column_result.subcolumns])
|
75
77
|
for column_result in self.results])
|
78
|
+
|
79
|
+
|
80
|
+
def is_valid_id(smth_id: Optional[str]) -> bool:
|
81
|
+
if smth_id is None:
|
82
|
+
return False
|
83
|
+
|
84
|
+
if smth_id.startswith("most-"):
|
85
|
+
smth_id = smth_id[5:]
|
86
|
+
|
87
|
+
try:
|
88
|
+
ObjectId(smth_id)
|
89
|
+
return True
|
90
|
+
except:
|
91
|
+
return False
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: most-client
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.12
|
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
|
@@ -26,6 +26,7 @@ Requires-Dist: pytest
|
|
26
26
|
Requires-Dist: tox
|
27
27
|
Requires-Dist: twine
|
28
28
|
Requires-Dist: httpx
|
29
|
+
Requires-Dist: bson
|
29
30
|
Dynamic: author
|
30
31
|
Dynamic: author-email
|
31
32
|
Dynamic: classifier
|
@@ -0,0 +1,9 @@
|
|
1
|
+
most/__init__.py,sha256=62uFFeM_1VVR83K3bTYWK3PEoqnmFCy9aWYerQ6U4Ds,67
|
2
|
+
most/api.py,sha256=sGChrPUuwBjSdkkJK3BDOh3YYaxe9xAuGS82GcEdQk4,10074
|
3
|
+
most/async_api.py,sha256=ZiUXdqRBG8yTEBHfuglN1eaBMr29S9ibWWfFM5EP61w,10735
|
4
|
+
most/types.py,sha256=nSYmVm27y9py_HG6a7oKSObDRHCymmTYo-x5bYhKqug,1844
|
5
|
+
most_client-1.0.12.dist-info/METADATA,sha256=8oMagstmNNBg12x6Y2E-Zv5zBfMpAnXgZdQZcCbJTI0,1026
|
6
|
+
most_client-1.0.12.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
7
|
+
most_client-1.0.12.dist-info/top_level.txt,sha256=2g5fk02LKkM1hV3pVVti_LQ60TToLBcR2zQ3JEKGVk8,5
|
8
|
+
most_client-1.0.12.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
9
|
+
most_client-1.0.12.dist-info/RECORD,,
|
@@ -1,9 +0,0 @@
|
|
1
|
-
most/__init__.py,sha256=62uFFeM_1VVR83K3bTYWK3PEoqnmFCy9aWYerQ6U4Ds,67
|
2
|
-
most/api.py,sha256=tD6GkStvShdGTnjCLD34OSXLTV9mpJSQCKqo0UGsE60,9028
|
3
|
-
most/async_api.py,sha256=ixUxEttK5ibcRdWV9DghU9ixQcJWxXqdnkFEYsc6crA,9691
|
4
|
-
most/types.py,sha256=-GF8GBe0ojaAqyFl0yju030cZuUDe_6YU_5Q_5FT7UI,1565
|
5
|
-
most_client-1.0.10.dist-info/METADATA,sha256=YF8cjUF9bVgJhPg1xf-a3GNx7VPvjM9vkPgsgB5dYJk,1006
|
6
|
-
most_client-1.0.10.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
7
|
-
most_client-1.0.10.dist-info/top_level.txt,sha256=2g5fk02LKkM1hV3pVVti_LQ60TToLBcR2zQ3JEKGVk8,5
|
8
|
-
most_client-1.0.10.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
9
|
-
most_client-1.0.10.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|