mostlyai 0.3.10__tar.gz → 0.3.12__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.1
2
2
  Name: mostlyai
3
- Version: 0.3.10
3
+ Version: 0.3.12
4
4
  Summary: The official Python client for the MOSTLY AI platform.
5
5
  Home-page: https://app.mostly.ai/
6
6
  License: Proprietary
@@ -33,6 +33,7 @@ A Python wrapper for the MOSTLY AI platform (https://app.mostly.ai/).
33
33
  | Live probe the generator on demand | `mostly.probe(g, size \| seed)` |
34
34
  | Connect to any data source within your org | `mostly.connect(config)` |
35
35
  | Info about the current user | `mostly.me()` |
36
+ | Info about the usage | `mostly.usage(by_periods)` |
36
37
  | Info about the platform | `mostly.about()` |
37
38
 
38
39
 
@@ -144,7 +145,8 @@ c.shares()
144
145
  ### Info
145
146
 
146
147
  ```python
147
- mostly.about()
148
148
  mostly.me()
149
+ mostly.usage_report(by_periods)
150
+ mostly.about()
149
151
  ```
150
152
 
@@ -11,6 +11,7 @@ A Python wrapper for the MOSTLY AI platform (https://app.mostly.ai/).
11
11
  | Live probe the generator on demand | `mostly.probe(g, size \| seed)` |
12
12
  | Connect to any data source within your org | `mostly.connect(config)` |
13
13
  | Info about the current user | `mostly.me()` |
14
+ | Info about the usage | `mostly.usage(by_periods)` |
14
15
  | Info about the platform | `mostly.about()` |
15
16
 
16
17
 
@@ -122,6 +123,7 @@ c.shares()
122
123
  ### Info
123
124
 
124
125
  ```python
125
- mostly.about()
126
126
  mostly.me()
127
+ mostly.usage_report(by_periods)
128
+ mostly.about()
127
129
  ```
@@ -1,4 +1,4 @@
1
1
  from mostlyai.api import MostlyAI
2
2
 
3
3
  __all__ = ["MostlyAI"]
4
- __version__ = "0.3.10" # Do not set this manually. Use poetry version [params].
4
+ __version__ = "0.3.12" # Do not set this manually. Use poetry version [params].
@@ -1,3 +1,5 @@
1
+ import io
2
+ import json
1
3
  from pathlib import Path
2
4
  from typing import Any, Optional, Union, Literal
3
5
 
@@ -375,6 +377,24 @@ class MostlyAI(_MostlyBaseClient):
375
377
  """
376
378
  return self.request(verb=GET, path=["users", "me"], response_type=CurrentUser)
377
379
 
380
+ def usage_report(self, by_periods: bool = False) -> pd.DataFrame:
381
+ """
382
+ Retrieve usage report as a pd.DataFrame.
383
+
384
+ :param by_periods: if True, by periods. Otherwise, the overall usage report.
385
+ :return: summary of the usage (either by periods or overall)
386
+ """
387
+ headers = {"Accept": "*/*"} # Accept any content type
388
+ path = ["usage-report"] + (["periods"] if by_periods else ["download"])
389
+ response = self.request(verb=GET, headers=headers, path=path, raw_response=True)
390
+ if by_periods:
391
+ data = json.loads(response.content.decode("utf-8"))["usage"]
392
+ df = pd.DataFrame(data)
393
+ else:
394
+ csv_file = io.BytesIO(response.content)
395
+ df = pd.read_csv(csv_file)
396
+ return df
397
+
378
398
  def about(self) -> dict[str, Any]:
379
399
  """
380
400
  Retrieve about info from the endpoint.
@@ -70,6 +70,14 @@ class _MostlyGeneratorsClient(_MostlyBaseClient, _MostlySharesMixin):
70
70
  table["data"] = _convert_to_base64(table["data"])
71
71
  else:
72
72
  raise ValueError("data must be a DataFrame or a file path")
73
+ # convert `columns` to list[dict], if provided as list[str]
74
+ if "tables" in config and config["tables"]:
75
+ for table in config["tables"]:
76
+ if "columns" in table and table["columns"]:
77
+ table["columns"] = [
78
+ {"name": col} if isinstance(col, str) else col
79
+ for col in table["columns"]
80
+ ]
73
81
 
74
82
  generator = self.request(
75
83
  verb=POST, path=[], json=config, response_type=Generator
@@ -1,5 +1,5 @@
1
1
  # generated by datamodel-codegen:
2
- # timestamp: 2024-06-21T12:02:58+00:00
2
+ # timestamp: 2024-08-12T09:57:53+00:00
3
3
 
4
4
  from __future__ import annotations
5
5
 
@@ -754,10 +754,8 @@ class SyntheticTableFairness(CustomBaseModel):
754
754
 
755
755
  """
756
756
 
757
- target_column: Annotated[Optional[str], Field(None, alias="targetColumn")] = None
758
- sensitive_columns: Annotated[
759
- Optional[List[str]], Field(None, alias="sensitiveColumns")
760
- ] = None
757
+ target_column: Annotated[str, Field(alias="targetColumn")]
758
+ sensitive_columns: Annotated[List[str], Field(alias="sensitiveColumns")]
761
759
 
762
760
 
763
761
  class SyntheticTableConfiguration(CustomBaseModel):
@@ -989,12 +987,20 @@ class AssistantSettings(CustomBaseModel):
989
987
  description="The custom instructions of the assistant",
990
988
  ),
991
989
  ] = None
990
+ default_system_instructions: Annotated[
991
+ Optional[str],
992
+ Field(
993
+ None,
994
+ alias="defaultSystemInstructions",
995
+ description="The system instructions of the assistant",
996
+ ),
997
+ ] = None
992
998
 
993
999
 
994
1000
  class AssistantThreadSessionStatus(str, Enum):
995
- pending = "pending"
996
- active = "active"
997
- inactive = "inactive"
1001
+ initializing = "initializing"
1002
+ running = "running"
1003
+ expired = "expired"
998
1004
 
999
1005
 
1000
1006
  class AssistantMessageRole(str, Enum):
@@ -1016,6 +1022,7 @@ class AssistantMessageContentType(str, Enum):
1016
1022
  text = "text"
1017
1023
  python = "python"
1018
1024
  console = "console"
1025
+ file = "file"
1019
1026
 
1020
1027
 
1021
1028
  class AssistantMessageFinishReason(str, Enum):
@@ -1040,7 +1047,7 @@ class AssistantMessage(CustomBaseModel):
1040
1047
  content: Annotated[
1041
1048
  Optional[str],
1042
1049
  Field(
1043
- None, description="The content of a message", max_length=65000, min_length=1
1050
+ None, description="The content of a message", max_length=65000, min_length=0
1044
1051
  ),
1045
1052
  ] = None
1046
1053
  finish_reason: Annotated[
@@ -1086,6 +1093,53 @@ class AssistantThreadUsage(CustomBaseModel):
1086
1093
  ] = None
1087
1094
 
1088
1095
 
1096
+ class UsageReportPeriod(CustomBaseModel):
1097
+ """
1098
+ The usage report for a specific month
1099
+ """
1100
+
1101
+ period_start: Annotated[
1102
+ Optional[AwareDatetime],
1103
+ Field(
1104
+ None,
1105
+ alias="periodStart",
1106
+ description="The UTC date and time when the reported time period started",
1107
+ ),
1108
+ ] = None
1109
+ period_end: Annotated[
1110
+ Optional[AwareDatetime],
1111
+ Field(
1112
+ None,
1113
+ alias="periodEnd",
1114
+ description="The UTC date and time when the reported time period started",
1115
+ ),
1116
+ ] = None
1117
+ total_datapoints: Annotated[
1118
+ Optional[int],
1119
+ Field(
1120
+ None,
1121
+ alias="totalDatapoints",
1122
+ description="The number of datapoints generated during the reported period",
1123
+ ),
1124
+ ] = None
1125
+ total_rows: Annotated[
1126
+ Optional[int],
1127
+ Field(
1128
+ None,
1129
+ alias="totalRows",
1130
+ description="The number of rows generated during the reported period",
1131
+ ),
1132
+ ] = None
1133
+ total_credits: Annotated[
1134
+ Optional[float],
1135
+ Field(
1136
+ None,
1137
+ alias="totalCredits",
1138
+ description="The number of credits used during the reported period",
1139
+ ),
1140
+ ] = None
1141
+
1142
+
1089
1143
  class BaseResource(CustomBaseModel):
1090
1144
  id: Annotated[
1091
1145
  Optional[str], Field(None, description="The unique identifier of the entity")
@@ -1545,11 +1599,9 @@ class Generator(CustomBaseModel):
1545
1599
  file_path: Union[str, Path, None] = None,
1546
1600
  ) -> Path:
1547
1601
  """
1548
- Export generator and save to file.
1549
- Supported from release v212 onwards.
1602
+ Export generator and save to file
1550
1603
 
1551
- :param file_path: Optional. The file path to save the synthetic dataset.
1552
- :return: The file path of the exported generator
1604
+ :param file_path: The file path to save the synthetic dataset
1553
1605
  """
1554
1606
  bytes, filename = self.client._export_to_file(generator_id=self.id)
1555
1607
  file_path = Path(file_path or ".")
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "mostlyai"
3
- version = "0.3.10"
3
+ version = "0.3.12"
4
4
  description = "The official Python client for the MOSTLY AI platform."
5
5
  homepage = "https://app.mostly.ai/"
6
6
  authors = ["MOSTLY AI <office@mostly.ai>"]
File without changes
File without changes
File without changes
File without changes