mostlyai 0.3.11__tar.gz → 0.3.13__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.11
3
+ Version: 0.3.13
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_report()` |
36
37
  | Info about the platform | `mostly.about()` |
37
38
 
38
39
 
@@ -141,10 +142,24 @@ sd.shares()
141
142
  c.shares()
142
143
  ```
143
144
 
145
+ ### Computes
146
+
147
+ ```python
148
+ l = mostly.computes.list()
149
+
150
+ cmp = mostly.computes.create(config)
151
+ cmp = mostly.computes.get(id)
152
+
153
+ cmp.update(config)
154
+ cmp.delete()
155
+ ```
156
+
144
157
  ### Info
145
158
 
146
159
  ```python
147
- mostly.about()
148
160
  mostly.me()
161
+ mostly.usage_report()
162
+ mostly.usage_report(by_periods=True)
163
+ mostly.about()
149
164
  ```
150
165
 
@@ -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_report()` |
14
15
  | Info about the platform | `mostly.about()` |
15
16
 
16
17
 
@@ -119,9 +120,23 @@ sd.shares()
119
120
  c.shares()
120
121
  ```
121
122
 
123
+ ### Computes
124
+
125
+ ```python
126
+ l = mostly.computes.list()
127
+
128
+ cmp = mostly.computes.create(config)
129
+ cmp = mostly.computes.get(id)
130
+
131
+ cmp.update(config)
132
+ cmp.delete()
133
+ ```
134
+
122
135
  ### Info
123
136
 
124
137
  ```python
125
- mostly.about()
126
138
  mostly.me()
139
+ mostly.usage_report()
140
+ mostly.usage_report(by_periods=True)
141
+ mostly.about()
127
142
  ```
@@ -1,4 +1,4 @@
1
1
  from mostlyai.api import MostlyAI
2
2
 
3
3
  __all__ = ["MostlyAI"]
4
- __version__ = "0.3.11" # Do not set this manually. Use poetry version [params].
4
+ __version__ = "0.3.13" # 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
 
@@ -5,6 +7,7 @@ import pandas as pd
5
7
  import rich
6
8
 
7
9
  from mostlyai.base import GET, _MostlyBaseClient
10
+ from mostlyai.computes import _MostlyComputesClient
8
11
  from mostlyai.connectors import _MostlyConnectorsClient
9
12
  from mostlyai.generators import _MostlyGeneratorsClient
10
13
  from mostlyai.model import (
@@ -59,6 +62,7 @@ class MostlyAI(_MostlyBaseClient):
59
62
  self.synthetic_datasets = _MostlySyntheticDatasetsClient(**client_kwargs)
60
63
  self.synthetic_probes = _MostlySyntheticProbesClient(**client_kwargs)
61
64
  self.shares = _MostlySharesClient(**client_kwargs)
65
+ self.computes = _MostlyComputesClient(**client_kwargs)
62
66
 
63
67
  def connect(self, config: dict[str, Any]) -> Connector:
64
68
  """
@@ -375,6 +379,24 @@ class MostlyAI(_MostlyBaseClient):
375
379
  """
376
380
  return self.request(verb=GET, path=["users", "me"], response_type=CurrentUser)
377
381
 
382
+ def usage_report(self, by_periods: bool = False) -> pd.DataFrame:
383
+ """
384
+ Retrieve usage report as a pd.DataFrame.
385
+
386
+ :param by_periods: if True, by periods. Otherwise, the overall usage report.
387
+ :return: summary of the usage (either by periods or overall)
388
+ """
389
+ headers = {"Accept": "*/*"} # Accept any content type
390
+ path = ["usage-report"] + (["periods"] if by_periods else ["download"])
391
+ response = self.request(verb=GET, headers=headers, path=path, raw_response=True)
392
+ if by_periods:
393
+ data = json.loads(response.content.decode("utf-8"))["usage"]
394
+ df = pd.DataFrame(data)
395
+ else:
396
+ csv_file = io.BytesIO(response.content)
397
+ df = pd.read_csv(csv_file)
398
+ return df
399
+
378
400
  def about(self) -> dict[str, Any]:
379
401
  """
380
402
  Retrieve about info from the endpoint.
@@ -0,0 +1,72 @@
1
+ from typing import Any
2
+
3
+ from mostlyai.base import DELETE, GET, POST, _MostlyBaseClient, PATCH
4
+ from mostlyai.model import (
5
+ Compute,
6
+ )
7
+
8
+
9
+ class _MostlyComputesClient(_MostlyBaseClient):
10
+ SECTION = ["computes"]
11
+
12
+ # PUBLIC METHODS #
13
+
14
+ def list(self) -> list[Compute]:
15
+ """
16
+ List the available computes, sorted by order index. The first returned compute is the default compute.
17
+
18
+ :return: List the available computes
19
+ """
20
+ response = self.request(verb=GET, path=[])
21
+ response = [Compute(**compute) for compute in response]
22
+ return response
23
+
24
+ def create(
25
+ self,
26
+ config: dict[str, Any],
27
+ ) -> Compute:
28
+ """
29
+ Create a compute. Only accessible for SuperAdmins.
30
+ The structures of the config and secrets parameters depend on the compute type.
31
+ ```yaml
32
+ - type: KUBERNETES
33
+ config:
34
+ toleration: string
35
+ - type: DATABRICKS
36
+ config:
37
+ instanceURL: string
38
+ clusterID: string
39
+ secrets:
40
+ token: string
41
+ ```
42
+ """
43
+ response = self.request(verb=POST, path=[], json=config, response_type=Compute)
44
+ return response
45
+
46
+ def get(self, compute_id: str) -> Compute:
47
+ """
48
+ Retrieve compute.
49
+
50
+ :param compute_id: The unique identifier of a compute
51
+ :return: The retrieved compute
52
+ """
53
+ response = self.request(verb=GET, path=[compute_id], response_type=Compute)
54
+ return response
55
+
56
+ # PRIVATE METHODS #
57
+
58
+ def _update(
59
+ self,
60
+ compute_id: str,
61
+ config: dict[str, Any],
62
+ ) -> Compute:
63
+ response = self.request(
64
+ verb=PATCH,
65
+ path=[compute_id],
66
+ json=config,
67
+ response_type=Compute,
68
+ )
69
+ return response
70
+
71
+ def _delete(self, compute_id: str) -> None:
72
+ self.request(verb=DELETE, path=[compute_id])
@@ -1,5 +1,5 @@
1
1
  # generated by datamodel-codegen:
2
- # timestamp: 2024-06-21T12:02:58+00:00
2
+ # timestamp: 2024-08-16T09:29:18+00:00
3
3
 
4
4
  from __future__ import annotations
5
5
 
@@ -464,95 +464,6 @@ class RareCategoryReplacementMethod(str, Enum):
464
464
  sample = "SAMPLE"
465
465
 
466
466
 
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
467
  class Accuracy(CustomBaseModel):
557
468
  overall: Annotated[
558
469
  Optional[float],
@@ -754,75 +665,8 @@ class SyntheticTableFairness(CustomBaseModel):
754
665
 
755
666
  """
756
667
 
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
761
-
762
-
763
- class SyntheticTableConfiguration(CustomBaseModel):
764
- """
765
- The sample configuration for a synthetic table
766
- """
767
-
768
- sample_size: Annotated[
769
- Optional[int],
770
- Field(
771
- None,
772
- alias="sampleSize",
773
- 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",
774
- ge=1,
775
- ),
776
- ] = None
777
- sample_seed_connector_id: Annotated[
778
- Optional[str],
779
- Field(
780
- None,
781
- alias="sampleSeedConnectorId",
782
- description="The connector id of the seed data for conditional generation.\nOnly applicable for subject tables.\n",
783
- ),
784
- ] = None
785
- sample_seed_dict: Annotated[
786
- Optional[str],
787
- Field(
788
- None,
789
- alias="sampleSeedDict",
790
- description="The base64-encoded string derived from a json line file containing the specified sample seed data.\n",
791
- ),
792
- ] = None
793
- sample_seed_data: Annotated[
794
- Optional[str],
795
- Field(
796
- None,
797
- alias="sampleSeedData",
798
- description="The base64-encoded string derived from a Parquet file containing the specified sample seed data.\n",
799
- ),
800
- ] = None
801
- sampling_temperature: Annotated[
802
- Optional[float],
803
- Field(
804
- None,
805
- alias="samplingTemperature",
806
- description="temperature for sampling",
807
- ge=0.0,
808
- le=10.0,
809
- ),
810
- ] = None
811
- sampling_top_p: Annotated[
812
- Optional[float],
813
- Field(
814
- None, alias="samplingTopP", description="topP for sampling", ge=0.0, le=1.0
815
- ),
816
- ] = None
817
- rebalancing: Optional[SyntheticTableRebalancing] = None
818
- imputation: Annotated[
819
- Optional[List[str]],
820
- Field(
821
- None,
822
- description="Specify a list of column names that are to be imputed.\nImputed columns will suppress the sampling of NULL values.\n",
823
- ),
824
- ] = None
825
- fairness: Optional[SyntheticTableFairness] = None
668
+ target_column: Annotated[str, Field(alias="targetColumn")]
669
+ sensitive_columns: Annotated[List[str], Field(alias="sensitiveColumns")]
826
670
 
827
671
 
828
672
  class SyntheticTableName(RootModel[str]):
@@ -852,52 +696,6 @@ class ForeignKey(CustomBaseModel):
852
696
  ]
853
697
 
854
698
 
855
- class SyntheticTable(CustomBaseModel):
856
- id: Annotated[
857
- Optional[str],
858
- Field(None, description="The unique identifier of a synthetic table"),
859
- ] = None
860
- name: Annotated[
861
- Optional[str],
862
- Field(
863
- None,
864
- description="The name of a source table. It must be unique within a generator.",
865
- ),
866
- ] = None
867
- configuration: Optional[SyntheticTableConfiguration] = None
868
- model_metrics: Annotated[
869
- Optional[ModelMetrics], Field(None, alias="modelMetrics")
870
- ] = None
871
- foreign_keys: Annotated[
872
- Optional[List[ForeignKey]],
873
- Field(None, alias="foreignKeys", description="The foreign keys of this table."),
874
- ] = None
875
- total_rows: Annotated[
876
- Optional[int],
877
- Field(
878
- None,
879
- alias="totalRows",
880
- description="The total number of rows for that table in the generated synthetic dataset.\n",
881
- ),
882
- ] = None
883
- total_datapoints: Annotated[
884
- Optional[int],
885
- Field(
886
- None,
887
- alias="totalDatapoints",
888
- description="The total number of datapoints for that table in the generated synthetic dataset.\n",
889
- ),
890
- ] = None
891
- source_table_total_rows: Annotated[
892
- Optional[int],
893
- Field(
894
- None,
895
- alias="sourceTableTotalRows",
896
- description="The total number of rows in the source table while fetching data for training.\n",
897
- ),
898
- ] = None
899
-
900
-
901
699
  class SyntheticDatasetDelivery(CustomBaseModel):
902
700
  overwrite_tables: Annotated[
903
701
  bool,
@@ -989,12 +787,20 @@ class AssistantSettings(CustomBaseModel):
989
787
  description="The custom instructions of the assistant",
990
788
  ),
991
789
  ] = None
790
+ default_system_instructions: Annotated[
791
+ Optional[str],
792
+ Field(
793
+ None,
794
+ alias="defaultSystemInstructions",
795
+ description="The system instructions of the assistant",
796
+ ),
797
+ ] = None
992
798
 
993
799
 
994
800
  class AssistantThreadSessionStatus(str, Enum):
995
- pending = "pending"
996
- active = "active"
997
- inactive = "inactive"
801
+ initializing = "initializing"
802
+ running = "running"
803
+ expired = "expired"
998
804
 
999
805
 
1000
806
  class AssistantMessageRole(str, Enum):
@@ -1016,6 +822,7 @@ class AssistantMessageContentType(str, Enum):
1016
822
  text = "text"
1017
823
  python = "python"
1018
824
  console = "console"
825
+ file = "file"
1019
826
 
1020
827
 
1021
828
  class AssistantMessageFinishReason(str, Enum):
@@ -1040,7 +847,34 @@ class AssistantMessage(CustomBaseModel):
1040
847
  content: Annotated[
1041
848
  Optional[str],
1042
849
  Field(
1043
- None, description="The content of a message", max_length=65000, min_length=1
850
+ None, description="The content of a message", max_length=65000, min_length=0
851
+ ),
852
+ ] = None
853
+ finish_reason: Annotated[
854
+ Optional[AssistantMessageFinishReason], Field(None, alias="finishReason")
855
+ ] = None
856
+
857
+
858
+ class AssistantMessageDelta(CustomBaseModel):
859
+ """
860
+ A partial message delta generated by streamed model responses.
861
+ """
862
+
863
+ id: Annotated[
864
+ Optional[str],
865
+ Field(None, description="The unique identifier of a assistant message"),
866
+ ] = None
867
+ role: Optional[AssistantMessageRole] = None
868
+ content_type: Annotated[
869
+ Optional[AssistantMessageContentType], Field(None, alias="contentType")
870
+ ] = None
871
+ delta: Annotated[
872
+ Optional[str],
873
+ Field(
874
+ None,
875
+ description="The partial content of a message",
876
+ max_length=65000,
877
+ min_length=1,
1044
878
  ),
1045
879
  ] = None
1046
880
  finish_reason: Annotated[
@@ -1048,111 +882,471 @@ class AssistantMessage(CustomBaseModel):
1048
882
  ] = None
1049
883
 
1050
884
 
1051
- class AssistantMessageDelta(CustomBaseModel):
885
+ class AssistantThreadUsage(CustomBaseModel):
886
+ no_of_shares: Annotated[
887
+ Optional[int],
888
+ Field(
889
+ None,
890
+ alias="noOfShares",
891
+ description="Number of shares of this assistant thread.",
892
+ ),
893
+ ] = None
894
+
895
+
896
+ class ComputeResources(CustomBaseModel):
897
+ cpus: Annotated[
898
+ Optional[int], Field(None, description="The number of CPU cores")
899
+ ] = None
900
+ memory: Annotated[
901
+ Optional[float], Field(None, description="The amount of memory in GB")
902
+ ] = None
903
+ gpus: Annotated[Optional[int], Field(0, description="The number of GPUs")] = 0
904
+ gpu_memory: Annotated[
905
+ Optional[float],
906
+ Field(0, alias="gpuMemory", description="The amount of GPU memory in GB"),
907
+ ] = 0
908
+
909
+
910
+ class ComputeListItem(CustomBaseModel):
911
+ id: Optional[str] = None
912
+ type: Optional[Literal["KUBERNETES"]] = None
913
+ name: Optional[str] = None
914
+ resources: Optional[ComputeResources] = None
915
+
916
+
917
+ class Compute(CustomBaseModel):
918
+ id: Optional[str] = None
919
+ name: Optional[str] = None
920
+ type: Optional[Literal["KUBERNETES"]] = None
921
+ config: Optional[Dict[str, Any]] = None
922
+ secrets: Optional[Dict[str, Any]] = None
923
+ resources: Optional[ComputeResources] = None
924
+ order_index: Annotated[
925
+ Optional[int],
926
+ Field(
927
+ None,
928
+ alias="orderIndex",
929
+ description="The index for determining the sort order when listing computes",
930
+ ),
931
+ ] = None
932
+
933
+ def update(self, config) -> "Compute":
934
+ """
935
+ Update a compute. Only accessible for SuperAdmins.
936
+
937
+ For the structure of the config and secrets, see the CREATE method.
938
+
939
+ :return: The updated compute
940
+ """
941
+ return self.client._update(compute_id=self.id, config=config)
942
+
943
+ def delete(self):
944
+ """
945
+ Delete compute. Only accessible for SuperAdmins.
946
+ """
947
+ return self.client._delete(compute_id=self.id)
948
+
949
+
950
+ class UsageReportPeriod(CustomBaseModel):
951
+ """
952
+ The usage report for a specific month
953
+ """
954
+
955
+ period_start: Annotated[
956
+ Optional[AwareDatetime],
957
+ Field(
958
+ None,
959
+ alias="periodStart",
960
+ description="The UTC date and time when the reported time period started",
961
+ ),
962
+ ] = None
963
+ period_end: Annotated[
964
+ Optional[AwareDatetime],
965
+ Field(
966
+ None,
967
+ alias="periodEnd",
968
+ description="The UTC date and time when the reported time period started",
969
+ ),
970
+ ] = None
971
+ total_datapoints: Annotated[
972
+ Optional[int],
973
+ Field(
974
+ None,
975
+ alias="totalDatapoints",
976
+ description="The number of datapoints generated during the reported period",
977
+ ),
978
+ ] = None
979
+ total_rows: Annotated[
980
+ Optional[int],
981
+ Field(
982
+ None,
983
+ alias="totalRows",
984
+ description="The number of rows generated during the reported period",
985
+ ),
986
+ ] = None
987
+ total_credits: Annotated[
988
+ Optional[float],
989
+ Field(
990
+ None,
991
+ alias="totalCredits",
992
+ description="The number of credits used during the reported period",
993
+ ),
994
+ ] = None
995
+
996
+
997
+ class BaseResource(CustomBaseModel):
998
+ id: Annotated[
999
+ Optional[str], Field(None, description="The unique identifier of the entity")
1000
+ ] = None
1001
+ name: Annotated[
1002
+ Optional[str], Field(None, description="The name of the entity")
1003
+ ] = None
1004
+ uri: Annotated[
1005
+ Optional[str],
1006
+ Field(
1007
+ None,
1008
+ description="The API service endpoint of the entity",
1009
+ examples=["/generators/94c77249-42bf-443a-8e17-6e18a19d60b8"],
1010
+ ),
1011
+ ] = None
1012
+ current_user_permission_level: Annotated[
1013
+ Optional[PermissionLevel], Field(None, alias="currentUserPermissionLevel")
1014
+ ] = None
1015
+
1016
+
1017
+ class User(CustomBaseModel):
1018
+ id: Annotated[
1019
+ Optional[str], Field(None, description="The unique identifier of a user")
1020
+ ] = None
1021
+ name: Annotated[Optional[str], Field(None, description="The name of a user")] = None
1022
+ email: Annotated[Optional[str], Field(None, description="The email of a user")] = (
1023
+ None
1024
+ )
1025
+
1026
+
1027
+ class CurrentUser(CustomBaseModel):
1028
+ id: Annotated[
1029
+ Optional[str], Field(None, description="The unique identifier of a user")
1030
+ ] = None
1031
+ name: Annotated[Optional[str], Field(None, description="The name of a user")] = None
1032
+ email: Annotated[Optional[str], Field(None, description="The email of a user")] = (
1033
+ None
1034
+ )
1035
+ settings: Optional[Dict[str, Any]] = None
1036
+ usage: Optional[UserUsage] = None
1037
+
1038
+
1039
+ class GeneratorListItem(CustomBaseModel):
1040
+ id: Annotated[str, Field(description="The unique identifier of a generator")]
1041
+ name: Annotated[
1042
+ Optional[str], Field(None, description="The name of a generator")
1043
+ ] = None
1044
+ description: Annotated[
1045
+ Optional[str], Field(None, description="The description of a generator")
1046
+ ] = None
1047
+ training_status: Annotated[ProgressStatus, Field(alias="trainingStatus")]
1048
+ training_time: Annotated[
1049
+ Optional[AwareDatetime],
1050
+ Field(
1051
+ None,
1052
+ alias="trainingTime",
1053
+ description="The UTC date and time when the training has finished.",
1054
+ ),
1055
+ ] = None
1056
+ usage: Optional[GeneratorUsage] = None
1057
+ metadata: Metadata
1058
+ accuracy: Annotated[
1059
+ Optional[float],
1060
+ Field(
1061
+ None,
1062
+ description="The overall accuracy of the trained generator.\nThis is the average of the overall accuracy scores of all trained models.\n",
1063
+ ),
1064
+ ] = None
1065
+
1066
+
1067
+ class Probe(CustomBaseModel):
1068
+ name: Annotated[Optional[str], Field(None, description="The name of the table")] = (
1069
+ None
1070
+ )
1071
+ rows: Optional[List[Dict[str, Any]]] = None
1072
+
1073
+
1074
+ class ModelConfiguration(CustomBaseModel):
1075
+ """
1076
+ The training configuration for a AI model
1077
+ """
1078
+
1079
+ max_sample_size: Annotated[
1080
+ Optional[int],
1081
+ Field(
1082
+ None,
1083
+ alias="maxSampleSize",
1084
+ description="The maximum number of samples to consider for training.\nIf not provided, then all available samples will be taken.\n",
1085
+ ge=1,
1086
+ le=1000000000,
1087
+ ),
1088
+ ] = None
1089
+ batch_size: Annotated[
1090
+ Optional[int],
1091
+ Field(
1092
+ None,
1093
+ alias="batchSize",
1094
+ description="The batch size used for training the model.\nIf not provided, batchSize will be chosen automatically.\n",
1095
+ ge=1,
1096
+ le=1000000,
1097
+ ),
1098
+ ] = None
1099
+ model_size: Annotated[
1100
+ Optional[ModelSize],
1101
+ Field(
1102
+ "M",
1103
+ alias="modelSize",
1104
+ 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",
1105
+ ),
1106
+ ] = "M"
1107
+ max_training_time: Annotated[
1108
+ Optional[int],
1109
+ Field(
1110
+ 10,
1111
+ alias="maxTrainingTime",
1112
+ description="The maximum number of minutes to train the model.",
1113
+ ge=0,
1114
+ le=100000,
1115
+ ),
1116
+ ] = 10
1117
+ max_epochs: Annotated[
1118
+ Optional[int],
1119
+ Field(
1120
+ 100,
1121
+ alias="maxEpochs",
1122
+ description="The maximum number of epochs to train the model.",
1123
+ ge=0,
1124
+ le=100000,
1125
+ ),
1126
+ ] = 100
1127
+ max_sequence_window: Annotated[
1128
+ Optional[int],
1129
+ Field(
1130
+ 100,
1131
+ alias="maxSequenceWindow",
1132
+ description="The maximum sequence window to consider for training.",
1133
+ ge=1,
1134
+ le=100000,
1135
+ ),
1136
+ ] = 100
1137
+ enable_flexible_generation: Annotated[
1138
+ Optional[bool],
1139
+ Field(
1140
+ True,
1141
+ alias="enableFlexibleGeneration",
1142
+ description="If true, then the trained generator can be used for rebalancing and imputation.\n",
1143
+ ),
1144
+ ] = True
1145
+ value_protection: Annotated[
1146
+ Optional[bool],
1147
+ Field(
1148
+ True,
1149
+ alias="valueProtection",
1150
+ description="Defines if Rare Category, Extreme value, or Sequence length protection will be applied.\n",
1151
+ ),
1152
+ ] = True
1153
+ rare_category_replacement_method: Annotated[
1154
+ Optional[RareCategoryReplacementMethod],
1155
+ Field(
1156
+ "CONSTANT",
1157
+ alias="rareCategoryReplacementMethod",
1158
+ 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",
1159
+ ),
1160
+ ] = "CONSTANT"
1161
+ compute: Optional[str] = None
1162
+
1163
+
1164
+ class ProgressStep(CustomBaseModel):
1165
+ id: Optional[str] = None
1166
+ model_label: Annotated[
1167
+ Optional[str],
1168
+ Field(
1169
+ None,
1170
+ alias="modelLabel",
1171
+ 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",
1172
+ examples=[["census", "census:text"]],
1173
+ ),
1174
+ ] = None
1175
+ step_code: Annotated[Optional[StepCode], Field(None, alias="stepCode")] = None
1176
+ start_date: Annotated[
1177
+ Optional[AwareDatetime],
1178
+ Field(
1179
+ None,
1180
+ alias="startDate",
1181
+ description="The UTC date and time when the job has started.\nIf the job has not started yet, then this is None.\n",
1182
+ examples=["2024-01-25T12:34:56Z"],
1183
+ ),
1184
+ ] = None
1185
+ end_date: Annotated[
1186
+ Optional[AwareDatetime],
1187
+ Field(
1188
+ None,
1189
+ alias="endDate",
1190
+ description="The UTC date and time when the job has ended.\nIf the job is still, then this is None.\n",
1191
+ examples=["2024-01-25T12:34:56Z"],
1192
+ ),
1193
+ ] = None
1194
+ messages: Optional[List[Dict[str, Any]]] = None
1195
+ progress: Optional[ProgressValue] = None
1196
+ status: Optional[ProgressStatus] = None
1197
+
1198
+
1199
+ class SyntheticTableConfiguration(CustomBaseModel):
1052
1200
  """
1053
- A partial message delta generated by streamed model responses.
1201
+ The sample configuration for a synthetic table
1054
1202
  """
1055
1203
 
1056
- id: Annotated[
1204
+ sample_size: Annotated[
1205
+ Optional[int],
1206
+ Field(
1207
+ None,
1208
+ alias="sampleSize",
1209
+ 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",
1210
+ ge=1,
1211
+ ),
1212
+ ] = None
1213
+ sample_seed_connector_id: Annotated[
1057
1214
  Optional[str],
1058
- Field(None, description="The unique identifier of a assistant message"),
1215
+ Field(
1216
+ None,
1217
+ alias="sampleSeedConnectorId",
1218
+ description="The connector id of the seed data for conditional generation.\nOnly applicable for subject tables.\n",
1219
+ ),
1059
1220
  ] = None
1060
- role: Optional[AssistantMessageRole] = None
1061
- content_type: Annotated[
1062
- Optional[AssistantMessageContentType], Field(None, alias="contentType")
1221
+ sample_seed_dict: Annotated[
1222
+ Optional[str],
1223
+ Field(
1224
+ None,
1225
+ alias="sampleSeedDict",
1226
+ description="The base64-encoded string derived from a json line file containing the specified sample seed data.\n",
1227
+ ),
1063
1228
  ] = None
1064
- delta: Annotated[
1229
+ sample_seed_data: Annotated[
1065
1230
  Optional[str],
1066
1231
  Field(
1067
1232
  None,
1068
- description="The partial content of a message",
1069
- max_length=65000,
1070
- min_length=1,
1233
+ alias="sampleSeedData",
1234
+ description="The base64-encoded string derived from a Parquet file containing the specified sample seed data.\n",
1071
1235
  ),
1072
1236
  ] = None
1073
- finish_reason: Annotated[
1074
- Optional[AssistantMessageFinishReason], Field(None, alias="finishReason")
1237
+ sampling_temperature: Annotated[
1238
+ Optional[float],
1239
+ Field(
1240
+ None,
1241
+ alias="samplingTemperature",
1242
+ description="temperature for sampling",
1243
+ ge=0.0,
1244
+ le=10.0,
1245
+ ),
1075
1246
  ] = None
1076
-
1077
-
1078
- class AssistantThreadUsage(CustomBaseModel):
1079
- no_of_shares: Annotated[
1080
- Optional[int],
1247
+ sampling_top_p: Annotated[
1248
+ Optional[float],
1249
+ Field(
1250
+ None, alias="samplingTopP", description="topP for sampling", ge=0.0, le=1.0
1251
+ ),
1252
+ ] = None
1253
+ rebalancing: Optional[SyntheticTableRebalancing] = None
1254
+ imputation: Annotated[
1255
+ Optional[List[str]],
1081
1256
  Field(
1082
1257
  None,
1083
- alias="noOfShares",
1084
- description="Number of shares of this assistant thread.",
1258
+ description="Specify a list of column names that are to be imputed.\nImputed columns will suppress the sampling of NULL values.\n",
1085
1259
  ),
1086
1260
  ] = None
1261
+ fairness: Optional[SyntheticTableFairness] = None
1262
+ tabular_compute: Annotated[Optional[str], Field(None, alias="tabularCompute")] = (
1263
+ None
1264
+ )
1265
+ language_compute: Annotated[Optional[str], Field(None, alias="languageCompute")] = (
1266
+ None
1267
+ )
1087
1268
 
1088
1269
 
1089
- class BaseResource(CustomBaseModel):
1270
+ class SyntheticTable(CustomBaseModel):
1090
1271
  id: Annotated[
1091
- Optional[str], Field(None, description="The unique identifier of the entity")
1272
+ Optional[str],
1273
+ Field(None, description="The unique identifier of a synthetic table"),
1092
1274
  ] = None
1093
1275
  name: Annotated[
1094
- Optional[str], Field(None, description="The name of the entity")
1095
- ] = None
1096
- uri: Annotated[
1097
1276
  Optional[str],
1098
1277
  Field(
1099
1278
  None,
1100
- description="The API service endpoint of the entity",
1101
- examples=["/generators/94c77249-42bf-443a-8e17-6e18a19d60b8"],
1279
+ description="The name of a source table. It must be unique within a generator.",
1102
1280
  ),
1103
1281
  ] = None
1104
- current_user_permission_level: Annotated[
1105
- Optional[PermissionLevel], Field(None, alias="currentUserPermissionLevel")
1282
+ configuration: Optional[SyntheticTableConfiguration] = None
1283
+ model_metrics: Annotated[
1284
+ Optional[ModelMetrics], Field(None, alias="modelMetrics")
1285
+ ] = None
1286
+ foreign_keys: Annotated[
1287
+ Optional[List[ForeignKey]],
1288
+ Field(None, alias="foreignKeys", description="The foreign keys of this table."),
1289
+ ] = None
1290
+ total_rows: Annotated[
1291
+ Optional[int],
1292
+ Field(
1293
+ None,
1294
+ alias="totalRows",
1295
+ description="The total number of rows for that table in the generated synthetic dataset.\n",
1296
+ ),
1297
+ ] = None
1298
+ total_datapoints: Annotated[
1299
+ Optional[int],
1300
+ Field(
1301
+ None,
1302
+ alias="totalDatapoints",
1303
+ description="The total number of datapoints for that table in the generated synthetic dataset.\n",
1304
+ ),
1305
+ ] = None
1306
+ source_table_total_rows: Annotated[
1307
+ Optional[int],
1308
+ Field(
1309
+ None,
1310
+ alias="sourceTableTotalRows",
1311
+ description="The total number of rows in the source table while fetching data for training.\n",
1312
+ ),
1106
1313
  ] = None
1107
1314
 
1108
1315
 
1109
- class User(CustomBaseModel):
1110
- id: Annotated[
1111
- Optional[str], Field(None, description="The unique identifier of a user")
1316
+ class AssistantThreadListItem(CustomBaseModel):
1317
+ id: Annotated[str, Field(description="The unique identifier of a assistant thread")]
1318
+ metadata: Metadata
1319
+ name: Annotated[
1320
+ Optional[str], Field(None, description="The name of a assistant thread")
1112
1321
  ] = None
1113
- name: Annotated[Optional[str], Field(None, description="The name of a user")] = None
1114
- email: Annotated[Optional[str], Field(None, description="The email of a user")] = (
1115
- None
1116
- )
1322
+ usage: Optional[AssistantThreadUsage] = None
1117
1323
 
1118
1324
 
1119
- class CurrentUser(CustomBaseModel):
1325
+ class AssistantThread(CustomBaseModel):
1120
1326
  id: Annotated[
1121
- Optional[str], Field(None, description="The unique identifier of a user")
1327
+ Optional[str],
1328
+ Field(None, description="The unique identifier of a assistant thread"),
1122
1329
  ] = None
1123
- name: Annotated[Optional[str], Field(None, description="The name of a user")] = None
1124
- email: Annotated[Optional[str], Field(None, description="The email of a user")] = (
1125
- None
1126
- )
1127
- settings: Optional[Dict[str, Any]] = None
1128
- usage: Optional[UserUsage] = None
1129
-
1130
-
1131
- class GeneratorListItem(CustomBaseModel):
1132
- id: Annotated[str, Field(description="The unique identifier of a generator")]
1330
+ metadata: Optional[Metadata] = None
1133
1331
  name: Annotated[
1134
- Optional[str], Field(None, description="The name of a generator")
1332
+ Optional[str], Field(None, description="The name of a assistant thread")
1135
1333
  ] = None
1136
- description: Annotated[
1137
- Optional[str], Field(None, description="The description of a generator")
1334
+ session_status: Annotated[
1335
+ Optional[AssistantThreadSessionStatus], Field(None, alias="sessionStatus")
1138
1336
  ] = None
1139
- training_status: Annotated[ProgressStatus, Field(alias="trainingStatus")]
1140
- training_time: Annotated[
1141
- Optional[AwareDatetime],
1337
+ messages: Annotated[
1338
+ Optional[List[AssistantMessage]],
1142
1339
  Field(
1143
1340
  None,
1144
- alias="trainingTime",
1145
- description="The UTC date and time when the training has finished.",
1341
+ 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",
1146
1342
  ),
1147
1343
  ] = None
1148
- usage: Optional[GeneratorUsage] = None
1149
- metadata: Metadata
1150
- accuracy: Annotated[
1151
- Optional[float],
1152
- Field(
1153
- None,
1154
- description="The overall accuracy of the trained generator.\nThis is the average of the overall accuracy scores of all trained models.\n",
1155
- ),
1344
+ usage: Optional[AssistantThreadUsage] = None
1345
+
1346
+
1347
+ class Share(User):
1348
+ permission_level: Annotated[
1349
+ Optional[PermissionLevel], Field(None, alias="permissionLevel")
1156
1350
  ] = None
1157
1351
 
1158
1352
 
@@ -1252,25 +1446,8 @@ class SourceTable(CustomBaseModel):
1252
1446
  )
1253
1447
 
1254
1448
 
1255
- class Probe(CustomBaseModel):
1256
- name: Annotated[Optional[str], Field(None, description="The name of the table")] = (
1257
- None
1258
- )
1259
- rows: Optional[List[Dict[str, Any]]] = None
1260
-
1261
-
1262
- class ProgressStep(CustomBaseModel):
1449
+ class JobProgress(CustomBaseModel):
1263
1450
  id: Optional[str] = None
1264
- model_label: Annotated[
1265
- Optional[str],
1266
- Field(
1267
- None,
1268
- alias="modelLabel",
1269
- 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",
1270
- examples=[["census", "census:text"]],
1271
- ),
1272
- ] = None
1273
- step_code: Annotated[Optional[StepCode], Field(None, alias="stepCode")] = None
1274
1451
  start_date: Annotated[
1275
1452
  Optional[AwareDatetime],
1276
1453
  Field(
@@ -1289,9 +1466,9 @@ class ProgressStep(CustomBaseModel):
1289
1466
  examples=["2024-01-25T12:34:56Z"],
1290
1467
  ),
1291
1468
  ] = None
1292
- messages: Optional[List[Dict[str, Any]]] = None
1293
1469
  progress: Optional[ProgressValue] = None
1294
1470
  status: Optional[ProgressStatus] = None
1471
+ steps: Optional[List[ProgressStep]] = None
1295
1472
 
1296
1473
 
1297
1474
  class SyntheticDataset(CustomBaseModel):
@@ -1439,43 +1616,6 @@ class SyntheticDataset(CustomBaseModel):
1439
1616
  )
1440
1617
 
1441
1618
 
1442
- class AssistantThreadListItem(CustomBaseModel):
1443
- id: Annotated[str, Field(description="The unique identifier of a assistant thread")]
1444
- metadata: Metadata
1445
- name: Annotated[
1446
- Optional[str], Field(None, description="The name of a assistant thread")
1447
- ] = None
1448
- usage: Optional[AssistantThreadUsage] = None
1449
-
1450
-
1451
- class AssistantThread(CustomBaseModel):
1452
- id: Annotated[
1453
- Optional[str],
1454
- Field(None, description="The unique identifier of a assistant thread"),
1455
- ] = None
1456
- metadata: Optional[Metadata] = None
1457
- name: Annotated[
1458
- Optional[str], Field(None, description="The name of a assistant thread")
1459
- ] = None
1460
- session_status: Annotated[
1461
- Optional[AssistantThreadSessionStatus], Field(None, alias="sessionStatus")
1462
- ] = None
1463
- messages: Annotated[
1464
- Optional[List[AssistantMessage]],
1465
- Field(
1466
- None,
1467
- 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",
1468
- ),
1469
- ] = None
1470
- usage: Optional[AssistantThreadUsage] = None
1471
-
1472
-
1473
- class Share(User):
1474
- permission_level: Annotated[
1475
- Optional[PermissionLevel], Field(None, alias="permissionLevel")
1476
- ] = None
1477
-
1478
-
1479
1619
  class Generator(CustomBaseModel):
1480
1620
  id: Annotated[str, Field(description="The unique identifier of a generator")]
1481
1621
  name: Annotated[
@@ -1545,11 +1685,9 @@ class Generator(CustomBaseModel):
1545
1685
  file_path: Union[str, Path, None] = None,
1546
1686
  ) -> Path:
1547
1687
  """
1548
- Export generator and save to file.
1549
- Supported from release v212 onwards.
1688
+ Export generator and save to file
1550
1689
 
1551
- :param file_path: Optional. The file path to save the synthetic dataset.
1552
- :return: The file path of the exported generator
1690
+ :param file_path: The file path to save the synthetic dataset
1553
1691
  """
1554
1692
  bytes, filename = self.client._export_to_file(generator_id=self.id)
1555
1693
  file_path = Path(file_path or ".")
@@ -1602,28 +1740,3 @@ class Generator(CustomBaseModel):
1602
1740
  raise "Not implemented yet."
1603
1741
  # return self.generator.client._list_synthetic_datasets(self.generator.id)
1604
1742
  pass
1605
-
1606
-
1607
- class JobProgress(CustomBaseModel):
1608
- id: Optional[str] = None
1609
- start_date: Annotated[
1610
- Optional[AwareDatetime],
1611
- Field(
1612
- None,
1613
- alias="startDate",
1614
- description="The UTC date and time when the job has started.\nIf the job has not started yet, then this is None.\n",
1615
- examples=["2024-01-25T12:34:56Z"],
1616
- ),
1617
- ] = None
1618
- end_date: Annotated[
1619
- Optional[AwareDatetime],
1620
- Field(
1621
- None,
1622
- alias="endDate",
1623
- description="The UTC date and time when the job has ended.\nIf the job is still, then this is None.\n",
1624
- examples=["2024-01-25T12:34:56Z"],
1625
- ),
1626
- ] = None
1627
- progress: Optional[ProgressValue] = None
1628
- status: Optional[ProgressStatus] = None
1629
- steps: Optional[List[ProgressStep]] = None
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "mostlyai"
3
- version = "0.3.11"
3
+ version = "0.3.13"
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