mostlyai 0.3.12__tar.gz → 0.4.0__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.12
3
+ Version: 0.4.0
4
4
  Summary: The official Python client for the MOSTLY AI platform.
5
5
  Home-page: https://app.mostly.ai/
6
6
  License: Proprietary
@@ -32,13 +32,13 @@ A Python wrapper for the MOSTLY AI platform (https://app.mostly.ai/).
32
32
  | Prompt the generator for the data that you need | `mostly.generate(g, seed)` |
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
+ | List the available models | `mostly.models(model_type)` |
36
+ | List the available computes | `mostly.computes()` |
35
37
  | Info about the current user | `mostly.me()` |
36
- | Info about the usage | `mostly.usage(by_periods)` |
37
38
  | Info about the platform | `mostly.about()` |
38
39
 
39
40
 
40
41
 
41
-
42
42
  ## Installation
43
43
 
44
44
  ```shell
@@ -142,11 +142,17 @@ sd.shares()
142
142
  c.shares()
143
143
  ```
144
144
 
145
- ### Info
145
+ ### Job Configuration Info
146
+ ```python
147
+ mostly.models(model_type)
148
+ mostly.computes()
149
+ ```
150
+
151
+ ### User Info
146
152
 
147
153
  ```python
148
154
  mostly.me()
149
- mostly.usage_report(by_periods)
150
155
  mostly.about()
156
+
151
157
  ```
152
158
 
@@ -10,13 +10,13 @@ A Python wrapper for the MOSTLY AI platform (https://app.mostly.ai/).
10
10
  | Prompt the generator for the data that you need | `mostly.generate(g, seed)` |
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
+ | List the available models | `mostly.models(model_type)` |
14
+ | List the available computes | `mostly.computes()` |
13
15
  | Info about the current user | `mostly.me()` |
14
- | Info about the usage | `mostly.usage(by_periods)` |
15
16
  | Info about the platform | `mostly.about()` |
16
17
 
17
18
 
18
19
 
19
-
20
20
  ## Installation
21
21
 
22
22
  ```shell
@@ -120,10 +120,16 @@ sd.shares()
120
120
  c.shares()
121
121
  ```
122
122
 
123
- ### Info
123
+ ### Job Configuration Info
124
+ ```python
125
+ mostly.models(model_type)
126
+ mostly.computes()
127
+ ```
128
+
129
+ ### User Info
124
130
 
125
131
  ```python
126
132
  mostly.me()
127
- mostly.usage_report(by_periods)
128
133
  mostly.about()
134
+
129
135
  ```
@@ -0,0 +1,4 @@
1
+ from mostlyai.api import MostlyAI
2
+
3
+ __all__ = ["MostlyAI"]
4
+ __version__ = "0.4.0" # Do not set this manually. Use poetry version [params].
@@ -1,5 +1,3 @@
1
- import io
2
- import json
3
1
  from pathlib import Path
4
2
  from typing import Any, Optional, Union, Literal
5
3
 
@@ -16,6 +14,7 @@ from mostlyai.model import (
16
14
  PermissionLevel,
17
15
  ProgressStatus,
18
16
  SyntheticDataset,
17
+ ModelType,
19
18
  )
20
19
  from mostlyai.shares import _MostlySharesClient
21
20
  from mostlyai.synthetic_datasets import (
@@ -377,24 +376,6 @@ class MostlyAI(_MostlyBaseClient):
377
376
  """
378
377
  return self.request(verb=GET, path=["users", "me"], response_type=CurrentUser)
379
378
 
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
-
398
379
  def about(self) -> dict[str, Any]:
399
380
  """
400
381
  Retrieve about info from the endpoint.
@@ -402,3 +383,11 @@ class MostlyAI(_MostlyBaseClient):
402
383
  :return: info about the platform.
403
384
  """
404
385
  return self.request(verb=GET, path=["about"])
386
+
387
+ def models(self, model_type: Union[str, ModelType]) -> list[str]:
388
+ if isinstance(model_type, ModelType):
389
+ model_type = model_type.value
390
+ return self.request(verb=GET, path=["models", model_type])
391
+
392
+ def computes(self) -> list[dict[str, Any]]:
393
+ return self.request(verb=GET, path=["computes"])
@@ -210,7 +210,7 @@ class CustomBaseModel(BaseModel):
210
210
  # Use rich.print to create a rich representation of the model
211
211
  console = Console()
212
212
  with console.capture() as capture:
213
- rich.print(self.dict())
213
+ rich.print(self.model_dump())
214
214
  return capture.get()
215
215
 
216
216
  def open(self) -> str:
@@ -7,7 +7,11 @@ import pandas as pd
7
7
  from mostlyai.base import DELETE, GET, PATCH, POST, Paginator, _MostlyBaseClient
8
8
  from mostlyai.model import Generator, JobProgress
9
9
  from mostlyai.shares import _MostlySharesMixin
10
- from mostlyai.utils import _convert_to_base64, _job_wait, _read_table_from_path
10
+ from mostlyai.utils import (
11
+ _convert_to_base64,
12
+ _job_wait,
13
+ _read_table_from_path,
14
+ )
11
15
 
12
16
 
13
17
  class _MostlyGeneratorsClient(_MostlyBaseClient, _MostlySharesMixin):
@@ -56,10 +60,10 @@ class _MostlyGeneratorsClient(_MostlyBaseClient, _MostlySharesMixin):
56
60
  return response
57
61
 
58
62
  def create(self, config: dict) -> Generator:
59
- # convert `data` to base64-encoded Parquet files
60
- if "tables" in config and config["tables"]:
63
+ if config.get("tables"):
61
64
  for table in config["tables"]:
62
- if "data" in table and table["data"] is not None:
65
+ # convert `data` to base64-encoded Parquet files
66
+ if table.get("data") is not None:
63
67
  if isinstance(table["data"], (str, Path)):
64
68
  name, df = _read_table_from_path(table["data"])
65
69
  table["data"] = _convert_to_base64(df)
@@ -70,15 +74,12 @@ class _MostlyGeneratorsClient(_MostlyBaseClient, _MostlySharesMixin):
70
74
  table["data"] = _convert_to_base64(table["data"])
71
75
  else:
72
76
  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
+ if table.get("columns"):
78
+ # convert `columns` to list[dict], if provided as list[str]
77
79
  table["columns"] = [
78
80
  {"name": col} if isinstance(col, str) else col
79
81
  for col in table["columns"]
80
82
  ]
81
-
82
83
  generator = self.request(
83
84
  verb=POST, path=[], json=config, response_type=Generator
84
85
  )
@@ -1,5 +1,5 @@
1
1
  # generated by datamodel-codegen:
2
- # timestamp: 2024-08-12T09:57:53+00:00
2
+ # timestamp: 2024-09-04T22:33:57+00:00
3
3
 
4
4
  from __future__ import annotations
5
5
 
@@ -142,22 +142,35 @@ class PaginatedTotalCount(RootModel[int]):
142
142
  class ModelEncodingType(str, Enum):
143
143
  """
144
144
  The encoding type used for model training and data generation.
145
- This property is only relevant if generation method is AI_MODEL.
146
145
  - AUTO: Model chooses among available encoding types based on the column's data type.
147
- - CATEGORICAL: Model samples from existing (non-rare) categories.
148
- - NUMERIC_AUTO: Model chooses among 3 numeric encoding types based on the values.
149
- - NUMERIC_DISCRETE: Model samples from existing discrete numerical values.
150
- - NUMERIC_BINNED: Model samples from binned buckets, to then sample randomly within a bucket.
151
- - NUMERIC_DIGIT: Model samples each digit of a numerical value.
152
- - CHARACTER: Model samples each character of a string value.
153
- - DATETIME: Model samples each part of a datetime value.
154
- - DATETIME_RELATIVE: Model samples the relative difference between datetimes within a sequence.
155
- - LAT_LONG: Model samples a latitude-longitude column. The format is "latitude,longitude".
156
- - TEXT_MODEL: Model will train a distinct TEXT model for this column.
146
+ - TABULAR_CATEGORICAL: Model samples from existing (non-rare) categories.
147
+ - TABULAR_NUMERIC_AUTO: Model chooses among 3 numeric encoding types based on the values.
148
+ - TABULAR_NUMERIC_DISCRETE: Model samples from existing discrete numerical values.
149
+ - TABULAR_NUMERIC_BINNED: Model samples from binned buckets, to then sample randomly within a bucket.
150
+ - TABULAR_NUMERIC_DIGIT: Model samples each digit of a numerical value.
151
+ - TABULAR_CHARACTER: Model samples each character of a string value.
152
+ - TABULAR_DATETIME: Model samples each part of a datetime value.
153
+ - TABULAR_DATETIME_RELATIVE: Model samples the relative difference between datetimes within a sequence.
154
+ - TABULAR_LAT_LONG: Model samples a latitude-longitude column. The format is "latitude,longitude".
155
+ - LANGUAGE_TEXT: Model will train a distinct LANGUAGE model for this column, to then generate free text.
156
+ # - LANGUAGE_NUMERIC
157
+ # - LANGUAGE_CATEGORICAL
158
+ # - LANGUAGE_DATETIME
159
+ Encoding types, that are not being prefixed with either TABULAR or LANGUAGE have been deprecated.
157
160
 
158
161
  """
159
162
 
160
163
  auto = "AUTO"
164
+ tabular_categorical = "TABULAR_CATEGORICAL"
165
+ tabular_numeric_auto = "TABULAR_NUMERIC_AUTO"
166
+ tabular_numeric_discrete = "TABULAR_NUMERIC_DISCRETE"
167
+ tabular_numeric_binned = "TABULAR_NUMERIC_BINNED"
168
+ tabular_numeric_digit = "TABULAR_NUMERIC_DIGIT"
169
+ tabular_character = "TABULAR_CHARACTER"
170
+ tabular_datetime = "TABULAR_DATETIME"
171
+ tabular_datetime_relative = "TABULAR_DATETIME_RELATIVE"
172
+ tabular_lat_long = "TABULAR_LAT_LONG"
173
+ language_text = "LANGUAGE_TEXT"
161
174
  categorical = "CATEGORICAL"
162
175
  numeric_auto = "NUMERIC_AUTO"
163
176
  numeric_discrete = "NUMERIC_DISCRETE"
@@ -167,7 +180,6 @@ class ModelEncodingType(str, Enum):
167
180
  datetime = "DATETIME"
168
181
  datetime_relative = "DATETIME_RELATIVE"
169
182
  lat_long = "LAT_LONG"
170
- text_model = "TEXT_MODEL"
171
183
 
172
184
 
173
185
  class ConnectorAccessType(str, Enum):
@@ -440,23 +452,16 @@ class SourceForeignKey(CustomBaseModel):
440
452
  ]
441
453
 
442
454
 
443
- class ModelSize(str, Enum):
444
- """
445
- The size of the model, with the default being M(edium).
446
- Choose S(mall) for faster training, or L(arge) for better results for large dataset.
447
- Note, that larger model sizes will require more memory and more compute.
448
-
449
- """
450
-
451
- s = "S"
452
- m = "M"
453
- l = "L"
455
+ class ModelType(str, Enum):
456
+ tabular = "TABULAR"
457
+ language = "LANGUAGE"
454
458
 
455
459
 
456
460
  class RareCategoryReplacementMethod(str, Enum):
457
461
  """
458
462
  Specifies, if the rare categories for categoricals will be replaced by a constant
459
463
  _RARE_ or by a sample from non-rare categories.
464
+ Only applicable if valueProtection is set to True.
460
465
 
461
466
  """
462
467
 
@@ -464,95 +469,6 @@ class RareCategoryReplacementMethod(str, Enum):
464
469
  sample = "SAMPLE"
465
470
 
466
471
 
467
- class ModelConfiguration(CustomBaseModel):
468
- """
469
- The training configuration for a AI model
470
- """
471
-
472
- max_sample_size: Annotated[
473
- Optional[int],
474
- Field(
475
- None,
476
- alias="maxSampleSize",
477
- description="The maximum number of samples to consider for training.\nIf not provided, then all available samples will be taken.\n",
478
- ge=1,
479
- le=1000000000,
480
- ),
481
- ] = None
482
- batch_size: Annotated[
483
- Optional[int],
484
- Field(
485
- None,
486
- alias="batchSize",
487
- description="The batch size used for training the model.\nIf not provided, batchSize will be chosen automatically.\n",
488
- ge=1,
489
- le=1000000,
490
- ),
491
- ] = None
492
- model_size: Annotated[
493
- Optional[ModelSize],
494
- Field(
495
- "M",
496
- alias="modelSize",
497
- description="The size of the model, with the default being M(edium).\nChoose S(mall) for faster training, or L(arge) for better results for large dataset.\nNote, that larger model sizes will require more memory and more compute.\n",
498
- ),
499
- ] = "M"
500
- max_training_time: Annotated[
501
- Optional[int],
502
- Field(
503
- 10,
504
- alias="maxTrainingTime",
505
- description="The maximum number of minutes to train the model.",
506
- ge=0,
507
- le=100000,
508
- ),
509
- ] = 10
510
- max_epochs: Annotated[
511
- Optional[int],
512
- Field(
513
- 100,
514
- alias="maxEpochs",
515
- description="The maximum number of epochs to train the model.",
516
- ge=0,
517
- le=100000,
518
- ),
519
- ] = 100
520
- max_sequence_window: Annotated[
521
- Optional[int],
522
- Field(
523
- 100,
524
- alias="maxSequenceWindow",
525
- description="The maximum sequence window to consider for training.",
526
- ge=1,
527
- le=100000,
528
- ),
529
- ] = 100
530
- enable_flexible_generation: Annotated[
531
- Optional[bool],
532
- Field(
533
- True,
534
- alias="enableFlexibleGeneration",
535
- description="If true, then the trained generator can be used for rebalancing and imputation.\n",
536
- ),
537
- ] = True
538
- value_protection: Annotated[
539
- Optional[bool],
540
- Field(
541
- True,
542
- alias="valueProtection",
543
- description="Defines if Rare Category, Extreme value, or Sequence length protection will be applied.\n",
544
- ),
545
- ] = True
546
- rare_category_replacement_method: Annotated[
547
- Optional[RareCategoryReplacementMethod],
548
- Field(
549
- "CONSTANT",
550
- alias="rareCategoryReplacementMethod",
551
- description="Specifies, if the rare categories for categoricals will be replaced by a constant\n_RARE_ or by a sample from non-rare categories.\n",
552
- ),
553
- ] = "CONSTANT"
554
-
555
-
556
472
  class Accuracy(CustomBaseModel):
557
473
  overall: Annotated[
558
474
  Optional[float],
@@ -758,71 +674,6 @@ class SyntheticTableFairness(CustomBaseModel):
758
674
  sensitive_columns: Annotated[List[str], Field(alias="sensitiveColumns")]
759
675
 
760
676
 
761
- class SyntheticTableConfiguration(CustomBaseModel):
762
- """
763
- The sample configuration for a synthetic table
764
- """
765
-
766
- sample_size: Annotated[
767
- Optional[int],
768
- Field(
769
- None,
770
- alias="sampleSize",
771
- description="Number of generated samples. Only applicable for subject tables.\nIf neither size nor seed is provided, then the default behavior for Synthetic Datasets is to generate the\nsame size of samples as the original, and the default behavior for Synthetic Datasets is to generate one\nsubject only.\n",
772
- ge=1,
773
- ),
774
- ] = None
775
- sample_seed_connector_id: Annotated[
776
- Optional[str],
777
- Field(
778
- None,
779
- alias="sampleSeedConnectorId",
780
- description="The connector id of the seed data for conditional generation.\nOnly applicable for subject tables.\n",
781
- ),
782
- ] = None
783
- sample_seed_dict: Annotated[
784
- Optional[str],
785
- Field(
786
- None,
787
- alias="sampleSeedDict",
788
- description="The base64-encoded string derived from a json line file containing the specified sample seed data.\n",
789
- ),
790
- ] = None
791
- sample_seed_data: Annotated[
792
- Optional[str],
793
- Field(
794
- None,
795
- alias="sampleSeedData",
796
- description="The base64-encoded string derived from a Parquet file containing the specified sample seed data.\n",
797
- ),
798
- ] = None
799
- sampling_temperature: Annotated[
800
- Optional[float],
801
- Field(
802
- None,
803
- alias="samplingTemperature",
804
- description="temperature for sampling",
805
- ge=0.0,
806
- le=10.0,
807
- ),
808
- ] = None
809
- sampling_top_p: Annotated[
810
- Optional[float],
811
- Field(
812
- None, alias="samplingTopP", description="topP for sampling", ge=0.0, le=1.0
813
- ),
814
- ] = None
815
- rebalancing: Optional[SyntheticTableRebalancing] = None
816
- imputation: Annotated[
817
- Optional[List[str]],
818
- Field(
819
- None,
820
- description="Specify a list of column names that are to be imputed.\nImputed columns will suppress the sampling of NULL values.\n",
821
- ),
822
- ] = None
823
- fairness: Optional[SyntheticTableFairness] = None
824
-
825
-
826
677
  class SyntheticTableName(RootModel[str]):
827
678
  root: Annotated[
828
679
  str,
@@ -850,52 +701,6 @@ class ForeignKey(CustomBaseModel):
850
701
  ]
851
702
 
852
703
 
853
- class SyntheticTable(CustomBaseModel):
854
- id: Annotated[
855
- Optional[str],
856
- Field(None, description="The unique identifier of a synthetic table"),
857
- ] = None
858
- name: Annotated[
859
- Optional[str],
860
- Field(
861
- None,
862
- description="The name of a source table. It must be unique within a generator.",
863
- ),
864
- ] = None
865
- configuration: Optional[SyntheticTableConfiguration] = None
866
- model_metrics: Annotated[
867
- Optional[ModelMetrics], Field(None, alias="modelMetrics")
868
- ] = None
869
- foreign_keys: Annotated[
870
- Optional[List[ForeignKey]],
871
- Field(None, alias="foreignKeys", description="The foreign keys of this table."),
872
- ] = None
873
- total_rows: Annotated[
874
- Optional[int],
875
- Field(
876
- None,
877
- alias="totalRows",
878
- description="The total number of rows for that table in the generated synthetic dataset.\n",
879
- ),
880
- ] = None
881
- total_datapoints: Annotated[
882
- Optional[int],
883
- Field(
884
- None,
885
- alias="totalDatapoints",
886
- description="The total number of datapoints for that table in the generated synthetic dataset.\n",
887
- ),
888
- ] = None
889
- source_table_total_rows: Annotated[
890
- Optional[int],
891
- Field(
892
- None,
893
- alias="sourceTableTotalRows",
894
- description="The total number of rows in the source table while fetching data for training.\n",
895
- ),
896
- ] = None
897
-
898
-
899
704
  class SyntheticDatasetDelivery(CustomBaseModel):
900
705
  overwrite_tables: Annotated[
901
706
  bool,
@@ -1003,6 +808,10 @@ class AssistantThreadSessionStatus(str, Enum):
1003
808
  expired = "expired"
1004
809
 
1005
810
 
811
+ class AssistantTokenUsage(RootModel[float]):
812
+ root: float
813
+
814
+
1006
815
  class AssistantMessageRole(str, Enum):
1007
816
  """
1008
817
  The role of the author of this message
@@ -1012,6 +821,7 @@ class AssistantMessageRole(str, Enum):
1012
821
  user = "user"
1013
822
  assistant = "assistant"
1014
823
  tool = "tool"
824
+ heartbeat = "heartbeat"
1015
825
 
1016
826
 
1017
827
  class AssistantMessageContentType(str, Enum):
@@ -1053,6 +863,14 @@ class AssistantMessage(CustomBaseModel):
1053
863
  finish_reason: Annotated[
1054
864
  Optional[AssistantMessageFinishReason], Field(None, alias="finishReason")
1055
865
  ] = None
866
+ tokens_consumed: Annotated[
867
+ Optional[float],
868
+ Field(
869
+ None,
870
+ alias="tokensConsumed",
871
+ description="The number of tokens consumed by the assistant message.",
872
+ ),
873
+ ] = None
1056
874
 
1057
875
 
1058
876
  class AssistantMessageDelta(CustomBaseModel):
@@ -1080,6 +898,14 @@ class AssistantMessageDelta(CustomBaseModel):
1080
898
  finish_reason: Annotated[
1081
899
  Optional[AssistantMessageFinishReason], Field(None, alias="finishReason")
1082
900
  ] = None
901
+ tokens_consumed: Annotated[
902
+ Optional[float],
903
+ Field(
904
+ None,
905
+ alias="tokensConsumed",
906
+ description="The number of tokens consumed by the model.",
907
+ ),
908
+ ] = None
1083
909
 
1084
910
 
1085
911
  class AssistantThreadUsage(CustomBaseModel):
@@ -1091,6 +917,52 @@ class AssistantThreadUsage(CustomBaseModel):
1091
917
  description="Number of shares of this assistant thread.",
1092
918
  ),
1093
919
  ] = None
920
+ total_tokens_consumed: Annotated[
921
+ Optional[float],
922
+ Field(
923
+ None,
924
+ alias="totalTokensConsumed",
925
+ description="The total number of tokens consumed by the thread.",
926
+ ),
927
+ ] = None
928
+
929
+
930
+ class ComputeResources(CustomBaseModel):
931
+ cpus: Annotated[
932
+ Optional[int], Field(None, description="The number of CPU cores")
933
+ ] = None
934
+ memory: Annotated[
935
+ Optional[float], Field(None, description="The amount of memory in GB")
936
+ ] = None
937
+ gpus: Annotated[Optional[int], Field(0, description="The number of GPUs")] = 0
938
+ gpu_memory: Annotated[
939
+ Optional[float],
940
+ Field(0, alias="gpuMemory", description="The amount of GPU memory in GB"),
941
+ ] = 0
942
+
943
+
944
+ class ComputeListItem(CustomBaseModel):
945
+ id: Optional[str] = None
946
+ type: Optional[Literal["KUBERNETES"]] = None
947
+ name: Optional[str] = None
948
+ resources: Optional[ComputeResources] = None
949
+
950
+
951
+ class Compute(CustomBaseModel):
952
+ id: Optional[str] = None
953
+ name: Optional[str] = None
954
+ type: Optional[Literal["KUBERNETES"]] = None
955
+ config: Optional[Dict[str, Any]] = None
956
+ secrets: Optional[Dict[str, Any]] = None
957
+ resources: Optional[ComputeResources] = None
958
+ order_index: Annotated[
959
+ Optional[int],
960
+ Field(
961
+ None,
962
+ alias="orderIndex",
963
+ description="The index for determining the sort order when listing computes",
964
+ ),
965
+ ] = None
1094
966
 
1095
967
 
1096
968
  class UsageReportPeriod(CustomBaseModel):
@@ -1210,24 +1082,320 @@ class GeneratorListItem(CustomBaseModel):
1210
1082
  ] = None
1211
1083
 
1212
1084
 
1213
- class SourceTable(CustomBaseModel):
1214
- id: Annotated[str, Field(description="The unique identifier of a source table")]
1215
- source_connector: Annotated[
1216
- Optional[BaseResource], Field(None, alias="sourceConnector")
1217
- ] = None
1218
- location: Annotated[
1085
+ class Probe(CustomBaseModel):
1086
+ name: Annotated[Optional[str], Field(None, description="The name of the table")] = (
1087
+ None
1088
+ )
1089
+ rows: Optional[List[Dict[str, Any]]] = None
1090
+
1091
+
1092
+ class ModelConfiguration(CustomBaseModel):
1093
+ """
1094
+ The training configuration for a AI model
1095
+ """
1096
+
1097
+ model: Annotated[
1219
1098
  Optional[str],
1220
1099
  Field(
1221
1100
  None,
1222
- description="The location of a source table. Together with the source connector it uniquely\nidentifies a source, and samples data from there.\n",
1101
+ description="The model to be used for training.",
1102
+ examples=[
1103
+ [
1104
+ "MOSTLY_AI/Small",
1105
+ "MOSTLY_AI/Medium",
1106
+ "MOSTLY_AI/Large",
1107
+ "MOSTLY_AI/LSTMFromScratch-3m",
1108
+ "microsoft/phi-1_5",
1109
+ "Locutusque/TinyMistral-248M",
1110
+ ]
1111
+ ],
1223
1112
  ),
1224
1113
  ] = None
1225
- name: Annotated[
1226
- str,
1114
+ max_sample_size: Annotated[
1115
+ Optional[int],
1227
1116
  Field(
1228
- description="The name of a source table. It must be unique within a generator."
1229
- ),
1230
- ]
1117
+ None,
1118
+ alias="maxSampleSize",
1119
+ description="The maximum number of samples to consider for training.\nIf not provided, then all available samples will be taken.\n",
1120
+ ge=1,
1121
+ le=1000000000,
1122
+ ),
1123
+ ] = None
1124
+ batch_size: Annotated[
1125
+ Optional[int],
1126
+ Field(
1127
+ None,
1128
+ alias="batchSize",
1129
+ description="The batch size used for training the model.\nIf not provided, batchSize will be chosen automatically.\n",
1130
+ ge=1,
1131
+ le=1000000,
1132
+ ),
1133
+ ] = None
1134
+ max_training_time: Annotated[
1135
+ Optional[int],
1136
+ Field(
1137
+ 10,
1138
+ alias="maxTrainingTime",
1139
+ description="The maximum number of minutes to train the model.",
1140
+ ge=0,
1141
+ le=100000,
1142
+ ),
1143
+ ] = 10
1144
+ max_epochs: Annotated[
1145
+ Optional[int],
1146
+ Field(
1147
+ 100,
1148
+ alias="maxEpochs",
1149
+ description="The maximum number of epochs to train the model.",
1150
+ ge=0,
1151
+ le=100000,
1152
+ ),
1153
+ ] = 100
1154
+ max_sequence_window: Annotated[
1155
+ Optional[int],
1156
+ Field(
1157
+ 100,
1158
+ alias="maxSequenceWindow",
1159
+ description="The maximum sequence window to consider for training.\nOnly applicable for TABULAR models.\n",
1160
+ ge=1,
1161
+ le=100000,
1162
+ ),
1163
+ ] = 100
1164
+ enable_flexible_generation: Annotated[
1165
+ Optional[bool],
1166
+ Field(
1167
+ True,
1168
+ alias="enableFlexibleGeneration",
1169
+ description="If true, then the trained generator can be used for rebalancing and imputation.\nOnly applicable for TABULAR models.\n",
1170
+ ),
1171
+ ] = True
1172
+ value_protection: Annotated[
1173
+ Optional[bool],
1174
+ Field(
1175
+ True,
1176
+ alias="valueProtection",
1177
+ description="Defines if Rare Category, Extreme value, or Sequence length protection will be applied.\n",
1178
+ ),
1179
+ ] = True
1180
+ rare_category_replacement_method: Annotated[
1181
+ Optional[RareCategoryReplacementMethod],
1182
+ Field(
1183
+ "CONSTANT",
1184
+ alias="rareCategoryReplacementMethod",
1185
+ description="Specifies, if the rare categories for categoricals will be replaced by a constant\n_RARE_ or by a sample from non-rare categories.\nOnly applicable if valueProtection is set to True.\n",
1186
+ ),
1187
+ ] = "CONSTANT"
1188
+ compute: Optional[str] = None
1189
+
1190
+
1191
+ class ProgressStep(CustomBaseModel):
1192
+ id: Optional[str] = None
1193
+ model_label: Annotated[
1194
+ Optional[str],
1195
+ Field(
1196
+ None,
1197
+ alias="modelLabel",
1198
+ description="The unique label for the model, consisting of table name and a suffix for the model type.\nThis will be empty for steps that are not related to a model.\n",
1199
+ examples=[["census:tabular", "census:language"]],
1200
+ ),
1201
+ ] = None
1202
+ step_code: Annotated[Optional[StepCode], Field(None, alias="stepCode")] = None
1203
+ start_date: Annotated[
1204
+ Optional[AwareDatetime],
1205
+ Field(
1206
+ None,
1207
+ alias="startDate",
1208
+ description="The UTC date and time when the job has started.\nIf the job has not started yet, then this is None.\n",
1209
+ examples=["2024-01-25T12:34:56Z"],
1210
+ ),
1211
+ ] = None
1212
+ end_date: Annotated[
1213
+ Optional[AwareDatetime],
1214
+ Field(
1215
+ None,
1216
+ alias="endDate",
1217
+ description="The UTC date and time when the job has ended.\nIf the job is still, then this is None.\n",
1218
+ examples=["2024-01-25T12:34:56Z"],
1219
+ ),
1220
+ ] = None
1221
+ messages: Optional[List[Dict[str, Any]]] = None
1222
+ error_message: Annotated[Optional[str], Field(None, alias="errorMessage")] = None
1223
+ progress: Optional[ProgressValue] = None
1224
+ status: Optional[ProgressStatus] = None
1225
+
1226
+
1227
+ class SyntheticTableConfiguration(CustomBaseModel):
1228
+ """
1229
+ The sample configuration for a synthetic table
1230
+ """
1231
+
1232
+ sample_size: Annotated[
1233
+ Optional[int],
1234
+ Field(
1235
+ None,
1236
+ alias="sampleSize",
1237
+ description="Number of generated samples. Only applicable for subject tables.\nIf neither size nor seed is provided, then the default behavior for Synthetic Datasets is to generate the\nsame size of samples as the original, and the default behavior for Synthetic Datasets is to generate one\nsubject only.\n",
1238
+ ge=1,
1239
+ ),
1240
+ ] = None
1241
+ sample_seed_connector_id: Annotated[
1242
+ Optional[str],
1243
+ Field(
1244
+ None,
1245
+ alias="sampleSeedConnectorId",
1246
+ description="The connector id of the seed data for conditional generation.\nOnly applicable for subject tables.\n",
1247
+ ),
1248
+ ] = None
1249
+ sample_seed_dict: Annotated[
1250
+ Optional[str],
1251
+ Field(
1252
+ None,
1253
+ alias="sampleSeedDict",
1254
+ description="The base64-encoded string derived from a json line file containing the specified sample seed data.\n",
1255
+ ),
1256
+ ] = None
1257
+ sample_seed_data: Annotated[
1258
+ Optional[str],
1259
+ Field(
1260
+ None,
1261
+ alias="sampleSeedData",
1262
+ description="The base64-encoded string derived from a Parquet file containing the specified sample seed data.\n",
1263
+ ),
1264
+ ] = None
1265
+ sampling_temperature: Annotated[
1266
+ Optional[float],
1267
+ Field(
1268
+ None,
1269
+ alias="samplingTemperature",
1270
+ description="temperature for sampling",
1271
+ ge=0.0,
1272
+ le=10.0,
1273
+ ),
1274
+ ] = None
1275
+ sampling_top_p: Annotated[
1276
+ Optional[float],
1277
+ Field(
1278
+ None, alias="samplingTopP", description="topP for sampling", ge=0.0, le=1.0
1279
+ ),
1280
+ ] = None
1281
+ rebalancing: Optional[SyntheticTableRebalancing] = None
1282
+ imputation: Annotated[
1283
+ Optional[List[str]],
1284
+ Field(
1285
+ None,
1286
+ description="Specify a list of column names that are to be imputed.\nImputed columns will suppress the sampling of NULL values.\n",
1287
+ ),
1288
+ ] = None
1289
+ fairness: Optional[SyntheticTableFairness] = None
1290
+ tabular_compute: Annotated[Optional[str], Field(None, alias="tabularCompute")] = (
1291
+ None
1292
+ )
1293
+ language_compute: Annotated[Optional[str], Field(None, alias="languageCompute")] = (
1294
+ None
1295
+ )
1296
+
1297
+
1298
+ class SyntheticTable(CustomBaseModel):
1299
+ id: Annotated[
1300
+ Optional[str],
1301
+ Field(None, description="The unique identifier of a synthetic table"),
1302
+ ] = None
1303
+ name: Annotated[
1304
+ Optional[str],
1305
+ Field(
1306
+ None,
1307
+ description="The name of a source table. It must be unique within a generator.",
1308
+ ),
1309
+ ] = None
1310
+ configuration: Optional[SyntheticTableConfiguration] = None
1311
+ model_metrics: Annotated[
1312
+ Optional[ModelMetrics], Field(None, alias="modelMetrics")
1313
+ ] = None
1314
+ foreign_keys: Annotated[
1315
+ Optional[List[ForeignKey]],
1316
+ Field(None, alias="foreignKeys", description="The foreign keys of this table."),
1317
+ ] = None
1318
+ total_rows: Annotated[
1319
+ Optional[int],
1320
+ Field(
1321
+ None,
1322
+ alias="totalRows",
1323
+ description="The total number of rows for that table in the generated synthetic dataset.\n",
1324
+ ),
1325
+ ] = None
1326
+ total_datapoints: Annotated[
1327
+ Optional[int],
1328
+ Field(
1329
+ None,
1330
+ alias="totalDatapoints",
1331
+ description="The total number of datapoints for that table in the generated synthetic dataset.\n",
1332
+ ),
1333
+ ] = None
1334
+ source_table_total_rows: Annotated[
1335
+ Optional[int],
1336
+ Field(
1337
+ None,
1338
+ alias="sourceTableTotalRows",
1339
+ description="The total number of rows in the source table while fetching data for training.\n",
1340
+ ),
1341
+ ] = None
1342
+
1343
+
1344
+ class AssistantThreadListItem(CustomBaseModel):
1345
+ id: Annotated[str, Field(description="The unique identifier of a assistant thread")]
1346
+ metadata: Metadata
1347
+ name: Annotated[
1348
+ Optional[str], Field(None, description="The name of a assistant thread")
1349
+ ] = None
1350
+ usage: Optional[AssistantThreadUsage] = None
1351
+
1352
+
1353
+ class AssistantThread(CustomBaseModel):
1354
+ id: Annotated[
1355
+ Optional[str],
1356
+ Field(None, description="The unique identifier of a assistant thread"),
1357
+ ] = None
1358
+ metadata: Optional[Metadata] = None
1359
+ name: Annotated[
1360
+ Optional[str], Field(None, description="The name of a assistant thread")
1361
+ ] = None
1362
+ session_status: Annotated[
1363
+ Optional[AssistantThreadSessionStatus], Field(None, alias="sessionStatus")
1364
+ ] = None
1365
+ messages: Annotated[
1366
+ Optional[List[AssistantMessage]],
1367
+ Field(
1368
+ None,
1369
+ description="List of all existing messages, excluding any system message.\nExample:\n What's the square root of 9? role: user type: text\n ok, I will write some python role: assistant type: text\n r = math.sqrt(9)\\nr role: assistant type: python\n 3 role: tool type: console\n The answer is 3! role: assistant type: text\n Plot me a random barplot role: user type: text\n ... plt.savefig() ... role: assistant type: python\n Here is ![img]() ... role: assistant type: text\n Write me a random file role: user type: text\n ... .to_csv() ... role: assistant type: python\n Here is [file]() ... role: assistant type: text\n",
1370
+ ),
1371
+ ] = None
1372
+ usage: Optional[AssistantThreadUsage] = None
1373
+
1374
+
1375
+ class Share(User):
1376
+ permission_level: Annotated[
1377
+ Optional[PermissionLevel], Field(None, alias="permissionLevel")
1378
+ ] = None
1379
+
1380
+
1381
+ class SourceTable(CustomBaseModel):
1382
+ id: Annotated[str, Field(description="The unique identifier of a source table")]
1383
+ source_connector: Annotated[
1384
+ Optional[BaseResource], Field(None, alias="sourceConnector")
1385
+ ] = None
1386
+ location: Annotated[
1387
+ Optional[str],
1388
+ Field(
1389
+ None,
1390
+ description="The location of a source table. Together with the source connector it uniquely\nidentifies a source, and samples data from there.\n",
1391
+ ),
1392
+ ] = None
1393
+ name: Annotated[
1394
+ str,
1395
+ Field(
1396
+ description="The name of a source table. It must be unique within a generator."
1397
+ ),
1398
+ ]
1231
1399
  primary_key: Annotated[
1232
1400
  Optional[str],
1233
1401
  Field(
@@ -1244,11 +1412,14 @@ class SourceTable(CustomBaseModel):
1244
1412
  model_metrics: Annotated[
1245
1413
  Optional[ModelMetrics], Field(None, alias="modelMetrics")
1246
1414
  ] = None
1415
+ language_model_metrics: Annotated[
1416
+ Optional[ModelMetrics], Field(None, alias="languageModelMetrics")
1417
+ ] = None
1247
1418
  model_configuration: Annotated[
1248
1419
  Optional[ModelConfiguration], Field(None, alias="modelConfiguration")
1249
1420
  ] = None
1250
- text_model_configuration: Annotated[
1251
- Optional[ModelConfiguration], Field(None, alias="textModelConfiguration")
1421
+ language_model_configuration: Annotated[
1422
+ Optional[ModelConfiguration], Field(None, alias="languageModelConfiguration")
1252
1423
  ] = None
1253
1424
  total_rows: Annotated[
1254
1425
  Optional[int],
@@ -1306,25 +1477,8 @@ class SourceTable(CustomBaseModel):
1306
1477
  )
1307
1478
 
1308
1479
 
1309
- class Probe(CustomBaseModel):
1310
- name: Annotated[Optional[str], Field(None, description="The name of the table")] = (
1311
- None
1312
- )
1313
- rows: Optional[List[Dict[str, Any]]] = None
1314
-
1315
-
1316
- class ProgressStep(CustomBaseModel):
1480
+ class JobProgress(CustomBaseModel):
1317
1481
  id: Optional[str] = None
1318
- model_label: Annotated[
1319
- Optional[str],
1320
- Field(
1321
- None,
1322
- alias="modelLabel",
1323
- description="The unique label for the model, consisting of table name and an optional suffix for text model.\nThis will be empty for steps that are not related to a model.\n",
1324
- examples=[["census", "census:text"]],
1325
- ),
1326
- ] = None
1327
- step_code: Annotated[Optional[StepCode], Field(None, alias="stepCode")] = None
1328
1482
  start_date: Annotated[
1329
1483
  Optional[AwareDatetime],
1330
1484
  Field(
@@ -1343,9 +1497,9 @@ class ProgressStep(CustomBaseModel):
1343
1497
  examples=["2024-01-25T12:34:56Z"],
1344
1498
  ),
1345
1499
  ] = None
1346
- messages: Optional[List[Dict[str, Any]]] = None
1347
1500
  progress: Optional[ProgressValue] = None
1348
1501
  status: Optional[ProgressStatus] = None
1502
+ steps: Optional[List[ProgressStep]] = None
1349
1503
 
1350
1504
 
1351
1505
  class SyntheticDataset(CustomBaseModel):
@@ -1493,43 +1647,6 @@ class SyntheticDataset(CustomBaseModel):
1493
1647
  )
1494
1648
 
1495
1649
 
1496
- class AssistantThreadListItem(CustomBaseModel):
1497
- id: Annotated[str, Field(description="The unique identifier of a assistant thread")]
1498
- metadata: Metadata
1499
- name: Annotated[
1500
- Optional[str], Field(None, description="The name of a assistant thread")
1501
- ] = None
1502
- usage: Optional[AssistantThreadUsage] = None
1503
-
1504
-
1505
- class AssistantThread(CustomBaseModel):
1506
- id: Annotated[
1507
- Optional[str],
1508
- Field(None, description="The unique identifier of a assistant thread"),
1509
- ] = None
1510
- metadata: Optional[Metadata] = None
1511
- name: Annotated[
1512
- Optional[str], Field(None, description="The name of a assistant thread")
1513
- ] = None
1514
- session_status: Annotated[
1515
- Optional[AssistantThreadSessionStatus], Field(None, alias="sessionStatus")
1516
- ] = None
1517
- messages: Annotated[
1518
- Optional[List[AssistantMessage]],
1519
- Field(
1520
- None,
1521
- description="List of all existing messages, excluding any system message.\nExample:\n What's the square root of 9? role: user type: text\n ok, I will write some python role: assistant type: text\n r = math.sqrt(9)\\nr role: assistant type: python\n 3 role: tool type: console\n The answer is 3! role: assistant type: text\n Plot me a random barplot role: user type: text\n ... plt.savefig() ... role: assistant type: python\n Here is ![img]() ... role: assistant type: text\n Write me a random file role: user type: text\n ... .to_csv() ... role: assistant type: python\n Here is [file]() ... role: assistant type: text\n",
1522
- ),
1523
- ] = None
1524
- usage: Optional[AssistantThreadUsage] = None
1525
-
1526
-
1527
- class Share(User):
1528
- permission_level: Annotated[
1529
- Optional[PermissionLevel], Field(None, alias="permissionLevel")
1530
- ] = None
1531
-
1532
-
1533
1650
  class Generator(CustomBaseModel):
1534
1651
  id: Annotated[str, Field(description="The unique identifier of a generator")]
1535
1652
  name: Annotated[
@@ -1654,28 +1771,3 @@ class Generator(CustomBaseModel):
1654
1771
  raise "Not implemented yet."
1655
1772
  # return self.generator.client._list_synthetic_datasets(self.generator.id)
1656
1773
  pass
1657
-
1658
-
1659
- class JobProgress(CustomBaseModel):
1660
- id: Optional[str] = None
1661
- start_date: Annotated[
1662
- Optional[AwareDatetime],
1663
- Field(
1664
- None,
1665
- alias="startDate",
1666
- description="The UTC date and time when the job has started.\nIf the job has not started yet, then this is None.\n",
1667
- examples=["2024-01-25T12:34:56Z"],
1668
- ),
1669
- ] = None
1670
- end_date: Annotated[
1671
- Optional[AwareDatetime],
1672
- Field(
1673
- None,
1674
- alias="endDate",
1675
- description="The UTC date and time when the job has ended.\nIf the job is still, then this is None.\n",
1676
- examples=["2024-01-25T12:34:56Z"],
1677
- ),
1678
- ] = None
1679
- progress: Optional[ProgressValue] = None
1680
- status: Optional[ProgressStatus] = None
1681
- steps: Optional[List[ProgressStep]] = None
@@ -1,6 +1,7 @@
1
1
  import base64
2
2
  import io
3
3
  import time
4
+ import warnings
4
5
  from pathlib import Path
5
6
  from typing import Callable, Union, Optional, Any, Literal
6
7
 
@@ -23,6 +24,8 @@ from mostlyai.model import (
23
24
  SyntheticDataset,
24
25
  )
25
26
 
27
+ warnings.simplefilter("always", DeprecationWarning)
28
+
26
29
 
27
30
  def _job_wait(
28
31
  get_progress: Callable,
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "mostlyai"
3
- version = "0.3.12"
3
+ version = "0.4.0"
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>"]
@@ -1,4 +0,0 @@
1
- from mostlyai.api import MostlyAI
2
-
3
- __all__ = ["MostlyAI"]
4
- __version__ = "0.3.12" # Do not set this manually. Use poetry version [params].
File without changes
File without changes