snowflake-ml-python 2.1.0__py3-none-any.whl → 2.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- snowflake/cortex/_classify_text.py +9 -9
- snowflake/cortex/_complete.py +50 -51
- snowflake/cortex/_embed_text_1024.py +9 -9
- snowflake/cortex/_embed_text_768.py +9 -9
- snowflake/cortex/_extract_answer.py +9 -9
- snowflake/cortex/_finetune.py +22 -22
- snowflake/cortex/_sentiment.py +4 -6
- snowflake/cortex/_sse_client.py +4 -4
- snowflake/cortex/_summarize.py +7 -7
- snowflake/cortex/_translate.py +11 -11
- snowflake/cortex/_util.py +9 -9
- snowflake/ml/_internal/file_utils.py +19 -19
- snowflake/ml/_internal/lineage/lineage_utils.py +4 -4
- snowflake/ml/_internal/platform_capabilities.py +22 -6
- snowflake/ml/_internal/telemetry.py +42 -55
- snowflake/ml/_internal/type_utils.py +3 -3
- snowflake/ml/_internal/utils/connection_params.py +3 -4
- snowflake/ml/_internal/utils/db_utils.py +4 -4
- snowflake/ml/_internal/utils/identifier.py +8 -8
- snowflake/ml/_internal/utils/jwt_generator.py +3 -4
- snowflake/ml/_internal/utils/mixins.py +8 -8
- snowflake/ml/_internal/utils/parallelize.py +3 -3
- snowflake/ml/_internal/utils/pkg_version_utils.py +5 -6
- snowflake/ml/_internal/utils/query_result_checker.py +9 -9
- snowflake/ml/_internal/utils/service_logger.py +4 -5
- snowflake/ml/_internal/utils/snowflake_env.py +6 -8
- snowflake/ml/_internal/utils/snowpark_dataframe_utils.py +1 -2
- snowflake/ml/_internal/utils/sql_identifier.py +8 -10
- snowflake/ml/_internal/utils/table_manager.py +2 -2
- snowflake/ml/_internal/utils/tee.py +2 -2
- snowflake/ml/_internal/utils/temp_file_utils.py +2 -2
- snowflake/ml/data/_internal/arrow_ingestor.py +5 -7
- snowflake/ml/data/data_connector.py +14 -24
- snowflake/ml/data/data_ingestor.py +2 -2
- snowflake/ml/data/data_source.py +4 -4
- snowflake/ml/data/ingestor_utils.py +3 -5
- snowflake/ml/data/torch_utils.py +4 -4
- snowflake/ml/dataset/dataset.py +18 -18
- snowflake/ml/dataset/dataset_metadata.py +9 -9
- snowflake/ml/dataset/dataset_reader.py +5 -5
- snowflake/ml/experiment/_entities/run.py +4 -4
- snowflake/ml/experiment/_experiment_info.py +4 -4
- snowflake/ml/experiment/_logging/experiment_logging_context.py +3 -3
- snowflake/ml/experiment/_source_info.py +19 -19
- snowflake/ml/experiment/callback/keras.py +7 -7
- snowflake/ml/experiment/callback/lightgbm.py +4 -4
- snowflake/ml/experiment/callback/xgboost.py +4 -4
- snowflake/ml/experiment/experiment_tracking.py +32 -19
- snowflake/ml/experiment/utils.py +2 -2
- snowflake/ml/feature_store/_compute_fn_validation.py +2 -2
- snowflake/ml/feature_store/access_manager.py +3 -4
- snowflake/ml/feature_store/aggregation.py +20 -0
- snowflake/ml/feature_store/entity.py +1 -3
- snowflake/ml/feature_store/examples/example_helper.py +5 -5
- snowflake/ml/feature_store/feature.py +2 -2
- snowflake/ml/feature_store/feature_group.py +30 -34
- snowflake/ml/feature_store/feature_store.py +71 -17
- snowflake/ml/feature_store/feature_view.py +303 -146
- snowflake/ml/feature_store/feature_view_refresh_freq.py +1 -3
- snowflake/ml/feature_store/metadata_manager.py +33 -33
- snowflake/ml/feature_store/online_service_http_client.py +10 -10
- snowflake/ml/feature_store/realtime_config.py +3 -3
- snowflake/ml/feature_store/realtime_dataset.py +4 -4
- snowflake/ml/feature_store/realtime_registration.py +7 -7
- snowflake/ml/feature_store/spec/builder.py +25 -25
- snowflake/ml/feature_store/spec/models.py +20 -20
- snowflake/ml/feature_store/spec/table_schema_evolution.py +2 -2
- snowflake/ml/feature_store/stream_config.py +7 -7
- snowflake/ml/feature_store/stream_source.py +4 -4
- snowflake/ml/feature_store/streaming_registration.py +82 -30
- snowflake/ml/feature_store/tile_sql_generator.py +59 -38
- snowflake/ml/fileset/embedded_stage_fs.py +3 -3
- snowflake/ml/fileset/fileset.py +6 -6
- snowflake/ml/fileset/snowfs.py +3 -3
- snowflake/ml/fileset/stage_fs.py +7 -7
- snowflake/ml/jobs/_interop/data_utils.py +5 -5
- snowflake/ml/jobs/_interop/dto_schema.py +8 -8
- snowflake/ml/jobs/_interop/exception_utils.py +11 -11
- snowflake/ml/jobs/_interop/legacy.py +6 -6
- snowflake/ml/jobs/_interop/protocols.py +21 -21
- snowflake/ml/jobs/_interop/results.py +6 -6
- snowflake/ml/jobs/_interop/utils.py +5 -5
- snowflake/ml/jobs/_utils/feature_flags.py +2 -2
- snowflake/ml/jobs/_utils/payload_utils.py +32 -28
- snowflake/ml/jobs/_utils/query_helper.py +3 -3
- snowflake/ml/jobs/_utils/runtime_env_utils.py +2 -2
- snowflake/ml/jobs/_utils/scripts/signal_workers.py +2 -2
- snowflake/ml/jobs/_utils/scripts/worker_shutdown_listener.py +2 -3
- snowflake/ml/jobs/_utils/stage_utils.py +6 -6
- snowflake/ml/jobs/job.py +19 -3
- snowflake/ml/jobs/job_definition.py +5 -5
- snowflake/ml/lineage/lineage_node.py +6 -6
- snowflake/ml/model/_client/model/batch_inference_job_specs.py +15 -15
- snowflake/ml/model/_client/model/batch_inference_task.py +2 -10
- snowflake/ml/model/_client/model/model_impl.py +9 -4
- snowflake/ml/model/_client/model/model_version_impl.py +189 -26
- snowflake/ml/model/_client/model/telemetry_params.py +84 -0
- snowflake/ml/model/_client/ops/deployment_step.py +2 -3
- snowflake/ml/model/_client/ops/metadata_ops.py +10 -10
- snowflake/ml/model/_client/ops/model_ops.py +253 -6
- snowflake/ml/model/_client/ops/param_ops.py +4 -4
- snowflake/ml/model/_client/ops/param_utils.py +7 -7
- snowflake/ml/model/_client/ops/service_ops.py +61 -18
- snowflake/ml/model/_client/service/import_model_spec_schema.py +2 -4
- snowflake/ml/model/_client/service/inference_job_service_spec.py +24 -7
- snowflake/ml/model/_client/service/model_deployment_spec.py +6 -0
- snowflake/ml/model/_client/service/model_deployment_spec_schema.py +15 -0
- snowflake/ml/model/_client/sql/_base.py +2 -4
- snowflake/ml/model/_client/sql/model.py +11 -3
- snowflake/ml/model/_client/sql/model_version.py +65 -65
- snowflake/ml/model/_client/sql/service.py +42 -42
- snowflake/ml/model/_client/sql/stage.py +4 -4
- snowflake/ml/model/_client/sql/tag.py +19 -19
- snowflake/ml/model/_model_composer/huggingface_lazy_uploader.py +6 -6
- snowflake/ml/model/_model_composer/model_composer.py +59 -22
- snowflake/ml/model/_model_composer/model_manifest/model_manifest.py +8 -8
- snowflake/ml/model/_model_composer/model_manifest/model_manifest_schema.py +4 -4
- snowflake/ml/model/_model_composer/model_method/function_generator.py +4 -4
- snowflake/ml/model/_model_composer/model_method/model_method.py +9 -9
- snowflake/ml/model/_model_composer/model_method/utils.py +2 -2
- snowflake/ml/model/_packager/model_env/model_env.py +18 -18
- snowflake/ml/model/_packager/model_handler.py +3 -3
- snowflake/ml/model/_packager/model_handlers/_base.py +5 -5
- snowflake/ml/model/_packager/model_handlers/custom.py +4 -4
- snowflake/ml/model/_packager/model_handlers/huggingface/_task_handler.py +2 -2
- snowflake/ml/model/_packager/model_handlers/huggingface/_utils.py +2 -2
- snowflake/ml/model/_packager/model_handlers/huggingface/image_to_text.py +2 -2
- snowflake/ml/model/_packager/model_handlers/huggingface/question_answering.py +2 -2
- snowflake/ml/model/_packager/model_handlers/huggingface/summarization.py +2 -2
- snowflake/ml/model/_packager/model_handlers/huggingface/text2text_generation.py +2 -2
- snowflake/ml/model/_packager/model_handlers/huggingface/translation.py +2 -2
- snowflake/ml/model/_packager/model_handlers/huggingface/visual_question_answering.py +2 -2
- snowflake/ml/model/_packager/model_handlers/keras.py +4 -4
- snowflake/ml/model/_packager/model_handlers/mlflow.py +4 -4
- snowflake/ml/model/_packager/model_handlers/peft_adapter.py +8 -8
- snowflake/ml/model/_packager/model_handlers/prophet.py +9 -9
- snowflake/ml/model/_packager/model_handlers/pytorch.py +4 -4
- snowflake/ml/model/_packager/model_handlers/tensorflow.py +4 -4
- snowflake/ml/model/_packager/model_handlers/torchscript.py +4 -4
- snowflake/ml/model/_packager/model_meta/model_meta.py +41 -39
- snowflake/ml/model/_packager/model_meta/model_meta_schema.py +14 -14
- snowflake/ml/model/_packager/model_meta/model_sample_input_data.py +6 -6
- snowflake/ml/model/_packager/model_packager.py +15 -16
- snowflake/ml/model/_packager/model_runtime/_snowml_inference_alternative_requirements.py +0 -1
- snowflake/ml/model/_packager/model_runtime/model_runtime.py +1 -2
- snowflake/ml/model/_signatures/core.py +15 -16
- snowflake/ml/model/_signatures/dmatrix_handler.py +2 -4
- snowflake/ml/model/_signatures/pandas_handler.py +4 -4
- snowflake/ml/model/_signatures/pytorch_handler.py +3 -3
- snowflake/ml/model/_signatures/snowpark_handler.py +7 -7
- snowflake/ml/model/_signatures/tensorflow_handler.py +3 -3
- snowflake/ml/model/_signatures/utils.py +5 -5
- snowflake/ml/model/code_path.py +2 -3
- snowflake/ml/model/custom_model.py +7 -16
- snowflake/ml/model/event_handler.py +4 -4
- snowflake/ml/model/model_signature.py +10 -10
- snowflake/ml/model/models/huggingface.py +54 -54
- snowflake/ml/model/models/huggingface_pipeline.py +2 -10
- snowflake/ml/model/type_hints.py +1 -1
- snowflake/ml/modeling/_internal/local_implementations/pandas_handlers.py +5 -5
- snowflake/ml/modeling/_internal/local_implementations/pandas_trainer.py +5 -6
- snowflake/ml/modeling/_internal/model_specifications.py +5 -0
- snowflake/ml/modeling/_internal/model_trainer.py +6 -6
- snowflake/ml/modeling/_internal/model_trainer_builder.py +8 -10
- snowflake/ml/modeling/_internal/model_transformer_builder.py +2 -4
- snowflake/ml/modeling/_internal/snowpark_implementations/distributed_hpo_trainer.py +4 -4
- snowflake/ml/modeling/_internal/transformer_protocols.py +12 -12
- snowflake/ml/modeling/calibration/calibrated_classifier_cv.py +3 -3
- snowflake/ml/modeling/cluster/affinity_propagation.py +3 -3
- snowflake/ml/modeling/cluster/agglomerative_clustering.py +3 -3
- snowflake/ml/modeling/cluster/birch.py +3 -3
- snowflake/ml/modeling/cluster/bisecting_k_means.py +3 -3
- snowflake/ml/modeling/cluster/dbscan.py +3 -3
- snowflake/ml/modeling/cluster/feature_agglomeration.py +3 -3
- snowflake/ml/modeling/cluster/k_means.py +3 -3
- snowflake/ml/modeling/cluster/mean_shift.py +3 -3
- snowflake/ml/modeling/cluster/mini_batch_k_means.py +3 -3
- snowflake/ml/modeling/cluster/optics.py +3 -3
- snowflake/ml/modeling/cluster/spectral_biclustering.py +3 -3
- snowflake/ml/modeling/cluster/spectral_clustering.py +3 -3
- snowflake/ml/modeling/cluster/spectral_coclustering.py +3 -3
- snowflake/ml/modeling/compose/column_transformer.py +3 -3
- snowflake/ml/modeling/compose/transformed_target_regressor.py +3 -3
- snowflake/ml/modeling/covariance/elliptic_envelope.py +3 -3
- snowflake/ml/modeling/covariance/empirical_covariance.py +3 -3
- snowflake/ml/modeling/covariance/graphical_lasso.py +3 -3
- snowflake/ml/modeling/covariance/graphical_lasso_cv.py +3 -3
- snowflake/ml/modeling/covariance/ledoit_wolf.py +3 -3
- snowflake/ml/modeling/covariance/min_cov_det.py +3 -3
- snowflake/ml/modeling/covariance/oas.py +3 -3
- snowflake/ml/modeling/covariance/shrunk_covariance.py +3 -3
- snowflake/ml/modeling/decomposition/dictionary_learning.py +3 -3
- snowflake/ml/modeling/decomposition/factor_analysis.py +3 -3
- snowflake/ml/modeling/decomposition/fast_ica.py +3 -3
- snowflake/ml/modeling/decomposition/incremental_pca.py +3 -3
- snowflake/ml/modeling/decomposition/kernel_pca.py +3 -3
- snowflake/ml/modeling/decomposition/mini_batch_dictionary_learning.py +3 -3
- snowflake/ml/modeling/decomposition/mini_batch_sparse_pca.py +3 -3
- snowflake/ml/modeling/decomposition/pca.py +3 -3
- snowflake/ml/modeling/decomposition/sparse_pca.py +3 -3
- snowflake/ml/modeling/decomposition/truncated_svd.py +3 -3
- snowflake/ml/modeling/discriminant_analysis/linear_discriminant_analysis.py +3 -3
- snowflake/ml/modeling/discriminant_analysis/quadratic_discriminant_analysis.py +3 -3
- snowflake/ml/modeling/ensemble/ada_boost_classifier.py +3 -3
- snowflake/ml/modeling/ensemble/ada_boost_regressor.py +3 -3
- snowflake/ml/modeling/ensemble/bagging_classifier.py +3 -3
- snowflake/ml/modeling/ensemble/bagging_regressor.py +3 -3
- snowflake/ml/modeling/ensemble/extra_trees_classifier.py +3 -3
- snowflake/ml/modeling/ensemble/extra_trees_regressor.py +3 -3
- snowflake/ml/modeling/ensemble/gradient_boosting_classifier.py +3 -3
- snowflake/ml/modeling/ensemble/gradient_boosting_regressor.py +3 -3
- snowflake/ml/modeling/ensemble/hist_gradient_boosting_classifier.py +3 -3
- snowflake/ml/modeling/ensemble/hist_gradient_boosting_regressor.py +3 -3
- snowflake/ml/modeling/ensemble/isolation_forest.py +3 -3
- snowflake/ml/modeling/ensemble/random_forest_classifier.py +3 -3
- snowflake/ml/modeling/ensemble/random_forest_regressor.py +3 -3
- snowflake/ml/modeling/ensemble/stacking_regressor.py +3 -3
- snowflake/ml/modeling/ensemble/voting_classifier.py +3 -3
- snowflake/ml/modeling/ensemble/voting_regressor.py +3 -3
- snowflake/ml/modeling/feature_selection/generic_univariate_select.py +3 -3
- snowflake/ml/modeling/feature_selection/select_fdr.py +3 -3
- snowflake/ml/modeling/feature_selection/select_fpr.py +3 -3
- snowflake/ml/modeling/feature_selection/select_fwe.py +3 -3
- snowflake/ml/modeling/feature_selection/select_k_best.py +3 -3
- snowflake/ml/modeling/feature_selection/select_percentile.py +3 -3
- snowflake/ml/modeling/feature_selection/sequential_feature_selector.py +3 -3
- snowflake/ml/modeling/feature_selection/variance_threshold.py +3 -3
- snowflake/ml/modeling/framework/_utils.py +9 -9
- snowflake/ml/modeling/framework/base.py +38 -40
- snowflake/ml/modeling/gaussian_process/gaussian_process_classifier.py +3 -3
- snowflake/ml/modeling/gaussian_process/gaussian_process_regressor.py +3 -3
- snowflake/ml/modeling/impute/iterative_imputer.py +3 -3
- snowflake/ml/modeling/impute/knn_imputer.py +3 -3
- snowflake/ml/modeling/impute/missing_indicator.py +3 -3
- snowflake/ml/modeling/impute/simple_imputer.py +10 -10
- snowflake/ml/modeling/kernel_approximation/additive_chi2_sampler.py +3 -3
- snowflake/ml/modeling/kernel_approximation/nystroem.py +3 -3
- snowflake/ml/modeling/kernel_approximation/polynomial_count_sketch.py +3 -3
- snowflake/ml/modeling/kernel_approximation/rbf_sampler.py +3 -3
- snowflake/ml/modeling/kernel_approximation/skewed_chi2_sampler.py +3 -3
- snowflake/ml/modeling/kernel_ridge/kernel_ridge.py +3 -3
- snowflake/ml/modeling/lightgbm/lgbm_classifier.py +3 -3
- snowflake/ml/modeling/lightgbm/lgbm_regressor.py +3 -3
- snowflake/ml/modeling/linear_model/ard_regression.py +3 -3
- snowflake/ml/modeling/linear_model/bayesian_ridge.py +3 -3
- snowflake/ml/modeling/linear_model/elastic_net.py +3 -3
- snowflake/ml/modeling/linear_model/elastic_net_cv.py +3 -3
- snowflake/ml/modeling/linear_model/gamma_regressor.py +3 -3
- snowflake/ml/modeling/linear_model/huber_regressor.py +3 -3
- snowflake/ml/modeling/linear_model/lars.py +3 -3
- snowflake/ml/modeling/linear_model/lars_cv.py +3 -3
- snowflake/ml/modeling/linear_model/lasso.py +3 -3
- snowflake/ml/modeling/linear_model/lasso_cv.py +3 -3
- snowflake/ml/modeling/linear_model/lasso_lars.py +3 -3
- snowflake/ml/modeling/linear_model/lasso_lars_cv.py +3 -3
- snowflake/ml/modeling/linear_model/lasso_lars_ic.py +3 -3
- snowflake/ml/modeling/linear_model/linear_regression.py +3 -3
- snowflake/ml/modeling/linear_model/logistic_regression.py +3 -3
- snowflake/ml/modeling/linear_model/logistic_regression_cv.py +3 -3
- snowflake/ml/modeling/linear_model/multi_task_elastic_net.py +3 -3
- snowflake/ml/modeling/linear_model/multi_task_elastic_net_cv.py +3 -3
- snowflake/ml/modeling/linear_model/multi_task_lasso.py +3 -3
- snowflake/ml/modeling/linear_model/multi_task_lasso_cv.py +3 -3
- snowflake/ml/modeling/linear_model/orthogonal_matching_pursuit.py +3 -3
- snowflake/ml/modeling/linear_model/passive_aggressive_classifier.py +3 -3
- snowflake/ml/modeling/linear_model/passive_aggressive_regressor.py +3 -3
- snowflake/ml/modeling/linear_model/perceptron.py +3 -3
- snowflake/ml/modeling/linear_model/poisson_regressor.py +3 -3
- snowflake/ml/modeling/linear_model/ransac_regressor.py +3 -3
- snowflake/ml/modeling/linear_model/ridge.py +3 -3
- snowflake/ml/modeling/linear_model/ridge_classifier.py +3 -3
- snowflake/ml/modeling/linear_model/ridge_classifier_cv.py +3 -3
- snowflake/ml/modeling/linear_model/ridge_cv.py +3 -3
- snowflake/ml/modeling/linear_model/sgd_classifier.py +3 -3
- snowflake/ml/modeling/linear_model/sgd_one_class_svm.py +3 -3
- snowflake/ml/modeling/linear_model/sgd_regressor.py +3 -3
- snowflake/ml/modeling/linear_model/theil_sen_regressor.py +3 -3
- snowflake/ml/modeling/linear_model/tweedie_regressor.py +3 -3
- snowflake/ml/modeling/manifold/isomap.py +3 -3
- snowflake/ml/modeling/manifold/mds.py +3 -3
- snowflake/ml/modeling/manifold/spectral_embedding.py +3 -3
- snowflake/ml/modeling/manifold/tsne.py +3 -3
- snowflake/ml/modeling/metrics/classification.py +76 -76
- snowflake/ml/modeling/metrics/correlation.py +2 -2
- snowflake/ml/modeling/metrics/covariance.py +2 -2
- snowflake/ml/modeling/metrics/metrics_utils.py +7 -7
- snowflake/ml/modeling/metrics/ranking.py +12 -14
- snowflake/ml/modeling/metrics/regression.py +34 -35
- snowflake/ml/modeling/mixture/bayesian_gaussian_mixture.py +3 -3
- snowflake/ml/modeling/mixture/gaussian_mixture.py +3 -3
- snowflake/ml/modeling/model_selection/grid_search_cv.py +22 -21
- snowflake/ml/modeling/model_selection/randomized_search_cv.py +22 -21
- snowflake/ml/modeling/multiclass/one_vs_one_classifier.py +3 -3
- snowflake/ml/modeling/multiclass/one_vs_rest_classifier.py +3 -3
- snowflake/ml/modeling/multiclass/output_code_classifier.py +3 -3
- snowflake/ml/modeling/naive_bayes/bernoulli_nb.py +3 -3
- snowflake/ml/modeling/naive_bayes/categorical_nb.py +3 -3
- snowflake/ml/modeling/naive_bayes/complement_nb.py +3 -3
- snowflake/ml/modeling/naive_bayes/gaussian_nb.py +3 -3
- snowflake/ml/modeling/naive_bayes/multinomial_nb.py +3 -3
- snowflake/ml/modeling/neighbors/k_neighbors_classifier.py +3 -3
- snowflake/ml/modeling/neighbors/k_neighbors_regressor.py +3 -3
- snowflake/ml/modeling/neighbors/kernel_density.py +3 -3
- snowflake/ml/modeling/neighbors/local_outlier_factor.py +3 -3
- snowflake/ml/modeling/neighbors/nearest_centroid.py +3 -3
- snowflake/ml/modeling/neighbors/nearest_neighbors.py +3 -3
- snowflake/ml/modeling/neighbors/neighborhood_components_analysis.py +3 -3
- snowflake/ml/modeling/neighbors/radius_neighbors_classifier.py +3 -3
- snowflake/ml/modeling/neighbors/radius_neighbors_regressor.py +3 -3
- snowflake/ml/modeling/neural_network/bernoulli_rbm.py +3 -3
- snowflake/ml/modeling/neural_network/mlp_classifier.py +3 -3
- snowflake/ml/modeling/neural_network/mlp_regressor.py +3 -3
- snowflake/ml/modeling/pipeline/pipeline.py +17 -29
- snowflake/ml/modeling/preprocessing/binarizer.py +7 -7
- snowflake/ml/modeling/preprocessing/k_bins_discretizer.py +3 -3
- snowflake/ml/modeling/preprocessing/label_encoder.py +9 -9
- snowflake/ml/modeling/preprocessing/max_abs_scaler.py +7 -7
- snowflake/ml/modeling/preprocessing/min_max_scaler.py +7 -7
- snowflake/ml/modeling/preprocessing/normalizer.py +7 -7
- snowflake/ml/modeling/preprocessing/one_hot_encoder.py +1 -1
- snowflake/ml/modeling/preprocessing/ordinal_encoder.py +12 -12
- snowflake/ml/modeling/preprocessing/polynomial_features.py +3 -3
- snowflake/ml/modeling/preprocessing/robust_scaler.py +9 -9
- snowflake/ml/modeling/preprocessing/standard_scaler.py +10 -10
- snowflake/ml/modeling/semi_supervised/label_propagation.py +3 -3
- snowflake/ml/modeling/semi_supervised/label_spreading.py +3 -3
- snowflake/ml/modeling/svm/linear_svc.py +3 -3
- snowflake/ml/modeling/svm/linear_svr.py +3 -3
- snowflake/ml/modeling/svm/nu_svc.py +3 -3
- snowflake/ml/modeling/svm/nu_svr.py +3 -3
- snowflake/ml/modeling/svm/svc.py +3 -3
- snowflake/ml/modeling/svm/svr.py +3 -3
- snowflake/ml/modeling/tree/decision_tree_classifier.py +3 -3
- snowflake/ml/modeling/tree/decision_tree_regressor.py +3 -3
- snowflake/ml/modeling/tree/extra_tree_classifier.py +3 -3
- snowflake/ml/modeling/tree/extra_tree_regressor.py +3 -3
- snowflake/ml/modeling/xgboost/xgb_classifier.py +3 -3
- snowflake/ml/modeling/xgboost/xgb_regressor.py +3 -3
- snowflake/ml/modeling/xgboost/xgbrf_classifier.py +3 -3
- snowflake/ml/modeling/xgboost/xgbrf_regressor.py +3 -3
- snowflake/ml/monitoring/_client/model_monitor_sql_client.py +40 -40
- snowflake/ml/monitoring/_manager/model_monitor_manager.py +3 -3
- snowflake/ml/monitoring/entities/model_monitor_config.py +8 -9
- snowflake/ml/monitoring/explain_visualize.py +3 -3
- snowflake/ml/registry/_manager/model_manager.py +145 -19
- snowflake/ml/registry/registry.py +49 -52
- snowflake/ml/utils/authentication.py +10 -11
- snowflake/ml/utils/sparse.py +1 -2
- snowflake/ml/utils/stage_file.py +2 -2
- snowflake/ml/version.py +1 -1
- {snowflake_ml_python-2.1.0.dist-info → snowflake_ml_python-2.3.0.dist-info}/METADATA +49 -5
- snowflake_ml_python-2.3.0.dist-info/RECORD +548 -0
- snowflake_ml_python-2.1.0.dist-info/RECORD +0 -547
- {snowflake_ml_python-2.1.0.dist-info → snowflake_ml_python-2.3.0.dist-info}/WHEEL +0 -0
- {snowflake_ml_python-2.1.0.dist-info → snowflake_ml_python-2.3.0.dist-info}/licenses/LICENSE.txt +0 -0
- {snowflake_ml_python-2.1.0.dist-info → snowflake_ml_python-2.3.0.dist-info}/top_level.txt +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import
|
|
1
|
+
from typing import Union, cast
|
|
2
2
|
|
|
3
3
|
from typing_extensions import deprecated
|
|
4
4
|
|
|
@@ -11,10 +11,10 @@ from snowflake.ml._internal import telemetry
|
|
|
11
11
|
project=CORTEX_FUNCTIONS_TELEMETRY_PROJECT,
|
|
12
12
|
)
|
|
13
13
|
def classify_text(
|
|
14
|
-
str_input:
|
|
15
|
-
categories:
|
|
16
|
-
session:
|
|
17
|
-
) ->
|
|
14
|
+
str_input: str | snowpark.Column,
|
|
15
|
+
categories: list[str] | snowpark.Column,
|
|
16
|
+
session: snowpark.Session | None = None,
|
|
17
|
+
) -> str | snowpark.Column:
|
|
18
18
|
"""Use the LLM inference service to classify the INPUT text into one of the target CATEGORIES.
|
|
19
19
|
|
|
20
20
|
Args:
|
|
@@ -31,10 +31,10 @@ def classify_text(
|
|
|
31
31
|
|
|
32
32
|
def _classify_text_impl(
|
|
33
33
|
function: str,
|
|
34
|
-
str_input:
|
|
35
|
-
categories:
|
|
36
|
-
session:
|
|
37
|
-
) ->
|
|
34
|
+
str_input: str | snowpark.Column,
|
|
35
|
+
categories: list[str] | snowpark.Column,
|
|
36
|
+
session: snowpark.Session | None = None,
|
|
37
|
+
) -> str | snowpark.Column:
|
|
38
38
|
return cast(Union[str, snowpark.Column], call_sql_function(function, session, str_input, categories))
|
|
39
39
|
|
|
40
40
|
|
snowflake/cortex/_complete.py
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import json
|
|
2
2
|
import logging
|
|
3
3
|
import time
|
|
4
|
-
import typing
|
|
5
4
|
from io import BytesIO
|
|
6
|
-
from typing import Any, Callable, Iterator,
|
|
5
|
+
from typing import Any, Callable, Iterator, TypedDict, cast
|
|
7
6
|
from urllib.parse import urlunparse
|
|
8
7
|
|
|
9
8
|
import requests
|
|
@@ -78,9 +77,9 @@ class MidStreamException(Exception):
|
|
|
78
77
|
|
|
79
78
|
def __init__(
|
|
80
79
|
self,
|
|
81
|
-
reason:
|
|
82
|
-
http_resp:
|
|
83
|
-
request_id:
|
|
80
|
+
reason: str | None = None,
|
|
81
|
+
http_resp: Any | None = None,
|
|
82
|
+
request_id: str | None = None,
|
|
84
83
|
) -> None:
|
|
85
84
|
message = ""
|
|
86
85
|
if reason is not None:
|
|
@@ -107,7 +106,7 @@ _MAX_RETRY_SECONDS = 30
|
|
|
107
106
|
|
|
108
107
|
def retry(func: Callable[..., requests.Response]) -> Callable[..., requests.Response]:
|
|
109
108
|
def inner(*args: Any, **kwargs: Any) -> requests.Response:
|
|
110
|
-
deadline = cast(
|
|
109
|
+
deadline = cast(float | None, kwargs["deadline"])
|
|
111
110
|
kwargs = {key: value for key, value in kwargs.items() if key != "deadline"}
|
|
112
111
|
expRetrySeconds = 0.5
|
|
113
112
|
while True:
|
|
@@ -141,7 +140,7 @@ def _make_common_request_headers() -> dict[str, str]:
|
|
|
141
140
|
return headers
|
|
142
141
|
|
|
143
142
|
|
|
144
|
-
def _get_request_id(resp: dict[str, Any]) ->
|
|
143
|
+
def _get_request_id(resp: dict[str, Any]) -> Any | None:
|
|
145
144
|
request_id = None
|
|
146
145
|
if "headers" in resp:
|
|
147
146
|
for key, value in resp["headers"].items():
|
|
@@ -181,8 +180,8 @@ def _validate_response_format_object(options: CompleteOptions) -> None:
|
|
|
181
180
|
|
|
182
181
|
def _make_request_body(
|
|
183
182
|
model: str,
|
|
184
|
-
prompt:
|
|
185
|
-
options:
|
|
183
|
+
prompt: str | list[ConversationMessage],
|
|
184
|
+
options: CompleteOptions | None = None,
|
|
186
185
|
) -> dict[str, Any]:
|
|
187
186
|
data = {
|
|
188
187
|
"model": model,
|
|
@@ -249,11 +248,11 @@ def _xp_dict_to_response(raw_resp: dict[str, Any]) -> requests.Response:
|
|
|
249
248
|
|
|
250
249
|
@retry
|
|
251
250
|
def _call_complete_xp(
|
|
252
|
-
snow_api_xp_request_handler:
|
|
251
|
+
snow_api_xp_request_handler: Callable[..., dict[str, Any]] | None,
|
|
253
252
|
model: str,
|
|
254
|
-
prompt:
|
|
255
|
-
options:
|
|
256
|
-
deadline:
|
|
253
|
+
prompt: str | list[ConversationMessage],
|
|
254
|
+
options: CompleteOptions | None = None,
|
|
255
|
+
deadline: float | None = None,
|
|
257
256
|
) -> requests.Response:
|
|
258
257
|
headers = _make_common_request_headers()
|
|
259
258
|
body = _make_request_body(model, prompt, options)
|
|
@@ -265,9 +264,9 @@ def _call_complete_xp(
|
|
|
265
264
|
@retry
|
|
266
265
|
def _call_complete_rest(
|
|
267
266
|
model: str,
|
|
268
|
-
prompt:
|
|
269
|
-
options:
|
|
270
|
-
session:
|
|
267
|
+
prompt: str | list[ConversationMessage],
|
|
268
|
+
options: CompleteOptions | None = None,
|
|
269
|
+
session: snowpark.Session | None = None,
|
|
271
270
|
) -> requests.Response:
|
|
272
271
|
session = session or context.get_active_session()
|
|
273
272
|
if session is None:
|
|
@@ -305,8 +304,8 @@ def _call_complete_rest(
|
|
|
305
304
|
|
|
306
305
|
def _return_stream_response(
|
|
307
306
|
response: requests.Response,
|
|
308
|
-
deadline:
|
|
309
|
-
session:
|
|
307
|
+
deadline: float | None,
|
|
308
|
+
session: snowpark.Session | None = None,
|
|
310
309
|
) -> Iterator[str]:
|
|
311
310
|
request_id = _get_request_id(dict(response.headers))
|
|
312
311
|
client = SSEClient(response)
|
|
@@ -333,18 +332,18 @@ def _return_stream_response(
|
|
|
333
332
|
|
|
334
333
|
|
|
335
334
|
def _complete_call_sql_function_snowpark(
|
|
336
|
-
function: str, *args:
|
|
335
|
+
function: str, *args: str | snowpark.Column | CompleteOptions
|
|
337
336
|
) -> snowpark.Column:
|
|
338
337
|
return cast(snowpark.Column, functions.builtin(function)(*args))
|
|
339
338
|
|
|
340
339
|
|
|
341
340
|
def _complete_non_streaming_immediate(
|
|
342
|
-
snow_api_xp_request_handler:
|
|
341
|
+
snow_api_xp_request_handler: Callable[..., dict[str, Any]] | None,
|
|
343
342
|
model: str,
|
|
344
|
-
prompt:
|
|
345
|
-
options:
|
|
346
|
-
session:
|
|
347
|
-
deadline:
|
|
343
|
+
prompt: str | list[ConversationMessage],
|
|
344
|
+
options: CompleteOptions | None,
|
|
345
|
+
session: snowpark.Session | None = None,
|
|
346
|
+
deadline: float | None = None,
|
|
348
347
|
) -> str:
|
|
349
348
|
response = _complete_rest(
|
|
350
349
|
snow_api_xp_request_handler=snow_api_xp_request_handler,
|
|
@@ -358,14 +357,14 @@ def _complete_non_streaming_immediate(
|
|
|
358
357
|
|
|
359
358
|
|
|
360
359
|
def _complete_non_streaming_impl(
|
|
361
|
-
snow_api_xp_request_handler:
|
|
360
|
+
snow_api_xp_request_handler: Callable[..., dict[str, Any]] | None,
|
|
362
361
|
function: str,
|
|
363
|
-
model:
|
|
364
|
-
prompt:
|
|
365
|
-
options:
|
|
366
|
-
session:
|
|
367
|
-
deadline:
|
|
368
|
-
) ->
|
|
362
|
+
model: str | snowpark.Column,
|
|
363
|
+
prompt: str | list[ConversationMessage] | snowpark.Column,
|
|
364
|
+
options: CompleteOptions | snowpark.Column | None,
|
|
365
|
+
session: snowpark.Session | None = None,
|
|
366
|
+
deadline: float | None = None,
|
|
367
|
+
) -> str | snowpark.Column:
|
|
369
368
|
if isinstance(prompt, snowpark.Column):
|
|
370
369
|
if options is not None:
|
|
371
370
|
return _complete_call_sql_function_snowpark(function, model, prompt, options)
|
|
@@ -388,12 +387,12 @@ def _complete_non_streaming_impl(
|
|
|
388
387
|
|
|
389
388
|
|
|
390
389
|
def _complete_rest(
|
|
391
|
-
snow_api_xp_request_handler:
|
|
390
|
+
snow_api_xp_request_handler: Callable[..., dict[str, Any]] | None,
|
|
392
391
|
model: str,
|
|
393
|
-
prompt:
|
|
394
|
-
options:
|
|
395
|
-
session:
|
|
396
|
-
deadline:
|
|
392
|
+
prompt: str | list[ConversationMessage],
|
|
393
|
+
options: CompleteOptions | None = None,
|
|
394
|
+
session: snowpark.Session | None = None,
|
|
395
|
+
deadline: float | None = None,
|
|
397
396
|
) -> Iterator[str]:
|
|
398
397
|
if options:
|
|
399
398
|
_validate_response_format_object(options)
|
|
@@ -412,16 +411,16 @@ def _complete_rest(
|
|
|
412
411
|
|
|
413
412
|
|
|
414
413
|
def _complete_impl(
|
|
415
|
-
model:
|
|
416
|
-
prompt:
|
|
417
|
-
snow_api_xp_request_handler:
|
|
414
|
+
model: str | snowpark.Column,
|
|
415
|
+
prompt: str | list[ConversationMessage] | snowpark.Column,
|
|
416
|
+
snow_api_xp_request_handler: Callable[..., dict[str, Any]] | None = None,
|
|
418
417
|
function: str = "snowflake.cortex.complete",
|
|
419
|
-
options:
|
|
420
|
-
session:
|
|
418
|
+
options: CompleteOptions | None = None,
|
|
419
|
+
session: snowpark.Session | None = None,
|
|
421
420
|
stream: bool = False,
|
|
422
|
-
timeout:
|
|
423
|
-
deadline:
|
|
424
|
-
) ->
|
|
421
|
+
timeout: float | None = None,
|
|
422
|
+
deadline: float | None = None,
|
|
423
|
+
) -> str | Iterator[str] | snowpark.Column:
|
|
425
424
|
if timeout is not None and deadline is not None:
|
|
426
425
|
raise ValueError('only one of "timeout" and "deadline" must be set')
|
|
427
426
|
if timeout is not None:
|
|
@@ -454,15 +453,15 @@ def _complete_impl(
|
|
|
454
453
|
project=CORTEX_FUNCTIONS_TELEMETRY_PROJECT,
|
|
455
454
|
)
|
|
456
455
|
def complete(
|
|
457
|
-
model:
|
|
458
|
-
prompt:
|
|
456
|
+
model: str | snowpark.Column,
|
|
457
|
+
prompt: str | list[ConversationMessage] | snowpark.Column,
|
|
459
458
|
*,
|
|
460
|
-
options:
|
|
461
|
-
session:
|
|
459
|
+
options: CompleteOptions | None = None,
|
|
460
|
+
session: snowpark.Session | None = None,
|
|
462
461
|
stream: bool = False,
|
|
463
|
-
timeout:
|
|
464
|
-
deadline:
|
|
465
|
-
) ->
|
|
462
|
+
timeout: float | None = None,
|
|
463
|
+
deadline: float | None = None,
|
|
464
|
+
) -> str | Iterator[str] | snowpark.Column:
|
|
466
465
|
"""Complete calls into the LLM inference service to perform completion.
|
|
467
466
|
|
|
468
467
|
Args:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import
|
|
1
|
+
from typing import Union, cast
|
|
2
2
|
|
|
3
3
|
from typing_extensions import deprecated
|
|
4
4
|
|
|
@@ -11,10 +11,10 @@ from snowflake.ml._internal import telemetry
|
|
|
11
11
|
project=CORTEX_FUNCTIONS_TELEMETRY_PROJECT,
|
|
12
12
|
)
|
|
13
13
|
def embed_text_1024(
|
|
14
|
-
model:
|
|
15
|
-
text:
|
|
16
|
-
session:
|
|
17
|
-
) ->
|
|
14
|
+
model: str | snowpark.Column,
|
|
15
|
+
text: str | snowpark.Column,
|
|
16
|
+
session: snowpark.Session | None = None,
|
|
17
|
+
) -> list[float] | snowpark.Column:
|
|
18
18
|
"""Calls into the LLM inference service to embed the text.
|
|
19
19
|
|
|
20
20
|
Args:
|
|
@@ -32,10 +32,10 @@ def embed_text_1024(
|
|
|
32
32
|
|
|
33
33
|
def _embed_text_1024_impl(
|
|
34
34
|
function: str,
|
|
35
|
-
model:
|
|
36
|
-
text:
|
|
37
|
-
session:
|
|
38
|
-
) ->
|
|
35
|
+
model: str | snowpark.Column,
|
|
36
|
+
text: str | snowpark.Column,
|
|
37
|
+
session: snowpark.Session | None = None,
|
|
38
|
+
) -> list[float] | snowpark.Column:
|
|
39
39
|
return cast(Union[list[float], snowpark.Column], call_sql_function(function, session, model, text))
|
|
40
40
|
|
|
41
41
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import
|
|
1
|
+
from typing import Union, cast
|
|
2
2
|
|
|
3
3
|
from typing_extensions import deprecated
|
|
4
4
|
|
|
@@ -11,10 +11,10 @@ from snowflake.ml._internal import telemetry
|
|
|
11
11
|
project=CORTEX_FUNCTIONS_TELEMETRY_PROJECT,
|
|
12
12
|
)
|
|
13
13
|
def embed_text_768(
|
|
14
|
-
model:
|
|
15
|
-
text:
|
|
16
|
-
session:
|
|
17
|
-
) ->
|
|
14
|
+
model: str | snowpark.Column,
|
|
15
|
+
text: str | snowpark.Column,
|
|
16
|
+
session: snowpark.Session | None = None,
|
|
17
|
+
) -> list[float] | snowpark.Column:
|
|
18
18
|
"""Calls into the LLM inference service to embed the text.
|
|
19
19
|
|
|
20
20
|
Args:
|
|
@@ -32,10 +32,10 @@ def embed_text_768(
|
|
|
32
32
|
|
|
33
33
|
def _embed_text_768_impl(
|
|
34
34
|
function: str,
|
|
35
|
-
model:
|
|
36
|
-
text:
|
|
37
|
-
session:
|
|
38
|
-
) ->
|
|
35
|
+
model: str | snowpark.Column,
|
|
36
|
+
text: str | snowpark.Column,
|
|
37
|
+
session: snowpark.Session | None = None,
|
|
38
|
+
) -> list[float] | snowpark.Column:
|
|
39
39
|
return cast(Union[list[float], snowpark.Column], call_sql_function(function, session, model, text))
|
|
40
40
|
|
|
41
41
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import
|
|
1
|
+
from typing import Union, cast
|
|
2
2
|
|
|
3
3
|
from typing_extensions import deprecated
|
|
4
4
|
|
|
@@ -11,10 +11,10 @@ from snowflake.ml._internal import telemetry
|
|
|
11
11
|
project=CORTEX_FUNCTIONS_TELEMETRY_PROJECT,
|
|
12
12
|
)
|
|
13
13
|
def extract_answer(
|
|
14
|
-
from_text:
|
|
15
|
-
question:
|
|
16
|
-
session:
|
|
17
|
-
) ->
|
|
14
|
+
from_text: str | snowpark.Column,
|
|
15
|
+
question: str | snowpark.Column,
|
|
16
|
+
session: snowpark.Session | None = None,
|
|
17
|
+
) -> str | snowpark.Column:
|
|
18
18
|
"""Calls into the LLM inference service to extract an answer from within specified text.
|
|
19
19
|
|
|
20
20
|
Args:
|
|
@@ -31,10 +31,10 @@ def extract_answer(
|
|
|
31
31
|
|
|
32
32
|
def _extract_answer_impl(
|
|
33
33
|
function: str,
|
|
34
|
-
from_text:
|
|
35
|
-
question:
|
|
36
|
-
session:
|
|
37
|
-
) ->
|
|
34
|
+
from_text: str | snowpark.Column,
|
|
35
|
+
question: str | snowpark.Column,
|
|
36
|
+
session: snowpark.Session | None = None,
|
|
37
|
+
) -> str | snowpark.Column:
|
|
38
38
|
return cast(Union[str, snowpark.Column], call_sql_function(function, session, from_text, question))
|
|
39
39
|
|
|
40
40
|
|
snowflake/cortex/_finetune.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import json
|
|
2
2
|
from dataclasses import dataclass
|
|
3
|
-
from typing import Any,
|
|
3
|
+
from typing import Any, cast
|
|
4
4
|
|
|
5
5
|
from snowflake import snowpark
|
|
6
6
|
from snowflake.cortex._util import (
|
|
@@ -17,7 +17,7 @@ CORTEX_FINETUNE_DOCUMENTATION_URL = "https://docs.snowflake.com/en/user-guide/sn
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
class FinetuneError(Exception):
|
|
20
|
-
def __init__(self, message: str, original_exception:
|
|
20
|
+
def __init__(self, message: str, original_exception: Exception | None = None) -> None:
|
|
21
21
|
"""Finetuning Exception Class.
|
|
22
22
|
|
|
23
23
|
Args:
|
|
@@ -41,46 +41,46 @@ class FinetuneError(Exception):
|
|
|
41
41
|
class FinetuneStatus:
|
|
42
42
|
"""Fine-tuning job status."""
|
|
43
43
|
|
|
44
|
-
id:
|
|
44
|
+
id: str | None = None
|
|
45
45
|
"""Workflow ID for the fine-tuning run."""
|
|
46
46
|
|
|
47
|
-
status:
|
|
47
|
+
status: str | None = None
|
|
48
48
|
"""Status string, e.g. PENDING, RUNNING, SUCCESS, ERROR, CANCELLED."""
|
|
49
49
|
|
|
50
|
-
base_model:
|
|
50
|
+
base_model: str | None = None
|
|
51
51
|
"""Name of the base model that is being fine-tuned."""
|
|
52
52
|
|
|
53
|
-
created_on:
|
|
53
|
+
created_on: int | None = None
|
|
54
54
|
"""Creation timestamp of the Fine-tuning job in milliseconds."""
|
|
55
55
|
|
|
56
|
-
error:
|
|
56
|
+
error: dict[str, Any] | None = None
|
|
57
57
|
"""Error message propagated from the job."""
|
|
58
58
|
|
|
59
|
-
finished_on:
|
|
59
|
+
finished_on: int | None = None
|
|
60
60
|
"""Completion timestamp of the Fine-tuning job in milliseconds."""
|
|
61
61
|
|
|
62
|
-
progress:
|
|
62
|
+
progress: float | None = None
|
|
63
63
|
"""Progress made as a fraction of total [0.0,1.0]."""
|
|
64
64
|
|
|
65
|
-
training_result:
|
|
65
|
+
training_result: list[dict[str, Any]] | None = None
|
|
66
66
|
"""Detailed metrics report for a completed training."""
|
|
67
67
|
|
|
68
|
-
trained_tokens:
|
|
68
|
+
trained_tokens: int | None = None
|
|
69
69
|
"""Number of tokens trained on. If multiple epochs are run, this can be larger than number of tokens in the
|
|
70
70
|
training data."""
|
|
71
71
|
|
|
72
|
-
training_data:
|
|
72
|
+
training_data: str | None = None
|
|
73
73
|
"""Training data query."""
|
|
74
74
|
|
|
75
|
-
validation_data:
|
|
75
|
+
validation_data: str | None = None
|
|
76
76
|
"""Validation data query."""
|
|
77
77
|
|
|
78
|
-
model:
|
|
78
|
+
model: str | None = None
|
|
79
79
|
"""Location of the fine-tuned model."""
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
class FinetuneJob:
|
|
83
|
-
def __init__(self, session:
|
|
83
|
+
def __init__(self, session: snowpark.Session | None, status: FinetuneStatus) -> None:
|
|
84
84
|
"""Fine-tuning Job.
|
|
85
85
|
|
|
86
86
|
Args:
|
|
@@ -145,7 +145,7 @@ class Finetune:
|
|
|
145
145
|
project=CORTEX_FUNCTIONS_TELEMETRY_PROJECT,
|
|
146
146
|
subproject=CORTEX_FINETUNE_TELEMETRY_SUBPROJECT,
|
|
147
147
|
)
|
|
148
|
-
def __init__(self, session:
|
|
148
|
+
def __init__(self, session: snowpark.Session | None = None) -> None:
|
|
149
149
|
"""Cortex Fine-Tuning API.
|
|
150
150
|
|
|
151
151
|
[Documentation](https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-finetuning)
|
|
@@ -165,9 +165,9 @@ class Finetune:
|
|
|
165
165
|
self,
|
|
166
166
|
name: str,
|
|
167
167
|
base_model: str,
|
|
168
|
-
training_data:
|
|
169
|
-
validation_data:
|
|
170
|
-
options:
|
|
168
|
+
training_data: str | snowpark.DataFrame,
|
|
169
|
+
validation_data: str | snowpark.DataFrame | None = None,
|
|
170
|
+
options: dict[str, Any] | None = None,
|
|
171
171
|
) -> FinetuneJob:
|
|
172
172
|
"""Create a new fine-tuning runs.
|
|
173
173
|
|
|
@@ -212,7 +212,7 @@ class Finetune:
|
|
|
212
212
|
else:
|
|
213
213
|
training_string = training_data
|
|
214
214
|
|
|
215
|
-
validation_string:
|
|
215
|
+
validation_string: str | None = None
|
|
216
216
|
if isinstance(validation_data, snowpark.DataFrame):
|
|
217
217
|
if snowpark_dataframe_utils.is_single_query_snowpark_dataframe(validation_data):
|
|
218
218
|
validation_string = str(validation_data.queries["queries"][0])
|
|
@@ -253,7 +253,7 @@ class Finetune:
|
|
|
253
253
|
return [FinetuneJob(session=self._session, status=FinetuneStatus(**run_status)) for run_status in result]
|
|
254
254
|
|
|
255
255
|
|
|
256
|
-
def _try_load_json(json_string: str) ->
|
|
256
|
+
def _try_load_json(json_string: str) -> dict[Any, Any] | list[Any]:
|
|
257
257
|
try:
|
|
258
258
|
result = json.loads(str(json_string))
|
|
259
259
|
except json.JSONDecodeError as e:
|
|
@@ -269,5 +269,5 @@ def _try_load_json(json_string: str) -> Union[dict[Any, Any], list[Any]]:
|
|
|
269
269
|
return result
|
|
270
270
|
|
|
271
271
|
|
|
272
|
-
def _finetune_impl(operation: str, session:
|
|
272
|
+
def _finetune_impl(operation: str, session: snowpark.Session | None, function_args: list[Any]) -> str:
|
|
273
273
|
return call_sql_function_literals(_CORTEX_FINETUNE_SYSTEM_FUNCTION_NAME, session, operation, *function_args)
|
snowflake/cortex/_sentiment.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import
|
|
1
|
+
from typing import cast
|
|
2
2
|
|
|
3
3
|
from typing_extensions import deprecated
|
|
4
4
|
|
|
@@ -10,9 +10,7 @@ from snowflake.ml._internal import telemetry
|
|
|
10
10
|
@telemetry.send_api_usage_telemetry(
|
|
11
11
|
project=CORTEX_FUNCTIONS_TELEMETRY_PROJECT,
|
|
12
12
|
)
|
|
13
|
-
def sentiment(
|
|
14
|
-
text: Union[str, snowpark.Column], session: Optional[snowpark.Session] = None
|
|
15
|
-
) -> Union[float, snowpark.Column]:
|
|
13
|
+
def sentiment(text: str | snowpark.Column, session: snowpark.Session | None = None) -> float | snowpark.Column:
|
|
16
14
|
"""Calls into the LLM inference service to perform sentiment analysis on the input text.
|
|
17
15
|
|
|
18
16
|
Args:
|
|
@@ -26,8 +24,8 @@ def sentiment(
|
|
|
26
24
|
|
|
27
25
|
|
|
28
26
|
def _sentiment_impl(
|
|
29
|
-
function: str, text:
|
|
30
|
-
) ->
|
|
27
|
+
function: str, text: str | snowpark.Column, session: snowpark.Session | None = None
|
|
28
|
+
) -> float | snowpark.Column:
|
|
31
29
|
|
|
32
30
|
output = call_sql_function(function, session, text)
|
|
33
31
|
if isinstance(output, snowpark.Column):
|
snowflake/cortex/_sse_client.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import json
|
|
2
|
-
from typing import Any, Iterator
|
|
2
|
+
from typing import Any, Iterator
|
|
3
3
|
|
|
4
4
|
_FIELD_SEPARATOR = ":"
|
|
5
5
|
|
|
@@ -9,11 +9,11 @@ class Event:
|
|
|
9
9
|
|
|
10
10
|
def __init__(
|
|
11
11
|
self,
|
|
12
|
-
id:
|
|
12
|
+
id: str | None = None,
|
|
13
13
|
event: str = "message",
|
|
14
14
|
data: str = "",
|
|
15
|
-
comment:
|
|
16
|
-
retry:
|
|
15
|
+
comment: str | None = None,
|
|
16
|
+
retry: int | None = None,
|
|
17
17
|
) -> None:
|
|
18
18
|
self.id = id
|
|
19
19
|
self.event = event
|
snowflake/cortex/_summarize.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import
|
|
1
|
+
from typing import Union, cast
|
|
2
2
|
|
|
3
3
|
from typing_extensions import deprecated
|
|
4
4
|
|
|
@@ -11,9 +11,9 @@ from snowflake.ml._internal import telemetry
|
|
|
11
11
|
project=CORTEX_FUNCTIONS_TELEMETRY_PROJECT,
|
|
12
12
|
)
|
|
13
13
|
def summarize(
|
|
14
|
-
text:
|
|
15
|
-
session:
|
|
16
|
-
) ->
|
|
14
|
+
text: str | snowpark.Column,
|
|
15
|
+
session: snowpark.Session | None = None,
|
|
16
|
+
) -> str | snowpark.Column:
|
|
17
17
|
"""Calls into the LLM inference service to summarize the input text.
|
|
18
18
|
|
|
19
19
|
Args:
|
|
@@ -29,9 +29,9 @@ def summarize(
|
|
|
29
29
|
|
|
30
30
|
def _summarize_impl(
|
|
31
31
|
function: str,
|
|
32
|
-
text:
|
|
33
|
-
session:
|
|
34
|
-
) ->
|
|
32
|
+
text: str | snowpark.Column,
|
|
33
|
+
session: snowpark.Session | None = None,
|
|
34
|
+
) -> str | snowpark.Column:
|
|
35
35
|
return cast(Union[str, snowpark.Column], call_sql_function(function, session, text))
|
|
36
36
|
|
|
37
37
|
|
snowflake/cortex/_translate.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import
|
|
1
|
+
from typing import Union, cast
|
|
2
2
|
|
|
3
3
|
from typing_extensions import deprecated
|
|
4
4
|
|
|
@@ -11,11 +11,11 @@ from snowflake.ml._internal import telemetry
|
|
|
11
11
|
project=CORTEX_FUNCTIONS_TELEMETRY_PROJECT,
|
|
12
12
|
)
|
|
13
13
|
def translate(
|
|
14
|
-
text:
|
|
15
|
-
from_language:
|
|
16
|
-
to_language:
|
|
17
|
-
session:
|
|
18
|
-
) ->
|
|
14
|
+
text: str | snowpark.Column,
|
|
15
|
+
from_language: str | snowpark.Column,
|
|
16
|
+
to_language: str | snowpark.Column,
|
|
17
|
+
session: snowpark.Session | None = None,
|
|
18
|
+
) -> str | snowpark.Column:
|
|
19
19
|
"""Calls into the LLM inference service to perform translation.
|
|
20
20
|
|
|
21
21
|
Args:
|
|
@@ -33,11 +33,11 @@ def translate(
|
|
|
33
33
|
|
|
34
34
|
def _translate_impl(
|
|
35
35
|
function: str,
|
|
36
|
-
text:
|
|
37
|
-
from_language:
|
|
38
|
-
to_language:
|
|
39
|
-
session:
|
|
40
|
-
) ->
|
|
36
|
+
text: str | snowpark.Column,
|
|
37
|
+
from_language: str | snowpark.Column,
|
|
38
|
+
to_language: str | snowpark.Column,
|
|
39
|
+
session: snowpark.Session | None = None,
|
|
40
|
+
) -> str | snowpark.Column:
|
|
41
41
|
return cast(Union[str, snowpark.Column], call_sql_function(function, session, text, from_language, to_language))
|
|
42
42
|
|
|
43
43
|
|
snowflake/cortex/_util.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any,
|
|
1
|
+
from typing import Any, Union, cast
|
|
2
2
|
|
|
3
3
|
from snowflake import snowpark
|
|
4
4
|
from snowflake.ml._internal.exceptions import error_codes, exceptions
|
|
@@ -20,9 +20,9 @@ class SnowflakeConfigurationException(Exception):
|
|
|
20
20
|
# (e.g. snowpark column and literal type modes).
|
|
21
21
|
def call_sql_function(
|
|
22
22
|
function: str,
|
|
23
|
-
session:
|
|
24
|
-
*args:
|
|
25
|
-
) ->
|
|
23
|
+
session: snowpark.Session | None,
|
|
24
|
+
*args: str | list[str] | snowpark.Column | dict[str, int | float],
|
|
25
|
+
) -> str | list[float] | snowpark.Column:
|
|
26
26
|
handle_as_column = False
|
|
27
27
|
|
|
28
28
|
for arg in args:
|
|
@@ -38,16 +38,16 @@ def call_sql_function(
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
def _call_sql_function_column(
|
|
41
|
-
function: str, *args:
|
|
41
|
+
function: str, *args: str | list[str] | snowpark.Column | dict[str, int | float]
|
|
42
42
|
) -> snowpark.Column:
|
|
43
43
|
return cast(snowpark.Column, functions.builtin(function)(*args))
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
def _call_sql_function_immediate(
|
|
47
47
|
function: str,
|
|
48
|
-
session:
|
|
49
|
-
*args:
|
|
50
|
-
) ->
|
|
48
|
+
session: snowpark.Session | None,
|
|
49
|
+
*args: str | list[str] | snowpark.Column | dict[str, int | float],
|
|
50
|
+
) -> str | list[float]:
|
|
51
51
|
session = session or context.get_active_session()
|
|
52
52
|
if session is None:
|
|
53
53
|
raise SnowflakeAuthenticationException(
|
|
@@ -64,7 +64,7 @@ def _call_sql_function_immediate(
|
|
|
64
64
|
return cast(str, df.collect()[0][0])
|
|
65
65
|
|
|
66
66
|
|
|
67
|
-
def call_sql_function_literals(function: str, session:
|
|
67
|
+
def call_sql_function_literals(function: str, session: snowpark.Session | None, *args: Any) -> str:
|
|
68
68
|
r"""Call a SQL function with only literal arguments.
|
|
69
69
|
|
|
70
70
|
This is useful for calling system functions.
|