carbon_ruby_sdk 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +89 -0
- data/README.md +2325 -0
- data/Rakefile +10 -0
- data/carbon_ruby_sdk.gemspec +39 -0
- data/header.png +0 -0
- data/lib/carbon_ruby_sdk/api/auth_api.rb +177 -0
- data/lib/carbon_ruby_sdk/api/data_sources_api.rb +217 -0
- data/lib/carbon_ruby_sdk/api/embeddings_api.rb +565 -0
- data/lib/carbon_ruby_sdk/api/files_api.rb +1526 -0
- data/lib/carbon_ruby_sdk/api/health_api.rb +92 -0
- data/lib/carbon_ruby_sdk/api/integrations_api.rb +2201 -0
- data/lib/carbon_ruby_sdk/api/organizations_api.rb +92 -0
- data/lib/carbon_ruby_sdk/api/users_api.rb +209 -0
- data/lib/carbon_ruby_sdk/api/utilities_api.rb +710 -0
- data/lib/carbon_ruby_sdk/api/webhooks_api.rb +296 -0
- data/lib/carbon_ruby_sdk/api_client.rb +436 -0
- data/lib/carbon_ruby_sdk/api_client_custom.rb +14 -0
- data/lib/carbon_ruby_sdk/api_error.rb +53 -0
- data/lib/carbon_ruby_sdk/configuration.rb +354 -0
- data/lib/carbon_ruby_sdk/models/add_webhook_props.rb +220 -0
- data/lib/carbon_ruby_sdk/models/body_create_upload_file_uploadfile_post.rb +220 -0
- data/lib/carbon_ruby_sdk/models/chunk_properties.rb +248 -0
- data/lib/carbon_ruby_sdk/models/chunk_properties_nullable.rb +248 -0
- data/lib/carbon_ruby_sdk/models/chunks_and_embeddings.rb +246 -0
- data/lib/carbon_ruby_sdk/models/chunks_and_embeddings_upload_input.rb +247 -0
- data/lib/carbon_ruby_sdk/models/data_source_last_sync_actions.rb +38 -0
- data/lib/carbon_ruby_sdk/models/data_source_sync_statuses.rb +38 -0
- data/lib/carbon_ruby_sdk/models/data_source_type.rb +76 -0
- data/lib/carbon_ruby_sdk/models/data_source_type_nullable.rb +76 -0
- data/lib/carbon_ruby_sdk/models/delete_files_query_input.rb +252 -0
- data/lib/carbon_ruby_sdk/models/directory_item.rb +266 -0
- data/lib/carbon_ruby_sdk/models/document_response.rb +328 -0
- data/lib/carbon_ruby_sdk/models/document_response_list.rb +222 -0
- data/lib/carbon_ruby_sdk/models/embedding_and_chunk.rb +256 -0
- data/lib/carbon_ruby_sdk/models/embedding_generators.rb +43 -0
- data/lib/carbon_ruby_sdk/models/embedding_generators_nullable.rb +43 -0
- data/lib/carbon_ruby_sdk/models/embedding_properties.rb +226 -0
- data/lib/carbon_ruby_sdk/models/embeddings_and_chunks_filters.rb +232 -0
- data/lib/carbon_ruby_sdk/models/embeddings_and_chunks_order_by_columns.rb +37 -0
- data/lib/carbon_ruby_sdk/models/embeddings_and_chunks_query_input.rb +262 -0
- data/lib/carbon_ruby_sdk/models/embeddings_and_chunks_response.rb +236 -0
- data/lib/carbon_ruby_sdk/models/external_file_sync_statuses.rb +43 -0
- data/lib/carbon_ruby_sdk/models/external_source_item.rb +420 -0
- data/lib/carbon_ruby_sdk/models/fetch_urls_response.rb +236 -0
- data/lib/carbon_ruby_sdk/models/file_content_types.rb +36 -0
- data/lib/carbon_ruby_sdk/models/file_content_types_nullable.rb +36 -0
- data/lib/carbon_ruby_sdk/models/file_formats.rb +76 -0
- data/lib/carbon_ruby_sdk/models/file_formats_nullable.rb +76 -0
- data/lib/carbon_ruby_sdk/models/file_statistics.rb +256 -0
- data/lib/carbon_ruby_sdk/models/file_statistics_nullable.rb +256 -0
- data/lib/carbon_ruby_sdk/models/fresh_desk_connect_request.rb +316 -0
- data/lib/carbon_ruby_sdk/models/generic_success_response.rb +220 -0
- data/lib/carbon_ruby_sdk/models/get_embedding_documents_body.rb +416 -0
- data/lib/carbon_ruby_sdk/models/gitbook_connect_request.rb +234 -0
- data/lib/carbon_ruby_sdk/models/gitbook_sync_request.rb +336 -0
- data/lib/carbon_ruby_sdk/models/gmail_sync_input.rb +301 -0
- data/lib/carbon_ruby_sdk/models/http_validation_error.rb +217 -0
- data/lib/carbon_ruby_sdk/models/hybrid_search_tuning_params.rb +234 -0
- data/lib/carbon_ruby_sdk/models/hybrid_search_tuning_params_nullable.rb +235 -0
- data/lib/carbon_ruby_sdk/models/list_data_source_items_request.rb +239 -0
- data/lib/carbon_ruby_sdk/models/list_data_source_items_response.rb +236 -0
- data/lib/carbon_ruby_sdk/models/list_request.rb +230 -0
- data/lib/carbon_ruby_sdk/models/list_response.rb +222 -0
- data/lib/carbon_ruby_sdk/models/location_property_inner.rb +226 -0
- data/lib/carbon_ruby_sdk/models/modify_user_configuration_input.rb +234 -0
- data/lib/carbon_ruby_sdk/models/o_auth_url_request.rb +362 -0
- data/lib/carbon_ruby_sdk/models/order_dir.rb +36 -0
- data/lib/carbon_ruby_sdk/models/organization_response.rb +362 -0
- data/lib/carbon_ruby_sdk/models/organization_user_data_source_api.rb +380 -0
- data/lib/carbon_ruby_sdk/models/organization_user_data_source_filters.rb +238 -0
- data/lib/carbon_ruby_sdk/models/organization_user_data_source_order_by_columns.rb +36 -0
- data/lib/carbon_ruby_sdk/models/organization_user_data_source_query_input.rb +246 -0
- data/lib/carbon_ruby_sdk/models/organization_user_data_source_response.rb +236 -0
- data/lib/carbon_ruby_sdk/models/organization_user_file_tag_create.rb +236 -0
- data/lib/carbon_ruby_sdk/models/organization_user_file_tags_remove.rb +236 -0
- data/lib/carbon_ruby_sdk/models/organization_user_files_to_sync_filters.rb +330 -0
- data/lib/carbon_ruby_sdk/models/organization_user_files_to_sync_order_by_types.rb +39 -0
- data/lib/carbon_ruby_sdk/models/organization_user_files_to_sync_query_input.rb +276 -0
- data/lib/carbon_ruby_sdk/models/outlook_sync_input.rb +313 -0
- data/lib/carbon_ruby_sdk/models/pagination.rb +228 -0
- data/lib/carbon_ruby_sdk/models/presigned_url_response.rb +220 -0
- data/lib/carbon_ruby_sdk/models/rank_property.rb +226 -0
- data/lib/carbon_ruby_sdk/models/raw_text_input.rb +295 -0
- data/lib/carbon_ruby_sdk/models/raw_transcript_property_inner_value.rb +226 -0
- data/lib/carbon_ruby_sdk/models/resync_file_query_input.rb +240 -0
- data/lib/carbon_ruby_sdk/models/revoke_access_token_input.rb +220 -0
- data/lib/carbon_ruby_sdk/models/rss_feed_input.rb +301 -0
- data/lib/carbon_ruby_sdk/models/s3_auth_request.rb +234 -0
- data/lib/carbon_ruby_sdk/models/s3_file_sync_input.rb +313 -0
- data/lib/carbon_ruby_sdk/models/s3_get_file_input.rb +226 -0
- data/lib/carbon_ruby_sdk/models/single_chunks_and_embeddings_upload_input.rb +256 -0
- data/lib/carbon_ruby_sdk/models/sitemap_scrape_request.rb +361 -0
- data/lib/carbon_ruby_sdk/models/source_property.rb +226 -0
- data/lib/carbon_ruby_sdk/models/sync_directory_request.rb +220 -0
- data/lib/carbon_ruby_sdk/models/sync_files_request.rb +328 -0
- data/lib/carbon_ruby_sdk/models/tags.rb +232 -0
- data/lib/carbon_ruby_sdk/models/tags1.rb +230 -0
- data/lib/carbon_ruby_sdk/models/text_embedding_generators.rb +42 -0
- data/lib/carbon_ruby_sdk/models/token_response.rb +234 -0
- data/lib/carbon_ruby_sdk/models/upload_file_from_url_input.rb +326 -0
- data/lib/carbon_ruby_sdk/models/user_file.rb +524 -0
- data/lib/carbon_ruby_sdk/models/user_files_v2.rb +236 -0
- data/lib/carbon_ruby_sdk/models/user_request_content.rb +220 -0
- data/lib/carbon_ruby_sdk/models/user_response.rb +354 -0
- data/lib/carbon_ruby_sdk/models/validation_error.rb +250 -0
- data/lib/carbon_ruby_sdk/models/webhook.rb +290 -0
- data/lib/carbon_ruby_sdk/models/webhook_filters.rb +218 -0
- data/lib/carbon_ruby_sdk/models/webhook_no_key.rb +276 -0
- data/lib/carbon_ruby_sdk/models/webhook_order_by_columns.rb +36 -0
- data/lib/carbon_ruby_sdk/models/webhook_query_input.rb +246 -0
- data/lib/carbon_ruby_sdk/models/webhook_query_response.rb +236 -0
- data/lib/carbon_ruby_sdk/models/webscrape_request.rb +375 -0
- data/lib/carbon_ruby_sdk/models/white_labeling_response.rb +234 -0
- data/lib/carbon_ruby_sdk/models/youtube_transcript_response.rb +252 -0
- data/lib/carbon_ruby_sdk/version.rb +11 -0
- data/lib/carbon_ruby_sdk.rb +207 -0
- data/spec/api/auth_api_spec.rb +50 -0
- data/spec/api/data_sources_api_spec.rb +51 -0
- data/spec/api/embeddings_api_spec.rb +63 -0
- data/spec/api/files_api_spec.rb +178 -0
- data/spec/api/health_api_spec.rb +39 -0
- data/spec/api/integrations_api_spec.rb +226 -0
- data/spec/api/organizations_api_spec.rb +39 -0
- data/spec/api/users_api_spec.rb +51 -0
- data/spec/api/utilities_api_spec.rb +102 -0
- data/spec/api/webhooks_api_spec.rb +62 -0
- data/spec/api_client_spec.rb +191 -0
- data/spec/configuration_spec.rb +38 -0
- data/spec/getting_started_spec.rb +196 -0
- data/spec/models/add_webhook_props_spec.rb +28 -0
- data/spec/models/body_create_upload_file_uploadfile_post_spec.rb +28 -0
- data/spec/models/chunk_properties_nullable_spec.rb +40 -0
- data/spec/models/chunk_properties_spec.rb +40 -0
- data/spec/models/chunks_and_embeddings_spec.rb +40 -0
- data/spec/models/chunks_and_embeddings_upload_input_spec.rb +40 -0
- data/spec/models/data_source_last_sync_actions_spec.rb +22 -0
- data/spec/models/data_source_sync_statuses_spec.rb +22 -0
- data/spec/models/data_source_type_nullable_spec.rb +22 -0
- data/spec/models/data_source_type_spec.rb +22 -0
- data/spec/models/delete_files_query_input_spec.rb +46 -0
- data/spec/models/directory_item_spec.rb +46 -0
- data/spec/models/document_response_list_spec.rb +28 -0
- data/spec/models/document_response_spec.rb +88 -0
- data/spec/models/embedding_and_chunk_spec.rb +46 -0
- data/spec/models/embedding_generators_nullable_spec.rb +22 -0
- data/spec/models/embedding_generators_spec.rb +22 -0
- data/spec/models/embedding_properties_spec.rb +34 -0
- data/spec/models/embeddings_and_chunks_filters_spec.rb +34 -0
- data/spec/models/embeddings_and_chunks_order_by_columns_spec.rb +22 -0
- data/spec/models/embeddings_and_chunks_query_input_spec.rb +52 -0
- data/spec/models/embeddings_and_chunks_response_spec.rb +34 -0
- data/spec/models/external_file_sync_statuses_spec.rb +22 -0
- data/spec/models/external_source_item_spec.rb +124 -0
- data/spec/models/fetch_urls_response_spec.rb +34 -0
- data/spec/models/file_content_types_nullable_spec.rb +22 -0
- data/spec/models/file_content_types_spec.rb +22 -0
- data/spec/models/file_formats_nullable_spec.rb +22 -0
- data/spec/models/file_formats_spec.rb +22 -0
- data/spec/models/file_statistics_nullable_spec.rb +52 -0
- data/spec/models/file_statistics_spec.rb +52 -0
- data/spec/models/fresh_desk_connect_request_spec.rb +76 -0
- data/spec/models/generic_success_response_spec.rb +28 -0
- data/spec/models/get_embedding_documents_body_spec.rb +106 -0
- data/spec/models/gitbook_connect_request_spec.rb +34 -0
- data/spec/models/gitbook_sync_request_spec.rb +76 -0
- data/spec/models/gmail_sync_input_spec.rb +70 -0
- data/spec/models/http_validation_error_spec.rb +28 -0
- data/spec/models/hybrid_search_tuning_params_nullable_spec.rb +34 -0
- data/spec/models/hybrid_search_tuning_params_spec.rb +34 -0
- data/spec/models/list_data_source_items_request_spec.rb +40 -0
- data/spec/models/list_data_source_items_response_spec.rb +34 -0
- data/spec/models/list_request_spec.rb +34 -0
- data/spec/models/list_response_spec.rb +28 -0
- data/spec/models/location_property_inner_spec.rb +22 -0
- data/spec/models/modify_user_configuration_input_spec.rb +34 -0
- data/spec/models/o_auth_url_request_spec.rb +106 -0
- data/spec/models/order_dir_spec.rb +22 -0
- data/spec/models/organization_response_spec.rb +94 -0
- data/spec/models/organization_user_data_source_api_spec.rb +100 -0
- data/spec/models/organization_user_data_source_filters_spec.rb +40 -0
- data/spec/models/organization_user_data_source_order_by_columns_spec.rb +22 -0
- data/spec/models/organization_user_data_source_query_input_spec.rb +46 -0
- data/spec/models/organization_user_data_source_response_spec.rb +34 -0
- data/spec/models/organization_user_file_tag_create_spec.rb +34 -0
- data/spec/models/organization_user_file_tags_remove_spec.rb +34 -0
- data/spec/models/organization_user_files_to_sync_filters_spec.rb +88 -0
- data/spec/models/organization_user_files_to_sync_order_by_types_spec.rb +22 -0
- data/spec/models/organization_user_files_to_sync_query_input_spec.rb +64 -0
- data/spec/models/outlook_sync_input_spec.rb +76 -0
- data/spec/models/pagination_spec.rb +34 -0
- data/spec/models/presigned_url_response_spec.rb +28 -0
- data/spec/models/rank_property_spec.rb +22 -0
- data/spec/models/raw_text_input_spec.rb +70 -0
- data/spec/models/raw_transcript_property_inner_value_spec.rb +22 -0
- data/spec/models/resync_file_query_input_spec.rb +40 -0
- data/spec/models/revoke_access_token_input_spec.rb +28 -0
- data/spec/models/rss_feed_input_spec.rb +70 -0
- data/spec/models/s3_auth_request_spec.rb +34 -0
- data/spec/models/s3_file_sync_input_spec.rb +76 -0
- data/spec/models/s3_get_file_input_spec.rb +34 -0
- data/spec/models/single_chunks_and_embeddings_upload_input_spec.rb +46 -0
- data/spec/models/sitemap_scrape_request_spec.rb +100 -0
- data/spec/models/source_property_spec.rb +22 -0
- data/spec/models/sync_directory_request_spec.rb +28 -0
- data/spec/models/sync_files_request_spec.rb +82 -0
- data/spec/models/tags1_spec.rb +22 -0
- data/spec/models/tags_spec.rb +22 -0
- data/spec/models/text_embedding_generators_spec.rb +22 -0
- data/spec/models/token_response_spec.rb +34 -0
- data/spec/models/upload_file_from_url_input_spec.rb +88 -0
- data/spec/models/user_file_spec.rb +190 -0
- data/spec/models/user_files_v2_spec.rb +34 -0
- data/spec/models/user_request_content_spec.rb +28 -0
- data/spec/models/user_response_spec.rb +88 -0
- data/spec/models/validation_error_spec.rb +40 -0
- data/spec/models/webhook_filters_spec.rb +28 -0
- data/spec/models/webhook_no_key_spec.rb +52 -0
- data/spec/models/webhook_order_by_columns_spec.rb +22 -0
- data/spec/models/webhook_query_input_spec.rb +46 -0
- data/spec/models/webhook_query_response_spec.rb +34 -0
- data/spec/models/webhook_spec.rb +58 -0
- data/spec/models/webscrape_request_spec.rb +106 -0
- data/spec/models/white_labeling_response_spec.rb +34 -0
- data/spec/models/youtube_transcript_response_spec.rb +46 -0
- data/spec/spec_helper.rb +107 -0
- metadata +440 -0
@@ -0,0 +1,565 @@
|
|
1
|
+
=begin
|
2
|
+
#Carbon
|
3
|
+
|
4
|
+
#Connect external data to LLMs, no matter the source.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
7
|
+
=end
|
8
|
+
|
9
|
+
require 'cgi'
|
10
|
+
|
11
|
+
module Carbon
|
12
|
+
class EmbeddingsApi
|
13
|
+
attr_accessor :api_client
|
14
|
+
|
15
|
+
def initialize(api_client = ApiClient.default)
|
16
|
+
@api_client = api_client
|
17
|
+
end
|
18
|
+
|
19
|
+
# Embeddings
|
20
|
+
#
|
21
|
+
# For pre-filtering documents, using `tags_v2` is preferred to using `tags` (which is now deprecated). If both `tags_v2`
|
22
|
+
# and `tags` are specified, `tags` is ignored. `tags_v2` enables
|
23
|
+
# building complex filters through the use of "AND", "OR", and negation logic. Take the below input as an example:
|
24
|
+
# ```json
|
25
|
+
# {
|
26
|
+
# "OR": [
|
27
|
+
# {
|
28
|
+
# "key": "subject",
|
29
|
+
# "value": "holy-bible",
|
30
|
+
# "negate": false
|
31
|
+
# },
|
32
|
+
# {
|
33
|
+
# "key": "person-of-interest",
|
34
|
+
# "value": "jesus christ",
|
35
|
+
# "negate": false
|
36
|
+
# },
|
37
|
+
# {
|
38
|
+
# "key": "genre",
|
39
|
+
# "value": "religion",
|
40
|
+
# "negate": true
|
41
|
+
# }
|
42
|
+
# {
|
43
|
+
# "AND": [
|
44
|
+
# {
|
45
|
+
# "key": "subject",
|
46
|
+
# "value": "tao-te-ching",
|
47
|
+
# "negate": false
|
48
|
+
# },
|
49
|
+
# {
|
50
|
+
# "key": "author",
|
51
|
+
# "value": "lao-tzu",
|
52
|
+
# "negate": false
|
53
|
+
# }
|
54
|
+
# ]
|
55
|
+
# }
|
56
|
+
# ]
|
57
|
+
# }
|
58
|
+
# ```
|
59
|
+
# In this case, files will be filtered such that:
|
60
|
+
# 1. "subject" = "holy-bible" OR
|
61
|
+
# 2. "person-of-interest" = "jesus christ" OR
|
62
|
+
# 3. "genre" != "religion" OR
|
63
|
+
# 4. "subject" = "tao-te-ching" AND "author" = "lao-tzu"
|
64
|
+
#
|
65
|
+
# Note that the top level of the query must be either an "OR" or "AND" array. Currently, nesting is limited to 3.
|
66
|
+
# For tag blocks (those with "key", "value", and "negate" keys), the following typing rules apply:
|
67
|
+
# 1. "key" isn't optional and must be a `string`
|
68
|
+
# 2. "value" isn't optional and can be `any` or list[`any`]
|
69
|
+
# 3. "negate" is optional and must be `true` or `false`. If present and `true`, then the filter block is negated in
|
70
|
+
# the resulting query. It is `false` by default.
|
71
|
+
#
|
72
|
+
#
|
73
|
+
# When querying embeddings, you can optionally specify the `media_type` parameter in your request. By default (if
|
74
|
+
# not set), it is equal to "TEXT". This means that the query will be performed over files that have
|
75
|
+
# been parsed as text (for now, this covers all files except image files). If it is equal to "IMAGE",
|
76
|
+
# the query will be performed over image files (for now, `.jpg` and `.png` files). You can think of this
|
77
|
+
# field as an additional filter on top of any filters set in `file_ids` and
|
78
|
+
#
|
79
|
+
#
|
80
|
+
# When `hybrid_search` is set to true, a combination of keyword search and semantic search are used to rank
|
81
|
+
# and select candidate embeddings during information retrieval. By default, these search methods are weighted
|
82
|
+
# equally during the ranking process. To adjust the weight (or "importance") of each search method, you can use
|
83
|
+
# the `hybrid_search_tuning_parameters` property. The description for the different tuning parameters are:
|
84
|
+
# - `weight_a`: weight to assign to semantic search
|
85
|
+
# - `weight_b`: weight to assign to keyword search
|
86
|
+
#
|
87
|
+
# You must ensure that `sum(weight_a, weight_b,..., weight_n)` for all *n* weights is equal to 1. The equality
|
88
|
+
# has an error tolerance of 0.001 to account for possible floating point issues.
|
89
|
+
#
|
90
|
+
# In order to use hybrid search for a customer across a set of documents, two flags need to be enabled:
|
91
|
+
# 1. Use the `/modify_user_configuration` endpoint to to enable `sparse_vectors` for the customer. The payload
|
92
|
+
# body for this request is below:
|
93
|
+
# ```
|
94
|
+
# {
|
95
|
+
# "configuration_key_name": "sparse_vectors",
|
96
|
+
# "value": {
|
97
|
+
# "enabled": true
|
98
|
+
# }
|
99
|
+
# }
|
100
|
+
# ```
|
101
|
+
# 2. Make sure hybrid search is enabled for the documents across which you want to perform the search. For the
|
102
|
+
# `/uploadfile` endpoint, this can be done by setting the following query parameter: `generate_sparse_vectors=true`
|
103
|
+
#
|
104
|
+
#
|
105
|
+
# Carbon supports multiple models for use in generating embeddings for files. For images, we support Vertex AI's
|
106
|
+
# multimodal model; for text, we support OpenAI's `text-embedding-ada-002` and Cohere's embed-multilingual-v3.0.
|
107
|
+
# The model can be specified via the `embedding_model` parameter (in the POST body for `/embeddings`, and a query
|
108
|
+
# parameter in `/uploadfile`). If no model is supplied, the `text-embedding-ada-002` is used by default. When performing
|
109
|
+
# embedding queries, embeddings from files that used the specified model will be considered in the query.
|
110
|
+
# For example, if files A and B have embeddings generated with `OPENAI`, and files C and D have embeddings generated with
|
111
|
+
# `COHERE_MULTILINGUAL_V3`, then by default, queries will only consider files A and B. If `COHERE_MULTILINGUAL_V3` is
|
112
|
+
# specified as the `embedding_model` in `/embeddings`, then only files C and D will be considered. Make sure that
|
113
|
+
# the set of all files you want considered for a query have embeddings generated via the same model. For now, **do not**
|
114
|
+
# set `VERTEX_MULTIMODAL` as an `embedding_model`. This model is used automatically by Carbon when it detects an image file.
|
115
|
+
#
|
116
|
+
# @param query [String] Query for which to get related chunks and embeddings.
|
117
|
+
# @param k [Integer] Number of related chunks to return.
|
118
|
+
# @param tags [Hash<String, Tags1>] A set of tags to limit the search to. Deprecated and may be removed in the future.
|
119
|
+
# @param query_vector [Array<Float>] Optional query vector for which to get related chunks and embeddings. It must have been generated by the same model used to generate the embeddings across which the search is being conducted. Cannot provide both `query` and `query_vector`.
|
120
|
+
# @param file_ids [Array<Integer>] Optional list of file IDs to limit the search to
|
121
|
+
# @param parent_file_ids [Array<Integer>] Optional list of parent file IDs to limit the search to. A parent file describes a file to which another file belongs (e.g. a folder)
|
122
|
+
# @param tags_v2 [Object] A set of tags to limit the search to. Use this instead of `tags`, which is deprecated.
|
123
|
+
# @param include_tags [Boolean] Flag to control whether or not to include tags for each chunk in the response.
|
124
|
+
# @param include_vectors [Boolean] Flag to control whether or not to include embedding vectors in the response.
|
125
|
+
# @param include_raw_file [Boolean] Flag to control whether or not to include a signed URL to the raw file containing each chunk in the response.
|
126
|
+
# @param hybrid_search [Boolean] Flag to control whether or not to perform hybrid search.
|
127
|
+
# @param hybrid_search_tuning_parameters [HybridSearchTuningParamsNullable]
|
128
|
+
# @param media_type [FileContentTypesNullable] Used to filter the kind of files (e.g. `TEXT` or `IMAGE`) over which to perform the search. Also plays a role in determining what embedding model is used to embed the query. If `IMAGE` is chosen as the media type, then the embedding model used will be an embedding model that is not text-only, *regardless* of what value is passed for `embedding_model`.
|
129
|
+
# @param embedding_model [EmbeddingGeneratorsNullable]
|
130
|
+
# @param body [GetEmbeddingDocumentsBody]
|
131
|
+
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
132
|
+
def get_documents(query:, k:, tags: SENTINEL, query_vector: SENTINEL, file_ids: SENTINEL, parent_file_ids: SENTINEL, tags_v2: SENTINEL, include_tags: SENTINEL, include_vectors: SENTINEL, include_raw_file: SENTINEL, hybrid_search: SENTINEL, hybrid_search_tuning_parameters: SENTINEL, media_type: 'TEXT', embedding_model: 'OPENAI', extra: {})
|
133
|
+
_body = {}
|
134
|
+
_body[:tags] = tags if tags != SENTINEL
|
135
|
+
_body[:query] = query if query != SENTINEL
|
136
|
+
_body[:query_vector] = query_vector if query_vector != SENTINEL
|
137
|
+
_body[:k] = k if k != SENTINEL
|
138
|
+
_body[:file_ids] = file_ids if file_ids != SENTINEL
|
139
|
+
_body[:parent_file_ids] = parent_file_ids if parent_file_ids != SENTINEL
|
140
|
+
_body[:tags_v2] = tags_v2 if tags_v2 != SENTINEL
|
141
|
+
_body[:include_tags] = include_tags if include_tags != SENTINEL
|
142
|
+
_body[:include_vectors] = include_vectors if include_vectors != SENTINEL
|
143
|
+
_body[:include_raw_file] = include_raw_file if include_raw_file != SENTINEL
|
144
|
+
_body[:hybrid_search] = hybrid_search if hybrid_search != SENTINEL
|
145
|
+
_body[:hybrid_search_tuning_parameters] = hybrid_search_tuning_parameters if hybrid_search_tuning_parameters != SENTINEL
|
146
|
+
_body[:media_type] = media_type if media_type != SENTINEL
|
147
|
+
_body[:embedding_model] = embedding_model if embedding_model != SENTINEL
|
148
|
+
get_embedding_documents_body = _body
|
149
|
+
api_response = get_documents_with_http_info_impl(get_embedding_documents_body, extra)
|
150
|
+
api_response.data
|
151
|
+
end
|
152
|
+
|
153
|
+
# Embeddings
|
154
|
+
#
|
155
|
+
# For pre-filtering documents, using `tags_v2` is preferred to using `tags` (which is now deprecated). If both `tags_v2`
|
156
|
+
# and `tags` are specified, `tags` is ignored. `tags_v2` enables
|
157
|
+
# building complex filters through the use of "AND", "OR", and negation logic. Take the below input as an example:
|
158
|
+
# ```json
|
159
|
+
# {
|
160
|
+
# "OR": [
|
161
|
+
# {
|
162
|
+
# "key": "subject",
|
163
|
+
# "value": "holy-bible",
|
164
|
+
# "negate": false
|
165
|
+
# },
|
166
|
+
# {
|
167
|
+
# "key": "person-of-interest",
|
168
|
+
# "value": "jesus christ",
|
169
|
+
# "negate": false
|
170
|
+
# },
|
171
|
+
# {
|
172
|
+
# "key": "genre",
|
173
|
+
# "value": "religion",
|
174
|
+
# "negate": true
|
175
|
+
# }
|
176
|
+
# {
|
177
|
+
# "AND": [
|
178
|
+
# {
|
179
|
+
# "key": "subject",
|
180
|
+
# "value": "tao-te-ching",
|
181
|
+
# "negate": false
|
182
|
+
# },
|
183
|
+
# {
|
184
|
+
# "key": "author",
|
185
|
+
# "value": "lao-tzu",
|
186
|
+
# "negate": false
|
187
|
+
# }
|
188
|
+
# ]
|
189
|
+
# }
|
190
|
+
# ]
|
191
|
+
# }
|
192
|
+
# ```
|
193
|
+
# In this case, files will be filtered such that:
|
194
|
+
# 1. "subject" = "holy-bible" OR
|
195
|
+
# 2. "person-of-interest" = "jesus christ" OR
|
196
|
+
# 3. "genre" != "religion" OR
|
197
|
+
# 4. "subject" = "tao-te-ching" AND "author" = "lao-tzu"
|
198
|
+
#
|
199
|
+
# Note that the top level of the query must be either an "OR" or "AND" array. Currently, nesting is limited to 3.
|
200
|
+
# For tag blocks (those with "key", "value", and "negate" keys), the following typing rules apply:
|
201
|
+
# 1. "key" isn't optional and must be a `string`
|
202
|
+
# 2. "value" isn't optional and can be `any` or list[`any`]
|
203
|
+
# 3. "negate" is optional and must be `true` or `false`. If present and `true`, then the filter block is negated in
|
204
|
+
# the resulting query. It is `false` by default.
|
205
|
+
#
|
206
|
+
#
|
207
|
+
# When querying embeddings, you can optionally specify the `media_type` parameter in your request. By default (if
|
208
|
+
# not set), it is equal to "TEXT". This means that the query will be performed over files that have
|
209
|
+
# been parsed as text (for now, this covers all files except image files). If it is equal to "IMAGE",
|
210
|
+
# the query will be performed over image files (for now, `.jpg` and `.png` files). You can think of this
|
211
|
+
# field as an additional filter on top of any filters set in `file_ids` and
|
212
|
+
#
|
213
|
+
#
|
214
|
+
# When `hybrid_search` is set to true, a combination of keyword search and semantic search are used to rank
|
215
|
+
# and select candidate embeddings during information retrieval. By default, these search methods are weighted
|
216
|
+
# equally during the ranking process. To adjust the weight (or "importance") of each search method, you can use
|
217
|
+
# the `hybrid_search_tuning_parameters` property. The description for the different tuning parameters are:
|
218
|
+
# - `weight_a`: weight to assign to semantic search
|
219
|
+
# - `weight_b`: weight to assign to keyword search
|
220
|
+
#
|
221
|
+
# You must ensure that `sum(weight_a, weight_b,..., weight_n)` for all *n* weights is equal to 1. The equality
|
222
|
+
# has an error tolerance of 0.001 to account for possible floating point issues.
|
223
|
+
#
|
224
|
+
# In order to use hybrid search for a customer across a set of documents, two flags need to be enabled:
|
225
|
+
# 1. Use the `/modify_user_configuration` endpoint to to enable `sparse_vectors` for the customer. The payload
|
226
|
+
# body for this request is below:
|
227
|
+
# ```
|
228
|
+
# {
|
229
|
+
# "configuration_key_name": "sparse_vectors",
|
230
|
+
# "value": {
|
231
|
+
# "enabled": true
|
232
|
+
# }
|
233
|
+
# }
|
234
|
+
# ```
|
235
|
+
# 2. Make sure hybrid search is enabled for the documents across which you want to perform the search. For the
|
236
|
+
# `/uploadfile` endpoint, this can be done by setting the following query parameter: `generate_sparse_vectors=true`
|
237
|
+
#
|
238
|
+
#
|
239
|
+
# Carbon supports multiple models for use in generating embeddings for files. For images, we support Vertex AI's
|
240
|
+
# multimodal model; for text, we support OpenAI's `text-embedding-ada-002` and Cohere's embed-multilingual-v3.0.
|
241
|
+
# The model can be specified via the `embedding_model` parameter (in the POST body for `/embeddings`, and a query
|
242
|
+
# parameter in `/uploadfile`). If no model is supplied, the `text-embedding-ada-002` is used by default. When performing
|
243
|
+
# embedding queries, embeddings from files that used the specified model will be considered in the query.
|
244
|
+
# For example, if files A and B have embeddings generated with `OPENAI`, and files C and D have embeddings generated with
|
245
|
+
# `COHERE_MULTILINGUAL_V3`, then by default, queries will only consider files A and B. If `COHERE_MULTILINGUAL_V3` is
|
246
|
+
# specified as the `embedding_model` in `/embeddings`, then only files C and D will be considered. Make sure that
|
247
|
+
# the set of all files you want considered for a query have embeddings generated via the same model. For now, **do not**
|
248
|
+
# set `VERTEX_MULTIMODAL` as an `embedding_model`. This model is used automatically by Carbon when it detects an image file.
|
249
|
+
#
|
250
|
+
# @param query [String] Query for which to get related chunks and embeddings.
|
251
|
+
# @param k [Integer] Number of related chunks to return.
|
252
|
+
# @param tags [Hash<String, Tags1>] A set of tags to limit the search to. Deprecated and may be removed in the future.
|
253
|
+
# @param query_vector [Array<Float>] Optional query vector for which to get related chunks and embeddings. It must have been generated by the same model used to generate the embeddings across which the search is being conducted. Cannot provide both `query` and `query_vector`.
|
254
|
+
# @param file_ids [Array<Integer>] Optional list of file IDs to limit the search to
|
255
|
+
# @param parent_file_ids [Array<Integer>] Optional list of parent file IDs to limit the search to. A parent file describes a file to which another file belongs (e.g. a folder)
|
256
|
+
# @param tags_v2 [Object] A set of tags to limit the search to. Use this instead of `tags`, which is deprecated.
|
257
|
+
# @param include_tags [Boolean] Flag to control whether or not to include tags for each chunk in the response.
|
258
|
+
# @param include_vectors [Boolean] Flag to control whether or not to include embedding vectors in the response.
|
259
|
+
# @param include_raw_file [Boolean] Flag to control whether or not to include a signed URL to the raw file containing each chunk in the response.
|
260
|
+
# @param hybrid_search [Boolean] Flag to control whether or not to perform hybrid search.
|
261
|
+
# @param hybrid_search_tuning_parameters [HybridSearchTuningParamsNullable]
|
262
|
+
# @param media_type [FileContentTypesNullable] Used to filter the kind of files (e.g. `TEXT` or `IMAGE`) over which to perform the search. Also plays a role in determining what embedding model is used to embed the query. If `IMAGE` is chosen as the media type, then the embedding model used will be an embedding model that is not text-only, *regardless* of what value is passed for `embedding_model`.
|
263
|
+
# @param embedding_model [EmbeddingGeneratorsNullable]
|
264
|
+
# @param body [GetEmbeddingDocumentsBody]
|
265
|
+
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
266
|
+
def get_documents_with_http_info(query:, k:, tags: SENTINEL, query_vector: SENTINEL, file_ids: SENTINEL, parent_file_ids: SENTINEL, tags_v2: SENTINEL, include_tags: SENTINEL, include_vectors: SENTINEL, include_raw_file: SENTINEL, hybrid_search: SENTINEL, hybrid_search_tuning_parameters: SENTINEL, media_type: 'TEXT', embedding_model: 'OPENAI', extra: {})
|
267
|
+
_body = {}
|
268
|
+
_body[:tags] = tags if tags != SENTINEL
|
269
|
+
_body[:query] = query if query != SENTINEL
|
270
|
+
_body[:query_vector] = query_vector if query_vector != SENTINEL
|
271
|
+
_body[:k] = k if k != SENTINEL
|
272
|
+
_body[:file_ids] = file_ids if file_ids != SENTINEL
|
273
|
+
_body[:parent_file_ids] = parent_file_ids if parent_file_ids != SENTINEL
|
274
|
+
_body[:tags_v2] = tags_v2 if tags_v2 != SENTINEL
|
275
|
+
_body[:include_tags] = include_tags if include_tags != SENTINEL
|
276
|
+
_body[:include_vectors] = include_vectors if include_vectors != SENTINEL
|
277
|
+
_body[:include_raw_file] = include_raw_file if include_raw_file != SENTINEL
|
278
|
+
_body[:hybrid_search] = hybrid_search if hybrid_search != SENTINEL
|
279
|
+
_body[:hybrid_search_tuning_parameters] = hybrid_search_tuning_parameters if hybrid_search_tuning_parameters != SENTINEL
|
280
|
+
_body[:media_type] = media_type if media_type != SENTINEL
|
281
|
+
_body[:embedding_model] = embedding_model if embedding_model != SENTINEL
|
282
|
+
get_embedding_documents_body = _body
|
283
|
+
get_documents_with_http_info_impl(get_embedding_documents_body, extra)
|
284
|
+
end
|
285
|
+
|
286
|
+
# Embeddings
|
287
|
+
# For pre-filtering documents, using `tags_v2` is preferred to using `tags` (which is now deprecated). If both `tags_v2` and `tags` are specified, `tags` is ignored. `tags_v2` enables building complex filters through the use of \"AND\", \"OR\", and negation logic. Take the below input as an example: ```json { \"OR\": [ { \"key\": \"subject\", \"value\": \"holy-bible\", \"negate\": false }, { \"key\": \"person-of-interest\", \"value\": \"jesus christ\", \"negate\": false }, { \"key\": \"genre\", \"value\": \"religion\", \"negate\": true } { \"AND\": [ { \"key\": \"subject\", \"value\": \"tao-te-ching\", \"negate\": false }, { \"key\": \"author\", \"value\": \"lao-tzu\", \"negate\": false } ] } ] } ``` In this case, files will be filtered such that: 1. \"subject\" = \"holy-bible\" OR 2. \"person-of-interest\" = \"jesus christ\" OR 3. \"genre\" != \"religion\" OR 4. \"subject\" = \"tao-te-ching\" AND \"author\" = \"lao-tzu\" Note that the top level of the query must be either an \"OR\" or \"AND\" array. Currently, nesting is limited to 3. For tag blocks (those with \"key\", \"value\", and \"negate\" keys), the following typing rules apply: 1. \"key\" isn't optional and must be a `string` 2. \"value\" isn't optional and can be `any` or list[`any`] 3. \"negate\" is optional and must be `true` or `false`. If present and `true`, then the filter block is negated in the resulting query. It is `false` by default. When querying embeddings, you can optionally specify the `media_type` parameter in your request. By default (if not set), it is equal to \"TEXT\". This means that the query will be performed over files that have been parsed as text (for now, this covers all files except image files). If it is equal to \"IMAGE\", the query will be performed over image files (for now, `.jpg` and `.png` files). You can think of this field as an additional filter on top of any filters set in `file_ids` and When `hybrid_search` is set to true, a combination of keyword search and semantic search are used to rank and select candidate embeddings during information retrieval. By default, these search methods are weighted equally during the ranking process. To adjust the weight (or \"importance\") of each search method, you can use the `hybrid_search_tuning_parameters` property. The description for the different tuning parameters are: - `weight_a`: weight to assign to semantic search - `weight_b`: weight to assign to keyword search You must ensure that `sum(weight_a, weight_b,..., weight_n)` for all *n* weights is equal to 1. The equality has an error tolerance of 0.001 to account for possible floating point issues. In order to use hybrid search for a customer across a set of documents, two flags need to be enabled: 1. Use the `/modify_user_configuration` endpoint to to enable `sparse_vectors` for the customer. The payload body for this request is below: ``` { \"configuration_key_name\": \"sparse_vectors\", \"value\": { \"enabled\": true } } ``` 2. Make sure hybrid search is enabled for the documents across which you want to perform the search. For the `/uploadfile` endpoint, this can be done by setting the following query parameter: `generate_sparse_vectors=true` Carbon supports multiple models for use in generating embeddings for files. For images, we support Vertex AI's multimodal model; for text, we support OpenAI's `text-embedding-ada-002` and Cohere's embed-multilingual-v3.0. The model can be specified via the `embedding_model` parameter (in the POST body for `/embeddings`, and a query parameter in `/uploadfile`). If no model is supplied, the `text-embedding-ada-002` is used by default. When performing embedding queries, embeddings from files that used the specified model will be considered in the query. For example, if files A and B have embeddings generated with `OPENAI`, and files C and D have embeddings generated with `COHERE_MULTILINGUAL_V3`, then by default, queries will only consider files A and B. If `COHERE_MULTILINGUAL_V3` is specified as the `embedding_model` in `/embeddings`, then only files C and D will be considered. Make sure that the set of all files you want considered for a query have embeddings generated via the same model. For now, **do not** set `VERTEX_MULTIMODAL` as an `embedding_model`. This model is used automatically by Carbon when it detects an image file.
|
288
|
+
# @param get_embedding_documents_body [GetEmbeddingDocumentsBody]
|
289
|
+
# @param [Hash] opts the optional parameters
|
290
|
+
# @return [DocumentResponseList]
|
291
|
+
private def get_documents_impl(get_embedding_documents_body, opts = {})
|
292
|
+
data, _status_code, _headers = get_documents_with_http_info(get_embedding_documents_body, opts)
|
293
|
+
data
|
294
|
+
end
|
295
|
+
|
296
|
+
# Embeddings
|
297
|
+
# For pre-filtering documents, using `tags_v2` is preferred to using `tags` (which is now deprecated). If both `tags_v2` and `tags` are specified, `tags` is ignored. `tags_v2` enables building complex filters through the use of \"AND\", \"OR\", and negation logic. Take the below input as an example: ```json { \"OR\": [ { \"key\": \"subject\", \"value\": \"holy-bible\", \"negate\": false }, { \"key\": \"person-of-interest\", \"value\": \"jesus christ\", \"negate\": false }, { \"key\": \"genre\", \"value\": \"religion\", \"negate\": true } { \"AND\": [ { \"key\": \"subject\", \"value\": \"tao-te-ching\", \"negate\": false }, { \"key\": \"author\", \"value\": \"lao-tzu\", \"negate\": false } ] } ] } ``` In this case, files will be filtered such that: 1. \"subject\" = \"holy-bible\" OR 2. \"person-of-interest\" = \"jesus christ\" OR 3. \"genre\" != \"religion\" OR 4. \"subject\" = \"tao-te-ching\" AND \"author\" = \"lao-tzu\" Note that the top level of the query must be either an \"OR\" or \"AND\" array. Currently, nesting is limited to 3. For tag blocks (those with \"key\", \"value\", and \"negate\" keys), the following typing rules apply: 1. \"key\" isn't optional and must be a `string` 2. \"value\" isn't optional and can be `any` or list[`any`] 3. \"negate\" is optional and must be `true` or `false`. If present and `true`, then the filter block is negated in the resulting query. It is `false` by default. When querying embeddings, you can optionally specify the `media_type` parameter in your request. By default (if not set), it is equal to \"TEXT\". This means that the query will be performed over files that have been parsed as text (for now, this covers all files except image files). If it is equal to \"IMAGE\", the query will be performed over image files (for now, `.jpg` and `.png` files). You can think of this field as an additional filter on top of any filters set in `file_ids` and When `hybrid_search` is set to true, a combination of keyword search and semantic search are used to rank and select candidate embeddings during information retrieval. By default, these search methods are weighted equally during the ranking process. To adjust the weight (or \"importance\") of each search method, you can use the `hybrid_search_tuning_parameters` property. The description for the different tuning parameters are: - `weight_a`: weight to assign to semantic search - `weight_b`: weight to assign to keyword search You must ensure that `sum(weight_a, weight_b,..., weight_n)` for all *n* weights is equal to 1. The equality has an error tolerance of 0.001 to account for possible floating point issues. In order to use hybrid search for a customer across a set of documents, two flags need to be enabled: 1. Use the `/modify_user_configuration` endpoint to to enable `sparse_vectors` for the customer. The payload body for this request is below: ``` { \"configuration_key_name\": \"sparse_vectors\", \"value\": { \"enabled\": true } } ``` 2. Make sure hybrid search is enabled for the documents across which you want to perform the search. For the `/uploadfile` endpoint, this can be done by setting the following query parameter: `generate_sparse_vectors=true` Carbon supports multiple models for use in generating embeddings for files. For images, we support Vertex AI's multimodal model; for text, we support OpenAI's `text-embedding-ada-002` and Cohere's embed-multilingual-v3.0. The model can be specified via the `embedding_model` parameter (in the POST body for `/embeddings`, and a query parameter in `/uploadfile`). If no model is supplied, the `text-embedding-ada-002` is used by default. When performing embedding queries, embeddings from files that used the specified model will be considered in the query. For example, if files A and B have embeddings generated with `OPENAI`, and files C and D have embeddings generated with `COHERE_MULTILINGUAL_V3`, then by default, queries will only consider files A and B. If `COHERE_MULTILINGUAL_V3` is specified as the `embedding_model` in `/embeddings`, then only files C and D will be considered. Make sure that the set of all files you want considered for a query have embeddings generated via the same model. For now, **do not** set `VERTEX_MULTIMODAL` as an `embedding_model`. This model is used automatically by Carbon when it detects an image file.
|
298
|
+
# @param get_embedding_documents_body [GetEmbeddingDocumentsBody]
|
299
|
+
# @param [Hash] opts the optional parameters
|
300
|
+
# @return [APIResponse] data is DocumentResponseList, status code, headers and response
|
301
|
+
private def get_documents_with_http_info_impl(get_embedding_documents_body, opts = {})
|
302
|
+
if @api_client.config.debugging
|
303
|
+
@api_client.config.logger.debug 'Calling API: EmbeddingsApi.get_documents ...'
|
304
|
+
end
|
305
|
+
# verify the required parameter 'get_embedding_documents_body' is set
|
306
|
+
if @api_client.config.client_side_validation && get_embedding_documents_body.nil?
|
307
|
+
fail ArgumentError, "Missing the required parameter 'get_embedding_documents_body' when calling EmbeddingsApi.get_documents"
|
308
|
+
end
|
309
|
+
# resource path
|
310
|
+
local_var_path = '/embeddings'
|
311
|
+
|
312
|
+
# query parameters
|
313
|
+
query_params = opts[:query_params] || {}
|
314
|
+
|
315
|
+
# header parameters
|
316
|
+
header_params = opts[:header_params] || {}
|
317
|
+
# HTTP header 'Accept' (if needed)
|
318
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
319
|
+
# HTTP header 'Content-Type'
|
320
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
321
|
+
if !content_type.nil?
|
322
|
+
header_params['Content-Type'] = content_type
|
323
|
+
end
|
324
|
+
|
325
|
+
# form parameters
|
326
|
+
form_params = opts[:form_params] || {}
|
327
|
+
|
328
|
+
# http body (model)
|
329
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(get_embedding_documents_body)
|
330
|
+
|
331
|
+
# return_type
|
332
|
+
return_type = opts[:debug_return_type] || 'DocumentResponseList'
|
333
|
+
|
334
|
+
# auth_names
|
335
|
+
auth_names = opts[:debug_auth_names] || ['accessToken', 'apiKey', 'customerId']
|
336
|
+
|
337
|
+
new_options = opts.merge(
|
338
|
+
:operation => :"EmbeddingsApi.get_documents",
|
339
|
+
:header_params => header_params,
|
340
|
+
:query_params => query_params,
|
341
|
+
:form_params => form_params,
|
342
|
+
:body => post_body,
|
343
|
+
:auth_names => auth_names,
|
344
|
+
:return_type => return_type
|
345
|
+
)
|
346
|
+
|
347
|
+
data, status_code, headers, response = @api_client.call_api(:POST, local_var_path, new_options)
|
348
|
+
if @api_client.config.debugging
|
349
|
+
@api_client.config.logger.debug "API called: EmbeddingsApi#get_documents\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
350
|
+
end
|
351
|
+
APIResponse::new(data, status_code, headers, response)
|
352
|
+
end
|
353
|
+
|
354
|
+
|
355
|
+
# Retrieve Embeddings And Content
|
356
|
+
#
|
357
|
+
# @param filters [EmbeddingsAndChunksFilters]
|
358
|
+
# @param pagination [Pagination]
|
359
|
+
# @param order_by [EmbeddingsAndChunksOrderByColumns]
|
360
|
+
# @param order_dir [OrderDir]
|
361
|
+
# @param include_vectors [Boolean]
|
362
|
+
# @param body [EmbeddingsAndChunksQueryInput]
|
363
|
+
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
364
|
+
def get_embeddings_and_chunks(filters:, pagination: SENTINEL, order_by: 'updated_at', order_dir: 'asc', include_vectors: false, extra: {})
|
365
|
+
_body = {}
|
366
|
+
_body[:pagination] = pagination if pagination != SENTINEL
|
367
|
+
_body[:order_by] = order_by if order_by != SENTINEL
|
368
|
+
_body[:order_dir] = order_dir if order_dir != SENTINEL
|
369
|
+
_body[:filters] = filters if filters != SENTINEL
|
370
|
+
_body[:include_vectors] = include_vectors if include_vectors != SENTINEL
|
371
|
+
embeddings_and_chunks_query_input = _body
|
372
|
+
api_response = get_embeddings_and_chunks_with_http_info_impl(embeddings_and_chunks_query_input, extra)
|
373
|
+
api_response.data
|
374
|
+
end
|
375
|
+
|
376
|
+
# Retrieve Embeddings And Content
|
377
|
+
#
|
378
|
+
# @param filters [EmbeddingsAndChunksFilters]
|
379
|
+
# @param pagination [Pagination]
|
380
|
+
# @param order_by [EmbeddingsAndChunksOrderByColumns]
|
381
|
+
# @param order_dir [OrderDir]
|
382
|
+
# @param include_vectors [Boolean]
|
383
|
+
# @param body [EmbeddingsAndChunksQueryInput]
|
384
|
+
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
385
|
+
def get_embeddings_and_chunks_with_http_info(filters:, pagination: SENTINEL, order_by: 'updated_at', order_dir: 'asc', include_vectors: false, extra: {})
|
386
|
+
_body = {}
|
387
|
+
_body[:pagination] = pagination if pagination != SENTINEL
|
388
|
+
_body[:order_by] = order_by if order_by != SENTINEL
|
389
|
+
_body[:order_dir] = order_dir if order_dir != SENTINEL
|
390
|
+
_body[:filters] = filters if filters != SENTINEL
|
391
|
+
_body[:include_vectors] = include_vectors if include_vectors != SENTINEL
|
392
|
+
embeddings_and_chunks_query_input = _body
|
393
|
+
get_embeddings_and_chunks_with_http_info_impl(embeddings_and_chunks_query_input, extra)
|
394
|
+
end
|
395
|
+
|
396
|
+
# Retrieve Embeddings And Content
|
397
|
+
# @param embeddings_and_chunks_query_input [EmbeddingsAndChunksQueryInput]
|
398
|
+
# @param [Hash] opts the optional parameters
|
399
|
+
# @return [EmbeddingsAndChunksResponse]
|
400
|
+
private def get_embeddings_and_chunks_impl(embeddings_and_chunks_query_input, opts = {})
|
401
|
+
data, _status_code, _headers = get_embeddings_and_chunks_with_http_info(embeddings_and_chunks_query_input, opts)
|
402
|
+
data
|
403
|
+
end
|
404
|
+
|
405
|
+
# Retrieve Embeddings And Content
|
406
|
+
# @param embeddings_and_chunks_query_input [EmbeddingsAndChunksQueryInput]
|
407
|
+
# @param [Hash] opts the optional parameters
|
408
|
+
# @return [APIResponse] data is EmbeddingsAndChunksResponse, status code, headers and response
|
409
|
+
private def get_embeddings_and_chunks_with_http_info_impl(embeddings_and_chunks_query_input, opts = {})
|
410
|
+
if @api_client.config.debugging
|
411
|
+
@api_client.config.logger.debug 'Calling API: EmbeddingsApi.get_embeddings_and_chunks ...'
|
412
|
+
end
|
413
|
+
# verify the required parameter 'embeddings_and_chunks_query_input' is set
|
414
|
+
if @api_client.config.client_side_validation && embeddings_and_chunks_query_input.nil?
|
415
|
+
fail ArgumentError, "Missing the required parameter 'embeddings_and_chunks_query_input' when calling EmbeddingsApi.get_embeddings_and_chunks"
|
416
|
+
end
|
417
|
+
# resource path
|
418
|
+
local_var_path = '/text_chunks'
|
419
|
+
|
420
|
+
# query parameters
|
421
|
+
query_params = opts[:query_params] || {}
|
422
|
+
|
423
|
+
# header parameters
|
424
|
+
header_params = opts[:header_params] || {}
|
425
|
+
# HTTP header 'Accept' (if needed)
|
426
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
427
|
+
# HTTP header 'Content-Type'
|
428
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
429
|
+
if !content_type.nil?
|
430
|
+
header_params['Content-Type'] = content_type
|
431
|
+
end
|
432
|
+
|
433
|
+
# form parameters
|
434
|
+
form_params = opts[:form_params] || {}
|
435
|
+
|
436
|
+
# http body (model)
|
437
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(embeddings_and_chunks_query_input)
|
438
|
+
|
439
|
+
# return_type
|
440
|
+
return_type = opts[:debug_return_type] || 'EmbeddingsAndChunksResponse'
|
441
|
+
|
442
|
+
# auth_names
|
443
|
+
auth_names = opts[:debug_auth_names] || ['accessToken', 'apiKey', 'customerId']
|
444
|
+
|
445
|
+
new_options = opts.merge(
|
446
|
+
:operation => :"EmbeddingsApi.get_embeddings_and_chunks",
|
447
|
+
:header_params => header_params,
|
448
|
+
:query_params => query_params,
|
449
|
+
:form_params => form_params,
|
450
|
+
:body => post_body,
|
451
|
+
:auth_names => auth_names,
|
452
|
+
:return_type => return_type
|
453
|
+
)
|
454
|
+
|
455
|
+
data, status_code, headers, response = @api_client.call_api(:POST, local_var_path, new_options)
|
456
|
+
if @api_client.config.debugging
|
457
|
+
@api_client.config.logger.debug "API called: EmbeddingsApi#get_embeddings_and_chunks\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
458
|
+
end
|
459
|
+
APIResponse::new(data, status_code, headers, response)
|
460
|
+
end
|
461
|
+
|
462
|
+
|
463
|
+
# Upload Chunks And Embeddings
|
464
|
+
#
|
465
|
+
# @param embedding_model [EmbeddingGenerators]
|
466
|
+
# @param chunks_and_embeddings [Array<SingleChunksAndEmbeddingsUploadInput>]
|
467
|
+
# @param overwrite_existing [Boolean]
|
468
|
+
# @param body [ChunksAndEmbeddingsUploadInput]
|
469
|
+
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
470
|
+
def upload_chunks_and_embeddings(embedding_model:, chunks_and_embeddings:, overwrite_existing: false, extra: {})
|
471
|
+
_body = {}
|
472
|
+
_body[:embedding_model] = embedding_model if embedding_model != SENTINEL
|
473
|
+
_body[:chunks_and_embeddings] = chunks_and_embeddings if chunks_and_embeddings != SENTINEL
|
474
|
+
_body[:overwrite_existing] = overwrite_existing if overwrite_existing != SENTINEL
|
475
|
+
chunks_and_embeddings_upload_input = _body
|
476
|
+
api_response = upload_chunks_and_embeddings_with_http_info_impl(chunks_and_embeddings_upload_input, extra)
|
477
|
+
api_response.data
|
478
|
+
end
|
479
|
+
|
480
|
+
# Upload Chunks And Embeddings
|
481
|
+
#
|
482
|
+
# @param embedding_model [EmbeddingGenerators]
|
483
|
+
# @param chunks_and_embeddings [Array<SingleChunksAndEmbeddingsUploadInput>]
|
484
|
+
# @param overwrite_existing [Boolean]
|
485
|
+
# @param body [ChunksAndEmbeddingsUploadInput]
|
486
|
+
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
487
|
+
def upload_chunks_and_embeddings_with_http_info(embedding_model:, chunks_and_embeddings:, overwrite_existing: false, extra: {})
|
488
|
+
_body = {}
|
489
|
+
_body[:embedding_model] = embedding_model if embedding_model != SENTINEL
|
490
|
+
_body[:chunks_and_embeddings] = chunks_and_embeddings if chunks_and_embeddings != SENTINEL
|
491
|
+
_body[:overwrite_existing] = overwrite_existing if overwrite_existing != SENTINEL
|
492
|
+
chunks_and_embeddings_upload_input = _body
|
493
|
+
upload_chunks_and_embeddings_with_http_info_impl(chunks_and_embeddings_upload_input, extra)
|
494
|
+
end
|
495
|
+
|
496
|
+
# Upload Chunks And Embeddings
|
497
|
+
# @param chunks_and_embeddings_upload_input [ChunksAndEmbeddingsUploadInput]
|
498
|
+
# @param [Hash] opts the optional parameters
|
499
|
+
# @return [GenericSuccessResponse]
|
500
|
+
private def upload_chunks_and_embeddings_impl(chunks_and_embeddings_upload_input, opts = {})
|
501
|
+
data, _status_code, _headers = upload_chunks_and_embeddings_with_http_info(chunks_and_embeddings_upload_input, opts)
|
502
|
+
data
|
503
|
+
end
|
504
|
+
|
505
|
+
# Upload Chunks And Embeddings
|
506
|
+
# @param chunks_and_embeddings_upload_input [ChunksAndEmbeddingsUploadInput]
|
507
|
+
# @param [Hash] opts the optional parameters
|
508
|
+
# @return [APIResponse] data is GenericSuccessResponse, status code, headers and response
|
509
|
+
private def upload_chunks_and_embeddings_with_http_info_impl(chunks_and_embeddings_upload_input, opts = {})
|
510
|
+
if @api_client.config.debugging
|
511
|
+
@api_client.config.logger.debug 'Calling API: EmbeddingsApi.upload_chunks_and_embeddings ...'
|
512
|
+
end
|
513
|
+
# verify the required parameter 'chunks_and_embeddings_upload_input' is set
|
514
|
+
if @api_client.config.client_side_validation && chunks_and_embeddings_upload_input.nil?
|
515
|
+
fail ArgumentError, "Missing the required parameter 'chunks_and_embeddings_upload_input' when calling EmbeddingsApi.upload_chunks_and_embeddings"
|
516
|
+
end
|
517
|
+
# resource path
|
518
|
+
local_var_path = '/upload_chunks_and_embeddings'
|
519
|
+
|
520
|
+
# query parameters
|
521
|
+
query_params = opts[:query_params] || {}
|
522
|
+
|
523
|
+
# header parameters
|
524
|
+
header_params = opts[:header_params] || {}
|
525
|
+
# HTTP header 'Accept' (if needed)
|
526
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
527
|
+
# HTTP header 'Content-Type'
|
528
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
529
|
+
if !content_type.nil?
|
530
|
+
header_params['Content-Type'] = content_type
|
531
|
+
end
|
532
|
+
|
533
|
+
# form parameters
|
534
|
+
form_params = opts[:form_params] || {}
|
535
|
+
|
536
|
+
# http body (model)
|
537
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(chunks_and_embeddings_upload_input)
|
538
|
+
|
539
|
+
# return_type
|
540
|
+
return_type = opts[:debug_return_type] || 'GenericSuccessResponse'
|
541
|
+
|
542
|
+
# auth_names
|
543
|
+
auth_names = opts[:debug_auth_names] || ['accessToken', 'apiKey', 'customerId']
|
544
|
+
|
545
|
+
new_options = opts.merge(
|
546
|
+
:operation => :"EmbeddingsApi.upload_chunks_and_embeddings",
|
547
|
+
:header_params => header_params,
|
548
|
+
:query_params => query_params,
|
549
|
+
:form_params => form_params,
|
550
|
+
:body => post_body,
|
551
|
+
:auth_names => auth_names,
|
552
|
+
:return_type => return_type
|
553
|
+
)
|
554
|
+
|
555
|
+
data, status_code, headers, response = @api_client.call_api(:POST, local_var_path, new_options)
|
556
|
+
if @api_client.config.debugging
|
557
|
+
@api_client.config.logger.debug "API called: EmbeddingsApi#upload_chunks_and_embeddings\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
558
|
+
end
|
559
|
+
APIResponse::new(data, status_code, headers, response)
|
560
|
+
end
|
561
|
+
end
|
562
|
+
|
563
|
+
# top-level client access to avoid having the user to insantiate their own API instances
|
564
|
+
Embeddings = EmbeddingsApi::new
|
565
|
+
end
|