most-client 1.0.22__py3-none-any.whl → 1.0.24__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 +35 -1
- most/async_api.py +35 -1
- {most_client-1.0.22.dist-info → most_client-1.0.24.dist-info}/METADATA +1 -1
- most_client-1.0.24.dist-info/RECORD +10 -0
- most_client-1.0.22.dist-info/RECORD +0 -10
- {most_client-1.0.22.dist-info → most_client-1.0.24.dist-info}/WHEEL +0 -0
- {most_client-1.0.22.dist-info → most_client-1.0.24.dist-info}/top_level.txt +0 -0
- {most_client-1.0.22.dist-info → most_client-1.0.24.dist-info}/zip-safe +0 -0
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,
|
21
|
+
is_valid_id, SearchParams, ScriptScoreMapping, Dialog,
|
22
22
|
)
|
23
23
|
|
24
24
|
|
@@ -114,6 +114,24 @@ class MostClient(object):
|
|
114
114
|
raise RuntimeError(resp.json()['message'] if resp.headers.get("Content-Type") == "application/json" else "Something went wrong.")
|
115
115
|
return resp
|
116
116
|
|
117
|
+
def put(self, url, **kwargs):
|
118
|
+
if self.access_token is None:
|
119
|
+
self.refresh_access_token()
|
120
|
+
headers = kwargs.pop("headers", {})
|
121
|
+
headers.update({"Authorization": "Bearer %s" % self.access_token})
|
122
|
+
resp = self.session.put(url,
|
123
|
+
headers=headers,
|
124
|
+
timeout=None,
|
125
|
+
**kwargs)
|
126
|
+
if resp.status_code == 401:
|
127
|
+
self.refresh_access_token()
|
128
|
+
return self.put(url,
|
129
|
+
headers=headers,
|
130
|
+
**kwargs)
|
131
|
+
if resp.status_code >= 400:
|
132
|
+
raise RuntimeError(resp.json()['message'] if resp.headers.get("Content-Type") == "application/json" else "Something went wrong.")
|
133
|
+
return resp
|
134
|
+
|
117
135
|
def post(self, url,
|
118
136
|
data=None,
|
119
137
|
json=None,
|
@@ -144,6 +162,11 @@ class MostClient(object):
|
|
144
162
|
files={"text": text})
|
145
163
|
return self.retort.load(resp.json(), Text)
|
146
164
|
|
165
|
+
def upload_dialog(self, dialog: Dialog) -> DialogResult:
|
166
|
+
resp = self.post(f"https://api.the-most.ai/api/external/{self.client_id}/upload_dialog",
|
167
|
+
json={"dialog": dialog})
|
168
|
+
return self.retort.load(resp.json(), DialogResult)
|
169
|
+
|
147
170
|
def upload_audio(self, audio_path) -> Audio:
|
148
171
|
with open(audio_path, 'rb') as f:
|
149
172
|
resp = self.post(f"https://api.the-most.ai/api/external/{self.client_id}/upload",
|
@@ -302,6 +325,17 @@ class MostClient(object):
|
|
302
325
|
resp = self.get(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/dialog")
|
303
326
|
return self.retort.load(resp.json(), DialogResult)
|
304
327
|
|
328
|
+
def update_dialog(self, audio_id, dialog: Dialog) -> DialogResult:
|
329
|
+
if not is_valid_id(self.model_id):
|
330
|
+
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
331
|
+
|
332
|
+
if not is_valid_id(audio_id):
|
333
|
+
raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
|
334
|
+
|
335
|
+
resp = self.put(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/dialog",
|
336
|
+
json={"dialog": dialog.to_dict()})
|
337
|
+
return self.retort.load(resp.json(), DialogResult)
|
338
|
+
|
305
339
|
def export(self, audio_ids: List[str],
|
306
340
|
aggregated_by: Optional[str] = None,
|
307
341
|
aggregation_title: Optional[str] = None) -> str:
|
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,
|
21
|
+
is_valid_id, SearchParams, ScriptScoreMapping, Dialog,
|
22
22
|
)
|
23
23
|
|
24
24
|
|
@@ -122,6 +122,24 @@ class AsyncMostClient(object):
|
|
122
122
|
"Content-Type") == "application/json" else "Something went wrong.")
|
123
123
|
return resp
|
124
124
|
|
125
|
+
async def put(self, url, **kwargs):
|
126
|
+
if self.access_token is None:
|
127
|
+
await self.refresh_access_token()
|
128
|
+
headers = kwargs.pop("headers", {})
|
129
|
+
headers.update({"Authorization": "Bearer %s" % self.access_token})
|
130
|
+
resp = await self.session.put(url,
|
131
|
+
headers=headers,
|
132
|
+
timeout=None,
|
133
|
+
**kwargs)
|
134
|
+
if resp.status_code == 401:
|
135
|
+
await self.refresh_access_token()
|
136
|
+
return await self.put(url,
|
137
|
+
headers=headers,
|
138
|
+
**kwargs)
|
139
|
+
if resp.status_code >= 400:
|
140
|
+
raise RuntimeError(resp.json()['message'] if resp.headers.get("Content-Type") == "application/json" else "Something went wrong.")
|
141
|
+
return resp
|
142
|
+
|
125
143
|
async def post(self, url,
|
126
144
|
data=None,
|
127
145
|
json=None,
|
@@ -170,6 +188,11 @@ class AsyncMostClient(object):
|
|
170
188
|
json={"text": text})
|
171
189
|
return self.retort.load(resp.json(), Text)
|
172
190
|
|
191
|
+
async def upload_dialog(self, dialog: Dialog) -> DialogResult:
|
192
|
+
resp = await self.post(f"https://api.the-most.ai/api/external/{self.client_id}/upload_dialog",
|
193
|
+
json={"dialog": dialog})
|
194
|
+
return self.retort.load(resp.json(), DialogResult)
|
195
|
+
|
173
196
|
async def upload_audio_url(self, audio_url) -> Audio:
|
174
197
|
resp = await self.post(f"https://api.the-most.ai/api/external/{self.client_id}/upload_url",
|
175
198
|
json={"audio_url": audio_url})
|
@@ -311,6 +334,17 @@ class AsyncMostClient(object):
|
|
311
334
|
resp = await self.get(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/dialog")
|
312
335
|
return self.retort.load(resp.json(), DialogResult)
|
313
336
|
|
337
|
+
async def update_dialog(self, audio_id, dialog: Dialog) -> DialogResult:
|
338
|
+
if not is_valid_id(self.model_id):
|
339
|
+
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
340
|
+
|
341
|
+
if not is_valid_id(audio_id):
|
342
|
+
raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
|
343
|
+
|
344
|
+
resp = await self.put(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/dialog",
|
345
|
+
json={"dialog": dialog.to_dict()})
|
346
|
+
return self.retort.load(resp.json(), DialogResult)
|
347
|
+
|
314
348
|
async def export(self, audio_ids: List[str],
|
315
349
|
aggregated_by: Optional[str] = None,
|
316
350
|
aggregation_title: Optional[str] = None) -> str:
|
@@ -0,0 +1,10 @@
|
|
1
|
+
most/__init__.py,sha256=62uFFeM_1VVR83K3bTYWK3PEoqnmFCy9aWYerQ6U4Ds,67
|
2
|
+
most/api.py,sha256=HWSwJX1QFRCvhf5OkH3Fx8lvGjLt_6gM9H6D5aKZ1og,17638
|
3
|
+
most/async_api.py,sha256=w56Ll0r97I__PSqFxvCGO6GOCeno1qvOdAwgK5FhtlM,18703
|
4
|
+
most/score_calculation.py,sha256=1XU1LfIH5LSCwAbAaKkr-EjH5qOTXrJKOUvhCCawka4,1054
|
5
|
+
most/types.py,sha256=Qgyv261J8b1cfbmeITz1C9QgkoCMGQQd_L4t4M3dd6M,3603
|
6
|
+
most_client-1.0.24.dist-info/METADATA,sha256=63Geupu8DOnw5svjeWeOSBW1S5qPSZZ7ZbZLynNXs9k,1027
|
7
|
+
most_client-1.0.24.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
8
|
+
most_client-1.0.24.dist-info/top_level.txt,sha256=2g5fk02LKkM1hV3pVVti_LQ60TToLBcR2zQ3JEKGVk8,5
|
9
|
+
most_client-1.0.24.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
10
|
+
most_client-1.0.24.dist-info/RECORD,,
|
@@ -1,10 +0,0 @@
|
|
1
|
-
most/__init__.py,sha256=62uFFeM_1VVR83K3bTYWK3PEoqnmFCy9aWYerQ6U4Ds,67
|
2
|
-
most/api.py,sha256=ffgsS-i9pxNOgjMBd7-G-PqA69-VFCVn47vHSJW8XeM,15980
|
3
|
-
most/async_api.py,sha256=UF7DXTmIGfPl93noMR742FkMiRtSO5zLV-c4qZVDMNs,16949
|
4
|
-
most/score_calculation.py,sha256=1XU1LfIH5LSCwAbAaKkr-EjH5qOTXrJKOUvhCCawka4,1054
|
5
|
-
most/types.py,sha256=Qgyv261J8b1cfbmeITz1C9QgkoCMGQQd_L4t4M3dd6M,3603
|
6
|
-
most_client-1.0.22.dist-info/METADATA,sha256=ske3Ee2ObuBu-q6omKkTPdwBgwfAKqVDTmf-jn0vlDs,1027
|
7
|
-
most_client-1.0.22.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
8
|
-
most_client-1.0.22.dist-info/top_level.txt,sha256=2g5fk02LKkM1hV3pVVti_LQ60TToLBcR2zQ3JEKGVk8,5
|
9
|
-
most_client-1.0.22.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
10
|
-
most_client-1.0.22.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|