most-client 1.0.31__tar.gz → 1.0.32__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: most-client
3
- Version: 1.0.31
3
+ Version: 1.0.32
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
@@ -18,7 +18,7 @@ from most.types import (
18
18
  Script,
19
19
  StoredAudioData,
20
20
  Text,
21
- is_valid_id, SearchParams, ScriptScoreMapping, Dialog,
21
+ is_valid_id, SearchParams, ScriptScoreMapping, Dialog, Usage,
22
22
  )
23
23
 
24
24
 
@@ -26,7 +26,7 @@ class MostClient(object):
26
26
  retort = Retort(recipe=[
27
27
  loader(int, lambda x: int(x)),
28
28
  loader(float, lambda x: float(x)),
29
- loader(datetime, lambda x: datetime.fromtimestamp(x).replace(tzinfo=timezone.utc)),
29
+ loader(datetime, lambda x: datetime.fromtimestamp(x).astimezone(tz=timezone.utc) if isinstance(x, (int, float)) else datetime.fromisoformat(x)),
30
30
  ],)
31
31
 
32
32
  def __init__(self,
@@ -444,3 +444,12 @@ class MostClient(object):
444
444
  raise RuntimeError("Audio can't be indexed")
445
445
  audio_list = resp.json()
446
446
  return self.retort.load(audio_list, List[Audio])
447
+
448
+ def get_usage(self,
449
+ start_dt: datetime,
450
+ end_dt: datetime):
451
+ resp = self.get(f"/{self.client_id}/model/{self.model_id}/usage",
452
+ params={'start_dt': start_dt.astimezone(timezone.utc).isoformat(),
453
+ 'end_dt': end_dt.astimezone(timezone.utc).isoformat()})
454
+ resp.raise_for_status()
455
+ return self.retort.load(resp.json(), Usage)
@@ -18,7 +18,7 @@ from most.types import (
18
18
  Script,
19
19
  StoredAudioData,
20
20
  Text,
21
- is_valid_id, SearchParams, ScriptScoreMapping, Dialog,
21
+ is_valid_id, SearchParams, ScriptScoreMapping, Dialog, Usage,
22
22
  )
23
23
 
24
24
 
@@ -26,7 +26,7 @@ class AsyncMostClient(object):
26
26
  retort = Retort(recipe=[
27
27
  loader(int, lambda x: int(x)),
28
28
  loader(float, lambda x: float(x)),
29
- loader(datetime, lambda x: datetime.fromtimestamp(x).replace(tzinfo=timezone.utc)),
29
+ loader(datetime, lambda x: datetime.fromtimestamp(x).astimezone(tz=timezone.utc) if isinstance(x, (int, float)) else datetime.fromisoformat(x)),
30
30
  ])
31
31
 
32
32
  def __init__(self,
@@ -450,3 +450,12 @@ class AsyncMostClient(object):
450
450
  raise RuntimeError("Audio can't be indexed")
451
451
  audio_list = resp.json()
452
452
  return self.retort.load(audio_list, List[Audio])
453
+
454
+ async def get_usage(self,
455
+ start_dt: datetime,
456
+ end_dt: datetime):
457
+ resp = await self.get(f"/{self.client_id}/model/{self.model_id}/usage",
458
+ params={'start_dt': start_dt.astimezone(timezone.utc).isoformat(),
459
+ 'end_dt': end_dt.astimezone(timezone.utc).isoformat()})
460
+ resp.raise_for_status()
461
+ return self.retort.load(resp.json(), Usage)
@@ -173,6 +173,25 @@ class HumanFeedback(DataClassJsonMixin):
173
173
  return sum((preds[key] == gt[key]) for key in common_keys) / len(common_keys)
174
174
 
175
175
 
176
+ @dataclass_json
177
+ @dataclass
178
+ class Usage(DataClassJsonMixin):
179
+ apply_audio_async: int
180
+ apply_audio_async_duration: int
181
+ apply_text_async: int
182
+
183
+ apply_audio: int
184
+ apply_audio_duration: int
185
+ apply_text: int
186
+
187
+ upload_audio: int
188
+ upload_audio_duration: int
189
+ upload_text: int
190
+
191
+ start_dt: datetime
192
+ end_dt: datetime
193
+
194
+
176
195
  def is_valid_objectid(oid: str) -> bool:
177
196
  """
178
197
  Check if a given string is a valid MongoDB ObjectId (24-character hex).
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: most-client
3
- Version: 1.0.31
3
+ Version: 1.0.32
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
@@ -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.31',
11
+ version='1.0.32',
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