shaped 2.0.1__py3-none-any.whl → 2.0.4__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.
- shaped/__init__.py +59 -4
- shaped/autogen/__init__.py +527 -66
- shaped/autogen/api/__init__.py +4 -3
- shaped/autogen/api/engine_api.py +1467 -0
- shaped/autogen/api/{dataset_api.py → query_api.py} +159 -194
- shaped/autogen/api/table_api.py +1494 -0
- shaped/autogen/api/{model_management_api.py → view_api.py} +179 -181
- shaped/autogen/api_client.py +18 -11
- shaped/autogen/configuration.py +22 -9
- shaped/autogen/exceptions.py +25 -5
- shaped/autogen/models/__init__.py +247 -52
- shaped/autogen/models/ai_enrichment_view_config.py +123 -0
- shaped/autogen/models/{path.py → algorithm.py} +19 -19
- shaped/autogen/models/amplitude_table_config.py +106 -0
- shaped/autogen/models/ascending.py +148 -0
- shaped/autogen/models/attn_dropout_prob.py +136 -0
- shaped/autogen/models/attribute_journey.py +124 -0
- shaped/autogen/models/attribute_value.py +178 -0
- shaped/autogen/models/autoscaling_config.py +95 -0
- shaped/autogen/models/aws_pinpoint_table_config.py +108 -0
- shaped/autogen/models/batch_size.py +136 -0
- shaped/autogen/models/batch_size1.py +136 -0
- shaped/autogen/models/batch_size2.py +136 -0
- shaped/autogen/models/big_query_table_config.py +147 -0
- shaped/autogen/models/bm25.py +136 -0
- shaped/autogen/models/boosted_reorder_step.py +125 -0
- shaped/autogen/models/canary_rollout.py +99 -0
- shaped/autogen/models/candidate_attributes_retrieve_step.py +113 -0
- shaped/autogen/models/candidate_ids_retrieve_step.py +113 -0
- shaped/autogen/models/candidate_retrieval_strategy.py +41 -0
- shaped/autogen/models/clickhouse_table_config.py +146 -0
- shaped/autogen/models/column_order_retrieve_step.py +123 -0
- shaped/autogen/models/column_ordering.py +91 -0
- shaped/autogen/models/create_table_response.py +87 -0
- shaped/autogen/models/create_view_response.py +87 -0
- shaped/autogen/models/custom_table_config.py +135 -0
- shaped/autogen/models/data_compute_config.py +89 -0
- shaped/autogen/models/data_config.py +145 -0
- shaped/autogen/models/data_config_interaction_table.py +146 -0
- shaped/autogen/models/data_split_config.py +88 -0
- shaped/autogen/models/data_split_strategy.py +37 -0
- shaped/autogen/models/data_tier.py +37 -0
- shaped/autogen/models/default.py +246 -0
- shaped/autogen/models/delete_engine_response.py +87 -0
- shaped/autogen/models/delete_table_response.py +87 -0
- shaped/autogen/models/delete_view_response.py +87 -0
- shaped/autogen/models/deployment_config.py +117 -0
- shaped/autogen/models/distance_function.py +38 -0
- shaped/autogen/models/diversity_reorder_step.py +137 -0
- shaped/autogen/models/dropout_rate.py +136 -0
- shaped/autogen/models/dynamo_db_table_config.py +160 -0
- shaped/autogen/models/dynamo_db_table_config_scan_kwargs_value.py +138 -0
- shaped/autogen/models/embedder_batch_size.py +136 -0
- shaped/autogen/models/embedding_config.py +93 -0
- shaped/autogen/models/embedding_dim.py +136 -0
- shaped/autogen/models/embedding_dims.py +136 -0
- shaped/autogen/models/embedding_size.py +136 -0
- shaped/autogen/models/encoder.py +140 -0
- shaped/autogen/models/encoding_pooling_strategy.py +38 -0
- shaped/autogen/models/engine.py +109 -0
- shaped/autogen/models/engine_config_v2.py +152 -0
- shaped/autogen/models/engine_details_response.py +120 -0
- shaped/autogen/models/engine_schema.py +113 -0
- shaped/autogen/models/engine_schema_user_inner.py +146 -0
- shaped/autogen/models/entity_config.py +109 -0
- shaped/autogen/models/entity_journey.py +161 -0
- shaped/autogen/models/entity_type.py +38 -0
- shaped/autogen/models/evaluation_config.py +92 -0
- shaped/autogen/models/exploration_reorder_step.py +125 -0
- shaped/autogen/models/expression_filter_step.py +106 -0
- shaped/autogen/models/factors.py +136 -0
- shaped/autogen/models/factors1.py +136 -0
- shaped/autogen/models/feature.py +90 -0
- shaped/autogen/models/feature_type.py +60 -0
- shaped/autogen/models/file_table_config.py +112 -0
- shaped/autogen/models/filter_config.py +99 -0
- shaped/autogen/models/filter_dataset.py +164 -0
- shaped/autogen/models/filter_index_type.py +36 -0
- shaped/autogen/models/filter_retrieve_step.py +113 -0
- shaped/autogen/models/filter_step_explanation.py +165 -0
- shaped/autogen/models/filter_table.py +140 -0
- shaped/autogen/models/filter_type.py +134 -0
- shaped/autogen/models/global_filter.py +102 -0
- shaped/autogen/models/hidden_dropout_prob.py +136 -0
- shaped/autogen/models/hidden_size.py +136 -0
- shaped/autogen/models/hidden_size1.py +136 -0
- shaped/autogen/models/http_problem_response.py +115 -0
- shaped/autogen/models/http_validation_error.py +2 -2
- shaped/autogen/models/hugging_face_encoder.py +115 -0
- shaped/autogen/models/iceberg_table_config.py +154 -0
- shaped/autogen/models/index_config.py +101 -0
- shaped/autogen/models/inner_entity_id.py +144 -0
- shaped/autogen/models/inner_size.py +136 -0
- shaped/autogen/models/inner_size1.py +136 -0
- shaped/autogen/models/inner_uid.py +144 -0
- shaped/autogen/models/interaction_config.py +122 -0
- shaped/autogen/models/interaction_pooling_encoder.py +104 -0
- shaped/autogen/models/interaction_round_robin_encoder.py +104 -0
- shaped/autogen/models/item_attribute_pooling_encoder.py +111 -0
- shaped/autogen/models/journey.py +140 -0
- shaped/autogen/models/kafka_table_config.py +129 -0
- shaped/autogen/models/kinesis_table_config.py +140 -0
- shaped/autogen/models/kinesis_table_config_column_schema_value.py +136 -0
- shaped/autogen/models/label.py +90 -0
- shaped/autogen/models/label_type.py +36 -0
- shaped/autogen/models/laplace_smoothing.py +136 -0
- shaped/autogen/models/latency_scaling_policy.py +112 -0
- shaped/autogen/models/learning_rate.py +136 -0
- shaped/autogen/models/learning_rate1.py +136 -0
- shaped/autogen/models/learning_rate2.py +136 -0
- shaped/autogen/models/learning_rate3.py +136 -0
- shaped/autogen/models/lexical_search_mode.py +99 -0
- shaped/autogen/models/list_engines_response.py +95 -0
- shaped/autogen/models/list_tables_response.py +95 -0
- shaped/autogen/models/list_views_response.py +95 -0
- shaped/autogen/models/location_inner.py +138 -0
- shaped/autogen/models/loss_types.py +37 -0
- shaped/autogen/models/lr.py +136 -0
- shaped/autogen/models/lr1.py +136 -0
- shaped/autogen/models/lr2.py +136 -0
- shaped/autogen/models/max_depth.py +136 -0
- shaped/autogen/models/max_leaves.py +136 -0
- shaped/autogen/models/max_seq_length.py +136 -0
- shaped/autogen/models/max_seq_length1.py +136 -0
- shaped/autogen/models/max_seq_length2.py +136 -0
- shaped/autogen/models/mode.py +134 -0
- shaped/autogen/models/mode1.py +136 -0
- shaped/autogen/models/mode2.py +150 -0
- shaped/autogen/models/models_inner.py +308 -0
- shaped/autogen/models/mongo_db_table_config.py +147 -0
- shaped/autogen/models/mssql_table_config.py +155 -0
- shaped/autogen/models/{my_sql_dataset_config.py → my_sql_table_config.py} +45 -28
- shaped/autogen/models/n_epochs.py +136 -0
- shaped/autogen/models/n_epochs1.py +136 -0
- shaped/autogen/models/n_epochs2.py +136 -0
- shaped/autogen/models/n_estimators.py +136 -0
- shaped/autogen/models/n_heads.py +136 -0
- shaped/autogen/models/n_layers.py +136 -0
- shaped/autogen/models/neg_per_positive.py +136 -0
- shaped/autogen/models/negative_samples_count.py +136 -0
- shaped/autogen/models/ngram_tokenizer.py +103 -0
- shaped/autogen/models/no_op_config.py +117 -0
- shaped/autogen/models/num_blocks.py +136 -0
- shaped/autogen/models/num_heads.py +136 -0
- shaped/autogen/models/num_leaves.py +136 -0
- shaped/autogen/models/objective.py +40 -0
- shaped/autogen/models/objective1.py +134 -0
- shaped/autogen/models/online_store_config.py +89 -0
- shaped/autogen/models/pagination_config.py +87 -0
- shaped/autogen/models/parameter_definition.py +96 -0
- shaped/autogen/models/parameters_value.py +240 -0
- shaped/autogen/models/passthrough_score.py +104 -0
- shaped/autogen/models/personal_filter.py +104 -0
- shaped/autogen/models/pipeline_stage_explanation.py +118 -0
- shaped/autogen/models/policy.py +134 -0
- shaped/autogen/models/pool_fn.py +152 -0
- shaped/autogen/models/pooling_function.py +37 -0
- shaped/autogen/models/{postgres_dataset_config.py → postgres_table_config.py} +66 -28
- shaped/autogen/models/posthog_table_config.py +133 -0
- shaped/autogen/models/prebuilt_filter_step.py +113 -0
- shaped/autogen/models/precomputed_item_embedding.py +99 -0
- shaped/autogen/models/precomputed_user_embedding.py +99 -0
- shaped/autogen/models/query.py +136 -0
- shaped/autogen/models/query1.py +136 -0
- shaped/autogen/models/query_any_of.py +172 -0
- shaped/autogen/models/query_config.py +140 -0
- shaped/autogen/models/query_definition.py +106 -0
- shaped/autogen/models/query_encoder.py +194 -0
- shaped/autogen/models/query_explanation.py +201 -0
- shaped/autogen/models/query_request.py +121 -0
- shaped/autogen/models/query_result.py +113 -0
- shaped/autogen/models/query_table_config.py +99 -0
- shaped/autogen/models/rank_item_attribute_values_query_config.py +122 -0
- shaped/autogen/models/rank_query_config.py +167 -0
- shaped/autogen/models/rank_query_config_filter_inner.py +149 -0
- shaped/autogen/models/rank_query_config_reorder_inner.py +186 -0
- shaped/autogen/models/rank_query_config_retrieve_inner.py +265 -0
- shaped/autogen/models/recreate_rollout.py +97 -0
- shaped/autogen/models/{redshift_dataset_config.py → redshift_table_config.py} +48 -25
- shaped/autogen/models/reference_table_config.py +113 -0
- shaped/autogen/models/regularization.py +136 -0
- shaped/autogen/models/reorder_inner.py +149 -0
- shaped/autogen/models/reorder_step_explanation.py +207 -0
- shaped/autogen/models/request.py +378 -0
- shaped/autogen/models/request1.py +140 -0
- shaped/autogen/models/requests_per_second_scaling_policy.py +112 -0
- shaped/autogen/models/resource_config.py +100 -0
- shaped/autogen/models/response_get_view_details_views_view_name_get.py +134 -0
- shaped/autogen/models/result.py +132 -0
- shaped/autogen/models/result_embeddings_value.py +127 -0
- shaped/autogen/models/retrieval_scores_value.py +127 -0
- shaped/autogen/models/retrieve_inner.py +196 -0
- shaped/autogen/models/retrieve_step_explanation.py +172 -0
- shaped/autogen/models/retriever.py +196 -0
- shaped/autogen/models/retriever1.py +196 -0
- shaped/autogen/models/rollout_config.py +91 -0
- shaped/autogen/models/rudderstack_table_config.py +106 -0
- shaped/autogen/models/sampling_strategy.py +36 -0
- shaped/autogen/models/saved_query_info_response.py +103 -0
- shaped/autogen/models/saved_query_list_response.py +87 -0
- shaped/autogen/models/saved_query_request.py +115 -0
- shaped/autogen/models/schema_config.py +117 -0
- shaped/autogen/models/score.py +134 -0
- shaped/autogen/models/score_ensemble.py +127 -0
- shaped/autogen/models/score_ensemble_policy_config.py +165 -0
- shaped/autogen/models/score_ensemble_policy_config_policies_inner.py +755 -0
- shaped/autogen/models/score_step_explanation.py +224 -0
- shaped/autogen/models/search_config.py +105 -0
- shaped/autogen/models/segment_table_config.py +106 -0
- shaped/autogen/models/sequence_length.py +136 -0
- shaped/autogen/models/server_config.py +100 -0
- shaped/autogen/models/setup_engine_response.py +87 -0
- shaped/autogen/models/shaped_internal_recsys_policies_als_model_policy_als_model_policy_config.py +154 -0
- shaped/autogen/models/shaped_internal_recsys_policies_beeformer_model_policy_beeformer_model_policy_beeformer_model_policy_config.py +160 -0
- shaped/autogen/models/shaped_internal_recsys_policies_bert_model_policy_bert_model_policy_bert_model_policy_config.py +215 -0
- shaped/autogen/models/shaped_internal_recsys_policies_chronological_model_policy_chronological_model_policy_config.py +156 -0
- shaped/autogen/models/shaped_internal_recsys_policies_elsa_model_policy_elsa_model_policy_elsa_model_policy_config.py +141 -0
- shaped/autogen/models/shaped_internal_recsys_policies_gsasrec_model_policy_gsasrec_model_policy_gsas_rec_model_policy_config.py +211 -0
- shaped/autogen/models/shaped_internal_recsys_policies_item2vec_model_policy_item2_vec_model_policy_config.py +140 -0
- shaped/autogen/models/shaped_internal_recsys_policies_item_content_similarity_model_policy_item_content_similarity_model_policy_config.py +195 -0
- shaped/autogen/models/shaped_internal_recsys_policies_lightgbm_model_policy_lightgbm_model_policy_light_gbm_model_policy_config.py +245 -0
- shaped/autogen/models/shaped_internal_recsys_policies_ngram_model_policy_ngram_model_policy_config.py +119 -0
- shaped/autogen/models/shaped_internal_recsys_policies_popular_model_policy_popular_model_policy_config.py +161 -0
- shaped/autogen/models/shaped_internal_recsys_policies_random_model_policy_random_model_policy_config.py +108 -0
- shaped/autogen/models/shaped_internal_recsys_policies_recently_popular_policy_recently_popular_policy_config.py +143 -0
- shaped/autogen/models/shaped_internal_recsys_policies_rising_popular_policy_rising_popular_policy_config.py +123 -0
- shaped/autogen/models/shaped_internal_recsys_policies_sasrec_model_policy_sasrec_model_policy_sas_rec_model_policy_config.py +230 -0
- shaped/autogen/models/shaped_internal_recsys_policies_svd_model_policy_svd_model_policy_config.py +119 -0
- shaped/autogen/models/shaped_internal_recsys_policies_two_tower_model_policy_two_tower_model_policy_two_tower_model_policy_config.py +165 -0
- shaped/autogen/models/shaped_internal_recsys_policies_user_item_content_similarity_model_policy_user_item_content_similarity_model_policy_config.py +153 -0
- shaped/autogen/models/shaped_internal_recsys_policies_widedeep_model_policy_wide_deep_model_policy_config.py +137 -0
- shaped/autogen/models/shaped_internal_recsys_policies_xgboost_model_policy_xg_boost_model_policy_config.py +155 -0
- shaped/autogen/models/shopify_table_config.py +156 -0
- shaped/autogen/models/similarity_retrieve_step.py +123 -0
- shaped/autogen/models/{snowflake_dataset_config.py → snowflake_table_config.py} +47 -18
- shaped/autogen/models/sql_transform_type.py +37 -0
- shaped/autogen/models/sql_view_config.py +111 -0
- shaped/autogen/models/stemmer_tokenizer.py +105 -0
- shaped/autogen/models/step_explanation.py +137 -0
- shaped/autogen/models/steps_inner.py +179 -0
- shaped/autogen/models/strategy.py +134 -0
- shaped/autogen/models/table.py +102 -0
- shaped/autogen/models/table_deployment_type.py +38 -0
- shaped/autogen/models/table_insert_arguments.py +87 -0
- shaped/autogen/models/table_insert_response.py +87 -0
- shaped/autogen/models/text_encoding.py +148 -0
- shaped/autogen/models/text_search_retrieve_step.py +121 -0
- shaped/autogen/models/time_frequency.py +136 -0
- shaped/autogen/models/time_window.py +136 -0
- shaped/autogen/models/time_window_in_days.py +154 -0
- shaped/autogen/models/tokenizer.py +149 -0
- shaped/autogen/models/trained_model_encoder.py +99 -0
- shaped/autogen/models/training_compute_config.py +99 -0
- shaped/autogen/models/training_config.py +121 -0
- shaped/autogen/models/training_config_models_inner.py +540 -0
- shaped/autogen/models/training_strategy.py +37 -0
- shaped/autogen/models/transform_status.py +41 -0
- shaped/autogen/models/trending_mode.py +37 -0
- shaped/autogen/models/truncate_filter_step.py +106 -0
- shaped/autogen/models/tunable_bool.py +97 -0
- shaped/autogen/models/tunable_float.py +118 -0
- shaped/autogen/models/tunable_int.py +118 -0
- shaped/autogen/models/tunable_int_categorical.py +99 -0
- shaped/autogen/models/tunable_string.py +99 -0
- shaped/autogen/models/tuning_config.py +89 -0
- shaped/autogen/models/type.py +150 -0
- shaped/autogen/models/update_table_response.py +87 -0
- shaped/autogen/models/update_view_response.py +87 -0
- shaped/autogen/models/user_attribute_pooling_encoder.py +124 -0
- shaped/autogen/models/user_inner.py +134 -0
- shaped/autogen/models/val_split.py +136 -0
- shaped/autogen/models/validation_error.py +13 -3
- shaped/autogen/models/validation_error_loc_inner.py +150 -0
- shaped/autogen/models/value_type.py +7 -5
- shaped/autogen/models/vector_search_mode.py +101 -0
- shaped/autogen/models/view.py +104 -0
- shaped/autogen/models/view_details_ai.py +140 -0
- shaped/autogen/models/view_details_ai_schema_value.py +153 -0
- shaped/autogen/models/view_details_sql.py +140 -0
- shaped/autogen/models/view_status.py +41 -0
- shaped/autogen/models/weight_decay.py +136 -0
- shaped/autogen/models/whitespace_tokenizer.py +97 -0
- shaped/autogen/models/window_size.py +136 -0
- shaped/autogen/rest.py +10 -4
- shaped/cli/shaped_cli.py +163 -35
- shaped/client.py +591 -171
- shaped/config_builders.py +705 -0
- shaped/query_builder.py +781 -0
- {shaped-2.0.1.dist-info → shaped-2.0.4.dist-info}/METADATA +141 -6
- shaped-2.0.4.dist-info/RECORD +296 -0
- {shaped-2.0.1.dist-info → shaped-2.0.4.dist-info}/WHEEL +1 -1
- shaped-2.0.4.dist-info/entry_points.txt +2 -0
- shaped/autogen/api/model_inference_api.py +0 -2825
- shaped/autogen/models/amplitude_dataset_config.py +0 -96
- shaped/autogen/models/aws_pinpoint_dataset_config.py +0 -96
- shaped/autogen/models/big_query_dataset_config.py +0 -114
- shaped/autogen/models/complement_items_request.py +0 -99
- shaped/autogen/models/complement_items_response.py +0 -89
- shaped/autogen/models/connectors_inner.py +0 -134
- shaped/autogen/models/create_dataset_arguments.py +0 -263
- shaped/autogen/models/create_embedding_response.py +0 -87
- shaped/autogen/models/create_item_embedding_request.py +0 -89
- shaped/autogen/models/create_model_arguments.py +0 -107
- shaped/autogen/models/create_model_response.py +0 -87
- shaped/autogen/models/create_user_embedding_request.py +0 -89
- shaped/autogen/models/custom_dataset_config.py +0 -115
- shaped/autogen/models/dataset_config.py +0 -101
- shaped/autogen/models/dataset_schema_type.py +0 -47
- shaped/autogen/models/datasets_inner.py +0 -91
- shaped/autogen/models/delete_model_response.py +0 -87
- shaped/autogen/models/fetch_config.py +0 -95
- shaped/autogen/models/file_config.py +0 -105
- shaped/autogen/models/file_source_config.py +0 -89
- shaped/autogen/models/inference_config.py +0 -101
- shaped/autogen/models/insert_model_response.py +0 -87
- shaped/autogen/models/interaction.py +0 -87
- shaped/autogen/models/list_datasets_response.py +0 -95
- shaped/autogen/models/list_models_response.py +0 -95
- shaped/autogen/models/model_config.py +0 -99
- shaped/autogen/models/model_response.py +0 -95
- shaped/autogen/models/mongo_db_dataset_config.py +0 -119
- shaped/autogen/models/post_rank_request.py +0 -117
- shaped/autogen/models/rank_attribute_response.py +0 -89
- shaped/autogen/models/rank_grid_attribute_request.py +0 -91
- shaped/autogen/models/rank_grid_attribute_request1.py +0 -93
- shaped/autogen/models/rank_grid_attribute_response.py +0 -91
- shaped/autogen/models/rank_response.py +0 -91
- shaped/autogen/models/retrieve_request.py +0 -101
- shaped/autogen/models/retrieve_response.py +0 -91
- shaped/autogen/models/retriever_top_k_override.py +0 -97
- shaped/autogen/models/rudder_stack_dataset_config.py +0 -96
- shaped/autogen/models/segment_dataset_config.py +0 -96
- shaped/autogen/models/similar_item_request.py +0 -101
- shaped/autogen/models/similar_response.py +0 -89
- shaped/autogen/models/similar_users_request.py +0 -99
- shaped/autogen/models/successful_response.py +0 -87
- shaped/autogen/models/view_model_response.py +0 -99
- shaped-2.0.1.dist-info/RECORD +0 -73
- shaped-2.0.1.dist-info/entry_points.txt +0 -2
- {shaped-2.0.1.dist-info → shaped-2.0.4.dist-info}/top_level.txt +0 -0
- {shaped-2.0.1.dist-info → shaped-2.0.4.dist-info}/zip-safe +0 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Shaped API
|
|
5
|
+
|
|
6
|
+
Welcome to Shaped's API reference docs. These provide a detailed view of the endpoints and CLI commands that Shaped provides and brief explanations of how they should be used. The Shaped API has four main endpoints: **Tables** - Provision and manage batch and real-time data connectors. **Views** - Configure SQL transformations and AI enrichment on your input data. Use SQL to combine multiple data sources or use an LLM to add new categories, extract specific attributes from descriptions, etc. **Engines** - Deploy and manage your relevance engines. The Engine API exposes configuration for indexing logic, input datasets, externam embeddings, and more. **Query** - Execute queries against your engines, to return data based on an input query or rerank an existing list. The Query API exposes the retrieve, filter, score, and ranking steps of the 4-stage ranking architecture. The base URL for each endpoint is: `https://api.shaped.ai/v2`
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 2.0.4
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
import pprint
|
|
17
|
+
import re # noqa: F401
|
|
18
|
+
import json
|
|
19
|
+
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
21
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
22
|
+
from shaped.autogen.models.parameter_definition import ParameterDefinition
|
|
23
|
+
from shaped.autogen.models.query import Query
|
|
24
|
+
from typing import Optional, Set
|
|
25
|
+
from typing_extensions import Self
|
|
26
|
+
|
|
27
|
+
class QueryDefinition(BaseModel):
|
|
28
|
+
"""
|
|
29
|
+
Defines a single, named query recipe (\"stored procedure\"). The query can be either: - A QueryConfig object (structured query configuration) - A SQL query string (will be transpiled to QueryConfig at initialization)
|
|
30
|
+
""" # noqa: E501
|
|
31
|
+
query: Query
|
|
32
|
+
parameters: Optional[Dict[str, ParameterDefinition]] = Field(default=None, description="Dictionary of parameter definitions for query parameterization.")
|
|
33
|
+
__properties: ClassVar[List[str]] = ["query", "parameters"]
|
|
34
|
+
|
|
35
|
+
model_config = ConfigDict(
|
|
36
|
+
populate_by_name=True,
|
|
37
|
+
validate_assignment=True,
|
|
38
|
+
protected_namespaces=(),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def to_str(self) -> str:
|
|
43
|
+
"""Returns the string representation of the model using alias"""
|
|
44
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
45
|
+
|
|
46
|
+
def to_json(self) -> str:
|
|
47
|
+
"""Returns the JSON representation of the model using alias"""
|
|
48
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
49
|
+
return json.dumps(self.to_dict())
|
|
50
|
+
|
|
51
|
+
@classmethod
|
|
52
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
53
|
+
"""Create an instance of QueryDefinition from a JSON string"""
|
|
54
|
+
return cls.from_dict(json.loads(json_str))
|
|
55
|
+
|
|
56
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
57
|
+
"""Return the dictionary representation of the model using alias.
|
|
58
|
+
|
|
59
|
+
This has the following differences from calling pydantic's
|
|
60
|
+
`self.model_dump(by_alias=True)`:
|
|
61
|
+
|
|
62
|
+
* `None` is only added to the output dict for nullable fields that
|
|
63
|
+
were set at model initialization. Other fields with value `None`
|
|
64
|
+
are ignored.
|
|
65
|
+
"""
|
|
66
|
+
excluded_fields: Set[str] = set([
|
|
67
|
+
])
|
|
68
|
+
|
|
69
|
+
_dict = self.model_dump(
|
|
70
|
+
by_alias=True,
|
|
71
|
+
exclude=excluded_fields,
|
|
72
|
+
exclude_none=True,
|
|
73
|
+
)
|
|
74
|
+
# override the default output from pydantic by calling `to_dict()` of query
|
|
75
|
+
if self.query:
|
|
76
|
+
_dict['query'] = self.query.to_dict()
|
|
77
|
+
# override the default output from pydantic by calling `to_dict()` of each value in parameters (dict)
|
|
78
|
+
_field_dict = {}
|
|
79
|
+
if self.parameters:
|
|
80
|
+
for _key_parameters in self.parameters:
|
|
81
|
+
if self.parameters[_key_parameters]:
|
|
82
|
+
_field_dict[_key_parameters] = self.parameters[_key_parameters].to_dict()
|
|
83
|
+
_dict['parameters'] = _field_dict
|
|
84
|
+
return _dict
|
|
85
|
+
|
|
86
|
+
@classmethod
|
|
87
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
88
|
+
"""Create an instance of QueryDefinition from a dict"""
|
|
89
|
+
if obj is None:
|
|
90
|
+
return None
|
|
91
|
+
|
|
92
|
+
if not isinstance(obj, dict):
|
|
93
|
+
return cls.model_validate(obj)
|
|
94
|
+
|
|
95
|
+
_obj = cls.model_validate({
|
|
96
|
+
"query": Query.from_dict(obj["query"]) if obj.get("query") is not None else None,
|
|
97
|
+
"parameters": dict(
|
|
98
|
+
(_k, ParameterDefinition.from_dict(_v))
|
|
99
|
+
for _k, _v in obj["parameters"].items()
|
|
100
|
+
)
|
|
101
|
+
if obj.get("parameters") is not None
|
|
102
|
+
else None
|
|
103
|
+
})
|
|
104
|
+
return _obj
|
|
105
|
+
|
|
106
|
+
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Shaped API
|
|
5
|
+
|
|
6
|
+
Welcome to Shaped's API reference docs. These provide a detailed view of the endpoints and CLI commands that Shaped provides and brief explanations of how they should be used. The Shaped API has four main endpoints: **Tables** - Provision and manage batch and real-time data connectors. **Views** - Configure SQL transformations and AI enrichment on your input data. Use SQL to combine multiple data sources or use an LLM to add new categories, extract specific attributes from descriptions, etc. **Engines** - Deploy and manage your relevance engines. The Engine API exposes configuration for indexing logic, input datasets, externam embeddings, and more. **Query** - Execute queries against your engines, to return data based on an input query or rerank an existing list. The Query API exposes the retrieve, filter, score, and ranking steps of the 4-stage ranking architecture. The base URL for each endpoint is: `https://api.shaped.ai/v2`
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 2.0.4
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
from inspect import getfullargspec
|
|
17
|
+
import json
|
|
18
|
+
import pprint
|
|
19
|
+
import re # noqa: F401
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator
|
|
21
|
+
from typing import Optional
|
|
22
|
+
from shaped.autogen.models.interaction_pooling_encoder import InteractionPoolingEncoder
|
|
23
|
+
from shaped.autogen.models.interaction_round_robin_encoder import InteractionRoundRobinEncoder
|
|
24
|
+
from shaped.autogen.models.item_attribute_pooling_encoder import ItemAttributePoolingEncoder
|
|
25
|
+
from shaped.autogen.models.precomputed_item_embedding import PrecomputedItemEmbedding
|
|
26
|
+
from shaped.autogen.models.precomputed_user_embedding import PrecomputedUserEmbedding
|
|
27
|
+
from shaped.autogen.models.user_attribute_pooling_encoder import UserAttributePoolingEncoder
|
|
28
|
+
from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict
|
|
29
|
+
from typing_extensions import Literal, Self
|
|
30
|
+
from pydantic import Field
|
|
31
|
+
|
|
32
|
+
QUERYENCODER_ANY_OF_SCHEMAS = ["InteractionPoolingEncoder", "InteractionRoundRobinEncoder", "ItemAttributePoolingEncoder", "PrecomputedItemEmbedding", "PrecomputedUserEmbedding", "UserAttributePoolingEncoder"]
|
|
33
|
+
|
|
34
|
+
class QueryEncoder(BaseModel):
|
|
35
|
+
"""
|
|
36
|
+
Encoder to generate query vector from user/item input.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
# data type: InteractionPoolingEncoder
|
|
40
|
+
anyof_schema_1_validator: Optional[InteractionPoolingEncoder] = None
|
|
41
|
+
# data type: InteractionRoundRobinEncoder
|
|
42
|
+
anyof_schema_2_validator: Optional[InteractionRoundRobinEncoder] = None
|
|
43
|
+
# data type: UserAttributePoolingEncoder
|
|
44
|
+
anyof_schema_3_validator: Optional[UserAttributePoolingEncoder] = None
|
|
45
|
+
# data type: PrecomputedUserEmbedding
|
|
46
|
+
anyof_schema_4_validator: Optional[PrecomputedUserEmbedding] = None
|
|
47
|
+
# data type: ItemAttributePoolingEncoder
|
|
48
|
+
anyof_schema_5_validator: Optional[ItemAttributePoolingEncoder] = None
|
|
49
|
+
# data type: PrecomputedItemEmbedding
|
|
50
|
+
anyof_schema_6_validator: Optional[PrecomputedItemEmbedding] = None
|
|
51
|
+
if TYPE_CHECKING:
|
|
52
|
+
actual_instance: Optional[Union[InteractionPoolingEncoder, InteractionRoundRobinEncoder, ItemAttributePoolingEncoder, PrecomputedItemEmbedding, PrecomputedUserEmbedding, UserAttributePoolingEncoder]] = None
|
|
53
|
+
else:
|
|
54
|
+
actual_instance: Any = None
|
|
55
|
+
any_of_schemas: Set[str] = { "InteractionPoolingEncoder", "InteractionRoundRobinEncoder", "ItemAttributePoolingEncoder", "PrecomputedItemEmbedding", "PrecomputedUserEmbedding", "UserAttributePoolingEncoder" }
|
|
56
|
+
|
|
57
|
+
model_config = {
|
|
58
|
+
"validate_assignment": True,
|
|
59
|
+
"protected_namespaces": (),
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
63
|
+
if args:
|
|
64
|
+
if len(args) > 1:
|
|
65
|
+
raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
|
|
66
|
+
if kwargs:
|
|
67
|
+
raise ValueError("If a position argument is used, keyword arguments cannot be used.")
|
|
68
|
+
super().__init__(actual_instance=args[0])
|
|
69
|
+
else:
|
|
70
|
+
super().__init__(**kwargs)
|
|
71
|
+
|
|
72
|
+
@field_validator('actual_instance')
|
|
73
|
+
def actual_instance_must_validate_anyof(cls, v):
|
|
74
|
+
instance = QueryEncoder.model_construct()
|
|
75
|
+
error_messages = []
|
|
76
|
+
# validate data type: InteractionPoolingEncoder
|
|
77
|
+
if not isinstance(v, InteractionPoolingEncoder):
|
|
78
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `InteractionPoolingEncoder`")
|
|
79
|
+
else:
|
|
80
|
+
return v
|
|
81
|
+
|
|
82
|
+
# validate data type: InteractionRoundRobinEncoder
|
|
83
|
+
if not isinstance(v, InteractionRoundRobinEncoder):
|
|
84
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `InteractionRoundRobinEncoder`")
|
|
85
|
+
else:
|
|
86
|
+
return v
|
|
87
|
+
|
|
88
|
+
# validate data type: UserAttributePoolingEncoder
|
|
89
|
+
if not isinstance(v, UserAttributePoolingEncoder):
|
|
90
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `UserAttributePoolingEncoder`")
|
|
91
|
+
else:
|
|
92
|
+
return v
|
|
93
|
+
|
|
94
|
+
# validate data type: PrecomputedUserEmbedding
|
|
95
|
+
if not isinstance(v, PrecomputedUserEmbedding):
|
|
96
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `PrecomputedUserEmbedding`")
|
|
97
|
+
else:
|
|
98
|
+
return v
|
|
99
|
+
|
|
100
|
+
# validate data type: ItemAttributePoolingEncoder
|
|
101
|
+
if not isinstance(v, ItemAttributePoolingEncoder):
|
|
102
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `ItemAttributePoolingEncoder`")
|
|
103
|
+
else:
|
|
104
|
+
return v
|
|
105
|
+
|
|
106
|
+
# validate data type: PrecomputedItemEmbedding
|
|
107
|
+
if not isinstance(v, PrecomputedItemEmbedding):
|
|
108
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `PrecomputedItemEmbedding`")
|
|
109
|
+
else:
|
|
110
|
+
return v
|
|
111
|
+
|
|
112
|
+
if error_messages:
|
|
113
|
+
# no match
|
|
114
|
+
raise ValueError("No match found when setting the actual_instance in QueryEncoder with anyOf schemas: InteractionPoolingEncoder, InteractionRoundRobinEncoder, ItemAttributePoolingEncoder, PrecomputedItemEmbedding, PrecomputedUserEmbedding, UserAttributePoolingEncoder. Details: " + ", ".join(error_messages))
|
|
115
|
+
else:
|
|
116
|
+
return v
|
|
117
|
+
|
|
118
|
+
@classmethod
|
|
119
|
+
def from_dict(cls, obj: Dict[str, Any]) -> Self:
|
|
120
|
+
return cls.from_json(json.dumps(obj))
|
|
121
|
+
|
|
122
|
+
@classmethod
|
|
123
|
+
def from_json(cls, json_str: str) -> Self:
|
|
124
|
+
"""Returns the object represented by the json string"""
|
|
125
|
+
instance = cls.model_construct()
|
|
126
|
+
error_messages = []
|
|
127
|
+
# anyof_schema_1_validator: Optional[InteractionPoolingEncoder] = None
|
|
128
|
+
try:
|
|
129
|
+
instance.actual_instance = InteractionPoolingEncoder.from_json(json_str)
|
|
130
|
+
return instance
|
|
131
|
+
except (ValidationError, ValueError) as e:
|
|
132
|
+
error_messages.append(str(e))
|
|
133
|
+
# anyof_schema_2_validator: Optional[InteractionRoundRobinEncoder] = None
|
|
134
|
+
try:
|
|
135
|
+
instance.actual_instance = InteractionRoundRobinEncoder.from_json(json_str)
|
|
136
|
+
return instance
|
|
137
|
+
except (ValidationError, ValueError) as e:
|
|
138
|
+
error_messages.append(str(e))
|
|
139
|
+
# anyof_schema_3_validator: Optional[UserAttributePoolingEncoder] = None
|
|
140
|
+
try:
|
|
141
|
+
instance.actual_instance = UserAttributePoolingEncoder.from_json(json_str)
|
|
142
|
+
return instance
|
|
143
|
+
except (ValidationError, ValueError) as e:
|
|
144
|
+
error_messages.append(str(e))
|
|
145
|
+
# anyof_schema_4_validator: Optional[PrecomputedUserEmbedding] = None
|
|
146
|
+
try:
|
|
147
|
+
instance.actual_instance = PrecomputedUserEmbedding.from_json(json_str)
|
|
148
|
+
return instance
|
|
149
|
+
except (ValidationError, ValueError) as e:
|
|
150
|
+
error_messages.append(str(e))
|
|
151
|
+
# anyof_schema_5_validator: Optional[ItemAttributePoolingEncoder] = None
|
|
152
|
+
try:
|
|
153
|
+
instance.actual_instance = ItemAttributePoolingEncoder.from_json(json_str)
|
|
154
|
+
return instance
|
|
155
|
+
except (ValidationError, ValueError) as e:
|
|
156
|
+
error_messages.append(str(e))
|
|
157
|
+
# anyof_schema_6_validator: Optional[PrecomputedItemEmbedding] = None
|
|
158
|
+
try:
|
|
159
|
+
instance.actual_instance = PrecomputedItemEmbedding.from_json(json_str)
|
|
160
|
+
return instance
|
|
161
|
+
except (ValidationError, ValueError) as e:
|
|
162
|
+
error_messages.append(str(e))
|
|
163
|
+
|
|
164
|
+
if error_messages:
|
|
165
|
+
# no match
|
|
166
|
+
raise ValueError("No match found when deserializing the JSON string into QueryEncoder with anyOf schemas: InteractionPoolingEncoder, InteractionRoundRobinEncoder, ItemAttributePoolingEncoder, PrecomputedItemEmbedding, PrecomputedUserEmbedding, UserAttributePoolingEncoder. Details: " + ", ".join(error_messages))
|
|
167
|
+
else:
|
|
168
|
+
return instance
|
|
169
|
+
|
|
170
|
+
def to_json(self) -> str:
|
|
171
|
+
"""Returns the JSON representation of the actual instance"""
|
|
172
|
+
if self.actual_instance is None:
|
|
173
|
+
return "null"
|
|
174
|
+
|
|
175
|
+
if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
|
|
176
|
+
return self.actual_instance.to_json()
|
|
177
|
+
else:
|
|
178
|
+
return json.dumps(self.actual_instance)
|
|
179
|
+
|
|
180
|
+
def to_dict(self) -> Optional[Union[Dict[str, Any], InteractionPoolingEncoder, InteractionRoundRobinEncoder, ItemAttributePoolingEncoder, PrecomputedItemEmbedding, PrecomputedUserEmbedding, UserAttributePoolingEncoder]]:
|
|
181
|
+
"""Returns the dict representation of the actual instance"""
|
|
182
|
+
if self.actual_instance is None:
|
|
183
|
+
return None
|
|
184
|
+
|
|
185
|
+
if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
|
|
186
|
+
return self.actual_instance.to_dict()
|
|
187
|
+
else:
|
|
188
|
+
return self.actual_instance
|
|
189
|
+
|
|
190
|
+
def to_str(self) -> str:
|
|
191
|
+
"""Returns the string representation of the actual instance"""
|
|
192
|
+
return pprint.pformat(self.model_dump())
|
|
193
|
+
|
|
194
|
+
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Shaped API
|
|
5
|
+
|
|
6
|
+
Welcome to Shaped's API reference docs. These provide a detailed view of the endpoints and CLI commands that Shaped provides and brief explanations of how they should be used. The Shaped API has four main endpoints: **Tables** - Provision and manage batch and real-time data connectors. **Views** - Configure SQL transformations and AI enrichment on your input data. Use SQL to combine multiple data sources or use an LLM to add new categories, extract specific attributes from descriptions, etc. **Engines** - Deploy and manage your relevance engines. The Engine API exposes configuration for indexing logic, input datasets, externam embeddings, and more. **Query** - Execute queries against your engines, to return data based on an input query or rerank an existing list. The Query API exposes the retrieve, filter, score, and ranking steps of the 4-stage ranking architecture. The base URL for each endpoint is: `https://api.shaped.ai/v2`
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 2.0.4
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
import pprint
|
|
17
|
+
import re # noqa: F401
|
|
18
|
+
import json
|
|
19
|
+
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr
|
|
21
|
+
from typing import Any, ClassVar, Dict, List, Optional, Union
|
|
22
|
+
from shaped.autogen.models.inner_uid import InnerUid
|
|
23
|
+
from shaped.autogen.models.pipeline_stage_explanation import PipelineStageExplanation
|
|
24
|
+
from typing import Optional, Set
|
|
25
|
+
from typing_extensions import Self
|
|
26
|
+
|
|
27
|
+
class QueryExplanation(BaseModel):
|
|
28
|
+
"""
|
|
29
|
+
Detailed explanation of the query execution pipeline. This follows the declarative query structure, providing explanations for each stage and step in the pipeline. Per-entity journey tracking is attached to individual Result objects in QueryResult.results.
|
|
30
|
+
""" # noqa: E501
|
|
31
|
+
query_name: Optional[StrictStr] = None
|
|
32
|
+
query_type: Optional[StrictStr] = None
|
|
33
|
+
parameters: Optional[Dict[str, Any]] = Field(default=None, description="Parameters that were passed to the query. Shows the resolved values for any $parameter references used in the query configuration.")
|
|
34
|
+
pagination_id: Optional[StrictStr] = None
|
|
35
|
+
retrieve_stage: Optional[PipelineStageExplanation] = None
|
|
36
|
+
filter_stage: Optional[PipelineStageExplanation] = None
|
|
37
|
+
score_stage: Optional[PipelineStageExplanation] = None
|
|
38
|
+
reorder_stage: Optional[PipelineStageExplanation] = None
|
|
39
|
+
total_execution_time_ms: Optional[Union[StrictFloat, StrictInt]] = None
|
|
40
|
+
final_result_count: Optional[StrictInt] = None
|
|
41
|
+
limit_applied: Optional[StrictInt] = None
|
|
42
|
+
inner_uid: Optional[InnerUid] = None
|
|
43
|
+
outer_uid: Optional[StrictStr] = None
|
|
44
|
+
additional_properties: Dict[str, Any] = {}
|
|
45
|
+
__properties: ClassVar[List[str]] = ["query_name", "query_type", "parameters", "pagination_id", "retrieve_stage", "filter_stage", "score_stage", "reorder_stage", "total_execution_time_ms", "final_result_count", "limit_applied", "inner_uid", "outer_uid"]
|
|
46
|
+
|
|
47
|
+
model_config = ConfigDict(
|
|
48
|
+
populate_by_name=True,
|
|
49
|
+
validate_assignment=True,
|
|
50
|
+
protected_namespaces=(),
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def to_str(self) -> str:
|
|
55
|
+
"""Returns the string representation of the model using alias"""
|
|
56
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
57
|
+
|
|
58
|
+
def to_json(self) -> str:
|
|
59
|
+
"""Returns the JSON representation of the model using alias"""
|
|
60
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
61
|
+
return json.dumps(self.to_dict())
|
|
62
|
+
|
|
63
|
+
@classmethod
|
|
64
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
65
|
+
"""Create an instance of QueryExplanation from a JSON string"""
|
|
66
|
+
return cls.from_dict(json.loads(json_str))
|
|
67
|
+
|
|
68
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
69
|
+
"""Return the dictionary representation of the model using alias.
|
|
70
|
+
|
|
71
|
+
This has the following differences from calling pydantic's
|
|
72
|
+
`self.model_dump(by_alias=True)`:
|
|
73
|
+
|
|
74
|
+
* `None` is only added to the output dict for nullable fields that
|
|
75
|
+
were set at model initialization. Other fields with value `None`
|
|
76
|
+
are ignored.
|
|
77
|
+
* Fields in `self.additional_properties` are added to the output dict.
|
|
78
|
+
"""
|
|
79
|
+
excluded_fields: Set[str] = set([
|
|
80
|
+
"additional_properties",
|
|
81
|
+
])
|
|
82
|
+
|
|
83
|
+
_dict = self.model_dump(
|
|
84
|
+
by_alias=True,
|
|
85
|
+
exclude=excluded_fields,
|
|
86
|
+
exclude_none=True,
|
|
87
|
+
)
|
|
88
|
+
# override the default output from pydantic by calling `to_dict()` of retrieve_stage
|
|
89
|
+
if self.retrieve_stage:
|
|
90
|
+
_dict['retrieve_stage'] = self.retrieve_stage.to_dict()
|
|
91
|
+
# override the default output from pydantic by calling `to_dict()` of filter_stage
|
|
92
|
+
if self.filter_stage:
|
|
93
|
+
_dict['filter_stage'] = self.filter_stage.to_dict()
|
|
94
|
+
# override the default output from pydantic by calling `to_dict()` of score_stage
|
|
95
|
+
if self.score_stage:
|
|
96
|
+
_dict['score_stage'] = self.score_stage.to_dict()
|
|
97
|
+
# override the default output from pydantic by calling `to_dict()` of reorder_stage
|
|
98
|
+
if self.reorder_stage:
|
|
99
|
+
_dict['reorder_stage'] = self.reorder_stage.to_dict()
|
|
100
|
+
# override the default output from pydantic by calling `to_dict()` of inner_uid
|
|
101
|
+
if self.inner_uid:
|
|
102
|
+
_dict['inner_uid'] = self.inner_uid.to_dict()
|
|
103
|
+
# puts key-value pairs in additional_properties in the top level
|
|
104
|
+
if self.additional_properties is not None:
|
|
105
|
+
for _key, _value in self.additional_properties.items():
|
|
106
|
+
_dict[_key] = _value
|
|
107
|
+
|
|
108
|
+
# set to None if query_name (nullable) is None
|
|
109
|
+
# and model_fields_set contains the field
|
|
110
|
+
if self.query_name is None and "query_name" in self.model_fields_set:
|
|
111
|
+
_dict['query_name'] = None
|
|
112
|
+
|
|
113
|
+
# set to None if query_type (nullable) is None
|
|
114
|
+
# and model_fields_set contains the field
|
|
115
|
+
if self.query_type is None and "query_type" in self.model_fields_set:
|
|
116
|
+
_dict['query_type'] = None
|
|
117
|
+
|
|
118
|
+
# set to None if pagination_id (nullable) is None
|
|
119
|
+
# and model_fields_set contains the field
|
|
120
|
+
if self.pagination_id is None and "pagination_id" in self.model_fields_set:
|
|
121
|
+
_dict['pagination_id'] = None
|
|
122
|
+
|
|
123
|
+
# set to None if retrieve_stage (nullable) is None
|
|
124
|
+
# and model_fields_set contains the field
|
|
125
|
+
if self.retrieve_stage is None and "retrieve_stage" in self.model_fields_set:
|
|
126
|
+
_dict['retrieve_stage'] = None
|
|
127
|
+
|
|
128
|
+
# set to None if filter_stage (nullable) is None
|
|
129
|
+
# and model_fields_set contains the field
|
|
130
|
+
if self.filter_stage is None and "filter_stage" in self.model_fields_set:
|
|
131
|
+
_dict['filter_stage'] = None
|
|
132
|
+
|
|
133
|
+
# set to None if score_stage (nullable) is None
|
|
134
|
+
# and model_fields_set contains the field
|
|
135
|
+
if self.score_stage is None and "score_stage" in self.model_fields_set:
|
|
136
|
+
_dict['score_stage'] = None
|
|
137
|
+
|
|
138
|
+
# set to None if reorder_stage (nullable) is None
|
|
139
|
+
# and model_fields_set contains the field
|
|
140
|
+
if self.reorder_stage is None and "reorder_stage" in self.model_fields_set:
|
|
141
|
+
_dict['reorder_stage'] = None
|
|
142
|
+
|
|
143
|
+
# set to None if total_execution_time_ms (nullable) is None
|
|
144
|
+
# and model_fields_set contains the field
|
|
145
|
+
if self.total_execution_time_ms is None and "total_execution_time_ms" in self.model_fields_set:
|
|
146
|
+
_dict['total_execution_time_ms'] = None
|
|
147
|
+
|
|
148
|
+
# set to None if final_result_count (nullable) is None
|
|
149
|
+
# and model_fields_set contains the field
|
|
150
|
+
if self.final_result_count is None and "final_result_count" in self.model_fields_set:
|
|
151
|
+
_dict['final_result_count'] = None
|
|
152
|
+
|
|
153
|
+
# set to None if limit_applied (nullable) is None
|
|
154
|
+
# and model_fields_set contains the field
|
|
155
|
+
if self.limit_applied is None and "limit_applied" in self.model_fields_set:
|
|
156
|
+
_dict['limit_applied'] = None
|
|
157
|
+
|
|
158
|
+
# set to None if inner_uid (nullable) is None
|
|
159
|
+
# and model_fields_set contains the field
|
|
160
|
+
if self.inner_uid is None and "inner_uid" in self.model_fields_set:
|
|
161
|
+
_dict['inner_uid'] = None
|
|
162
|
+
|
|
163
|
+
# set to None if outer_uid (nullable) is None
|
|
164
|
+
# and model_fields_set contains the field
|
|
165
|
+
if self.outer_uid is None and "outer_uid" in self.model_fields_set:
|
|
166
|
+
_dict['outer_uid'] = None
|
|
167
|
+
|
|
168
|
+
return _dict
|
|
169
|
+
|
|
170
|
+
@classmethod
|
|
171
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
172
|
+
"""Create an instance of QueryExplanation from a dict"""
|
|
173
|
+
if obj is None:
|
|
174
|
+
return None
|
|
175
|
+
|
|
176
|
+
if not isinstance(obj, dict):
|
|
177
|
+
return cls.model_validate(obj)
|
|
178
|
+
|
|
179
|
+
_obj = cls.model_validate({
|
|
180
|
+
"query_name": obj.get("query_name"),
|
|
181
|
+
"query_type": obj.get("query_type"),
|
|
182
|
+
"parameters": obj.get("parameters"),
|
|
183
|
+
"pagination_id": obj.get("pagination_id"),
|
|
184
|
+
"retrieve_stage": PipelineStageExplanation.from_dict(obj["retrieve_stage"]) if obj.get("retrieve_stage") is not None else None,
|
|
185
|
+
"filter_stage": PipelineStageExplanation.from_dict(obj["filter_stage"]) if obj.get("filter_stage") is not None else None,
|
|
186
|
+
"score_stage": PipelineStageExplanation.from_dict(obj["score_stage"]) if obj.get("score_stage") is not None else None,
|
|
187
|
+
"reorder_stage": PipelineStageExplanation.from_dict(obj["reorder_stage"]) if obj.get("reorder_stage") is not None else None,
|
|
188
|
+
"total_execution_time_ms": obj.get("total_execution_time_ms"),
|
|
189
|
+
"final_result_count": obj.get("final_result_count"),
|
|
190
|
+
"limit_applied": obj.get("limit_applied"),
|
|
191
|
+
"inner_uid": InnerUid.from_dict(obj["inner_uid"]) if obj.get("inner_uid") is not None else None,
|
|
192
|
+
"outer_uid": obj.get("outer_uid")
|
|
193
|
+
})
|
|
194
|
+
# store additional fields in additional_properties
|
|
195
|
+
for _key in obj.keys():
|
|
196
|
+
if _key not in cls.__properties:
|
|
197
|
+
_obj.additional_properties[_key] = obj.get(_key)
|
|
198
|
+
|
|
199
|
+
return _obj
|
|
200
|
+
|
|
201
|
+
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Shaped API
|
|
5
|
+
|
|
6
|
+
Welcome to Shaped's API reference docs. These provide a detailed view of the endpoints and CLI commands that Shaped provides and brief explanations of how they should be used. The Shaped API has four main endpoints: **Tables** - Provision and manage batch and real-time data connectors. **Views** - Configure SQL transformations and AI enrichment on your input data. Use SQL to combine multiple data sources or use an LLM to add new categories, extract specific attributes from descriptions, etc. **Engines** - Deploy and manage your relevance engines. The Engine API exposes configuration for indexing logic, input datasets, externam embeddings, and more. **Query** - Execute queries against your engines, to return data based on an input query or rerank an existing list. The Query API exposes the retrieve, filter, score, and ranking steps of the 4-stage ranking architecture. The base URL for each endpoint is: `https://api.shaped.ai/v2`
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 2.0.4
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
import pprint
|
|
17
|
+
import re # noqa: F401
|
|
18
|
+
import json
|
|
19
|
+
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
|
|
21
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
22
|
+
from shaped.autogen.models.parameters_value import ParametersValue
|
|
23
|
+
from shaped.autogen.models.query1 import Query1
|
|
24
|
+
from typing import Optional, Set
|
|
25
|
+
from typing_extensions import Self
|
|
26
|
+
|
|
27
|
+
class QueryRequest(BaseModel):
|
|
28
|
+
"""
|
|
29
|
+
Request model for ad-hoc queries.
|
|
30
|
+
""" # noqa: E501
|
|
31
|
+
parameters: Optional[Dict[str, ParametersValue]] = Field(default=None, description="Query parameters that can be referenced in the query configuration using $parameter.name syntax. Supports int, float, str, bool, and lists of these types.")
|
|
32
|
+
query: Query1
|
|
33
|
+
return_metadata: Optional[StrictBool] = Field(default=True, description="Whether to include entity metadata (attributes) in the response. When true, each result includes an 'attributes' field with entity metadata.")
|
|
34
|
+
return_explanation: Optional[StrictBool] = Field(default=False, description="Whether to include a detailed explanation of query execution. When true, the response includes an 'explanation' field with information about retrieval, filtering, scoring, and reordering stages.")
|
|
35
|
+
return_journey_explanations: Optional[StrictBool] = Field(default=False, description="Whether to include per-entity journey tracking in results. When true, each result includes a 'journey' field showing how that entity moved through the query pipeline.")
|
|
36
|
+
pagination_key: Optional[StrictStr] = None
|
|
37
|
+
ignore_pagination: Optional[StrictBool] = Field(default=False, description="Whether to ignore pagination and return results from the beginning. When true, pagination_key is ignored and results start from the first page.")
|
|
38
|
+
__properties: ClassVar[List[str]] = ["parameters", "query", "return_metadata", "return_explanation", "return_journey_explanations", "pagination_key", "ignore_pagination"]
|
|
39
|
+
|
|
40
|
+
model_config = ConfigDict(
|
|
41
|
+
populate_by_name=True,
|
|
42
|
+
validate_assignment=True,
|
|
43
|
+
protected_namespaces=(),
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def to_str(self) -> str:
|
|
48
|
+
"""Returns the string representation of the model using alias"""
|
|
49
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
50
|
+
|
|
51
|
+
def to_json(self) -> str:
|
|
52
|
+
"""Returns the JSON representation of the model using alias"""
|
|
53
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
54
|
+
return json.dumps(self.to_dict())
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
58
|
+
"""Create an instance of QueryRequest from a JSON string"""
|
|
59
|
+
return cls.from_dict(json.loads(json_str))
|
|
60
|
+
|
|
61
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
62
|
+
"""Return the dictionary representation of the model using alias.
|
|
63
|
+
|
|
64
|
+
This has the following differences from calling pydantic's
|
|
65
|
+
`self.model_dump(by_alias=True)`:
|
|
66
|
+
|
|
67
|
+
* `None` is only added to the output dict for nullable fields that
|
|
68
|
+
were set at model initialization. Other fields with value `None`
|
|
69
|
+
are ignored.
|
|
70
|
+
"""
|
|
71
|
+
excluded_fields: Set[str] = set([
|
|
72
|
+
])
|
|
73
|
+
|
|
74
|
+
_dict = self.model_dump(
|
|
75
|
+
by_alias=True,
|
|
76
|
+
exclude=excluded_fields,
|
|
77
|
+
exclude_none=True,
|
|
78
|
+
)
|
|
79
|
+
# override the default output from pydantic by calling `to_dict()` of each value in parameters (dict)
|
|
80
|
+
_field_dict = {}
|
|
81
|
+
if self.parameters:
|
|
82
|
+
for _key_parameters in self.parameters:
|
|
83
|
+
if self.parameters[_key_parameters]:
|
|
84
|
+
_field_dict[_key_parameters] = self.parameters[_key_parameters].to_dict()
|
|
85
|
+
_dict['parameters'] = _field_dict
|
|
86
|
+
# override the default output from pydantic by calling `to_dict()` of query
|
|
87
|
+
if self.query:
|
|
88
|
+
_dict['query'] = self.query.to_dict()
|
|
89
|
+
# set to None if pagination_key (nullable) is None
|
|
90
|
+
# and model_fields_set contains the field
|
|
91
|
+
if self.pagination_key is None and "pagination_key" in self.model_fields_set:
|
|
92
|
+
_dict['pagination_key'] = None
|
|
93
|
+
|
|
94
|
+
return _dict
|
|
95
|
+
|
|
96
|
+
@classmethod
|
|
97
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
98
|
+
"""Create an instance of QueryRequest from a dict"""
|
|
99
|
+
if obj is None:
|
|
100
|
+
return None
|
|
101
|
+
|
|
102
|
+
if not isinstance(obj, dict):
|
|
103
|
+
return cls.model_validate(obj)
|
|
104
|
+
|
|
105
|
+
_obj = cls.model_validate({
|
|
106
|
+
"parameters": dict(
|
|
107
|
+
(_k, ParametersValue.from_dict(_v))
|
|
108
|
+
for _k, _v in obj["parameters"].items()
|
|
109
|
+
)
|
|
110
|
+
if obj.get("parameters") is not None
|
|
111
|
+
else None,
|
|
112
|
+
"query": Query1.from_dict(obj["query"]) if obj.get("query") is not None else None,
|
|
113
|
+
"return_metadata": obj.get("return_metadata") if obj.get("return_metadata") is not None else True,
|
|
114
|
+
"return_explanation": obj.get("return_explanation") if obj.get("return_explanation") is not None else False,
|
|
115
|
+
"return_journey_explanations": obj.get("return_journey_explanations") if obj.get("return_journey_explanations") is not None else False,
|
|
116
|
+
"pagination_key": obj.get("pagination_key"),
|
|
117
|
+
"ignore_pagination": obj.get("ignore_pagination") if obj.get("ignore_pagination") is not None else False
|
|
118
|
+
})
|
|
119
|
+
return _obj
|
|
120
|
+
|
|
121
|
+
|