most-client 1.0.2__py3-none-any.whl → 1.0.4__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
@@ -1 +1,2 @@
1
1
  from .api import MostClient
2
+ from .async_api import AsyncMostClient
most/api.py CHANGED
@@ -2,7 +2,7 @@ from typing import List
2
2
  import json5
3
3
  import requests
4
4
  from adaptix import Retort
5
- from most.types import Audio, Result, Script
5
+ from most.types import Audio, Result, Script, JobStatus
6
6
  from pathlib import Path
7
7
 
8
8
 
@@ -119,6 +119,11 @@ class MostClient(object):
119
119
  files={"audio_file": f})
120
120
  return self.retort.load(resp.json(), Audio)
121
121
 
122
+ def upload_audio_url(self, audio_url) -> Audio:
123
+ resp = self.post(f"https://api.the-most.ai/api/external/{self.client_id}/upload_url",
124
+ json={"audio_url": audio_url})
125
+ return self.retort.load(resp.json(), Audio)
126
+
122
127
  def list_audios(self,
123
128
  offset: int = 0,
124
129
  limit: int = 10) -> List[Audio]:
@@ -143,8 +148,17 @@ class MostClient(object):
143
148
  resp = self.post(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/apply")
144
149
  return self.retort.load(resp.json(), Result)
145
150
 
146
- def apply_later(self, audio_id):
147
- raise NotImplementedError()
151
+ def apply_later(self, audio_id) -> Result:
152
+ if self.model_id is None:
153
+ raise RuntimeError("Please choose a model to apply. [try list_models()]")
154
+ resp = self.post(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/apply_async")
155
+ return self.retort.load(resp.json(), Result)
156
+
157
+ def get_job_status(self, audio_id) -> JobStatus:
158
+ if self.model_id is None:
159
+ raise RuntimeError("Please choose a model to apply. [try list_models()]")
160
+ resp = self.post(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/apply_status")
161
+ return self.retort.load(resp.json(), JobStatus)
148
162
 
149
163
  def fetch_results(self, audio_id) -> Result:
150
164
  if self.model_id is None:
most/async_api.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from typing import List
2
2
  import json5
3
3
  from adaptix import Retort
4
- from most.types import Audio, Result, Script
4
+ from most.types import Audio, Result, Script, JobStatus
5
5
  from pathlib import Path
6
6
  import httpx
7
7
 
@@ -126,6 +126,11 @@ class AsyncMostClient(object):
126
126
  timeout=None)
127
127
  return self.retort.load(resp.json(), Audio)
128
128
 
129
+ async def upload_audio_url(self, audio_url) -> Audio:
130
+ resp = await self.post(f"https://api.the-most.ai/api/external/{self.client_id}/upload_url",
131
+ json={"audio_url": audio_url})
132
+ return self.retort.load(resp.json(), Audio)
133
+
129
134
  async def list_audios(self,
130
135
  offset: int = 0,
131
136
  limit: int = 10) -> List[Audio]:
@@ -152,7 +157,16 @@ class AsyncMostClient(object):
152
157
  return self.retort.load(resp.json(), Result)
153
158
 
154
159
  async def apply_later(self, audio_id):
155
- raise NotImplementedError()
160
+ if self.model_id is None:
161
+ raise RuntimeError("Please choose a model to apply. [try list_models()]")
162
+ resp = await self.post(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/apply_async")
163
+ return self.retort.load(resp.json(), Result)
164
+
165
+ async def get_job_status(self, audio_id) -> JobStatus:
166
+ if self.model_id is None:
167
+ raise RuntimeError("Please choose a model to apply. [try list_models()]")
168
+ resp = await self.post(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/apply_status")
169
+ return self.retort.load(resp.json(), JobStatus)
156
170
 
157
171
  async def fetch_results(self, audio_id) -> Result:
158
172
  if self.model_id is None:
@@ -173,4 +187,4 @@ class AsyncMostClient(object):
173
187
  return await self.apply(audio.id)
174
188
 
175
189
  def __repr__(self):
176
- return "<MostClient(model_id='%s')>" % (self.model_id, )
190
+ return "<AsyncMostClient(model_id='%s')>" % (self.model_id, )
most/types.py CHANGED
@@ -1,40 +1,53 @@
1
1
  from dataclasses import dataclass
2
- from typing import Optional, List
2
+ from dataclasses_json import dataclass_json, DataClassJsonMixin
3
+ from typing import Optional, List, Literal
3
4
 
4
5
 
6
+ @dataclass_json
5
7
  @dataclass
6
- class Audio:
8
+ class Audio(DataClassJsonMixin):
7
9
  id: str
8
10
  url: str
9
11
 
10
12
 
13
+ @dataclass_json
11
14
  @dataclass
12
- class SubcolumnResult:
15
+ class SubcolumnResult(DataClassJsonMixin):
13
16
  name: str
14
17
  score: Optional[int]
15
18
  description: str
16
19
 
17
20
 
21
+ @dataclass_json
18
22
  @dataclass
19
- class ColumnResult:
23
+ class ColumnResult(DataClassJsonMixin):
20
24
  name: str
21
25
  subcolumns: List[SubcolumnResult]
22
26
 
23
27
 
28
+ @dataclass_json
24
29
  @dataclass
25
- class Result:
30
+ class Result(DataClassJsonMixin):
26
31
  id: str
27
32
  text: Optional[str]
28
33
  url: Optional[str]
29
34
  results: Optional[List[ColumnResult]]
30
35
 
31
36
 
37
+ @dataclass_json
32
38
  @dataclass
33
- class Column:
39
+ class Column(DataClassJsonMixin):
34
40
  name: str
35
41
  subcolumns: List[str]
36
42
 
37
43
 
44
+ @dataclass_json
38
45
  @dataclass
39
- class Script:
46
+ class Script(DataClassJsonMixin):
40
47
  columns: List[Column]
48
+
49
+
50
+ @dataclass_json
51
+ @dataclass
52
+ class JobStatus(DataClassJsonMixin):
53
+ status: Literal["not_found", "pending", "completed", "error"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: most-client
3
- Version: 1.0.2
3
+ Version: 1.0.4
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,13 @@
1
+ most/__init__.py,sha256=62uFFeM_1VVR83K3bTYWK3PEoqnmFCy9aWYerQ6U4Ds,67
2
+ most/api.py,sha256=8lhnJU89qMiCjYgc5Gv4Z2i782ltBA7oTtnR57WyjK8,7285
3
+ most/async_api.py,sha256=tHo-vVa3a1LVCZ7c-Zwp5fmMx88AoZ3c-84VpLtlNFc,7946
4
+ most/types.py,sha256=phMLar9VTZIVeHLBLHYsEBiTvz8af-GHHF1GLctGytE,969
5
+ most/__pycache__/__init__.cpython-310.pyc,sha256=5RlgyJsgWSNkWEufVPFWDKxat0cEMCdwD8QFz5FvIj8,193
6
+ most/__pycache__/api.cpython-310.pyc,sha256=vAmUcfJHdL-59JuzcMpDfQedBaTk62nomDuzTt-thx0,5894
7
+ most/__pycache__/async_api.cpython-310.pyc,sha256=ng8wYkVziihVAMlv1ugFQQf-qFqP0NgAIfqKqE-K4k8,6615
8
+ most/__pycache__/types.cpython-310.pyc,sha256=OE7jIlp_0lo6XAwsnVnbsYsjjppGzTUcVo5ve6uHnQg,1492
9
+ most_client-1.0.4.dist-info/METADATA,sha256=eijnCdZFCVPNdMYgEZirZYedoNzPRJiku6Hcf8_Gvjo,864
10
+ most_client-1.0.4.dist-info/WHEEL,sha256=bFJAMchF8aTQGUgMZzHJyDDMPTO3ToJ7x23SLJa1SVo,92
11
+ most_client-1.0.4.dist-info/top_level.txt,sha256=2g5fk02LKkM1hV3pVVti_LQ60TToLBcR2zQ3JEKGVk8,5
12
+ most_client-1.0.4.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
13
+ most_client-1.0.4.dist-info/RECORD,,
@@ -1,13 +0,0 @@
1
- most/__init__.py,sha256=zfyI5dry-rsHP2Rr9YuPPo_fNFUtguZPAt-mbxDQ57I,28
2
- most/api.py,sha256=MRg52eg6Lf_sFwfTy2XYDHiD9VZSQ22BbvvkqQA1Fv0,6373
3
- most/async_api.py,sha256=ypdQ1P-aDblDlM6LbxNDjVjrkp-INJvg5an1n0vhi-E,7003
4
- most/types.py,sha256=7FgmaE7xHXggoU859BucqB13DA83CqmUPmBEuikNqE8,548
5
- most/__pycache__/__init__.cpython-310.pyc,sha256=5RlgyJsgWSNkWEufVPFWDKxat0cEMCdwD8QFz5FvIj8,193
6
- most/__pycache__/api.cpython-310.pyc,sha256=vAmUcfJHdL-59JuzcMpDfQedBaTk62nomDuzTt-thx0,5894
7
- most/__pycache__/async_api.cpython-310.pyc,sha256=ng8wYkVziihVAMlv1ugFQQf-qFqP0NgAIfqKqE-K4k8,6615
8
- most/__pycache__/types.cpython-310.pyc,sha256=OE7jIlp_0lo6XAwsnVnbsYsjjppGzTUcVo5ve6uHnQg,1492
9
- most_client-1.0.2.dist-info/METADATA,sha256=7gIy21ifYHR1jPNd-_rxkb-mDHK9pNRt18w7vwlxPto,864
10
- most_client-1.0.2.dist-info/WHEEL,sha256=bFJAMchF8aTQGUgMZzHJyDDMPTO3ToJ7x23SLJa1SVo,92
11
- most_client-1.0.2.dist-info/top_level.txt,sha256=2g5fk02LKkM1hV3pVVti_LQ60TToLBcR2zQ3JEKGVk8,5
12
- most_client-1.0.2.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
13
- most_client-1.0.2.dist-info/RECORD,,