google-cloud-discovery_engine-v1 2.3.1 → 2.5.0

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +4 -4
  3. data/README.md +4 -4
  4. data/lib/google/cloud/discovery_engine/v1/assistant_service/client.rb +509 -0
  5. data/lib/google/cloud/discovery_engine/v1/assistant_service/credentials.rb +47 -0
  6. data/lib/google/cloud/discovery_engine/v1/assistant_service/paths.rb +169 -0
  7. data/lib/google/cloud/discovery_engine/v1/assistant_service/rest/client.rb +478 -0
  8. data/lib/google/cloud/discovery_engine/v1/assistant_service/rest/service_stub.rb +137 -0
  9. data/lib/google/cloud/discovery_engine/v1/assistant_service/rest.rb +52 -0
  10. data/lib/google/cloud/discovery_engine/v1/assistant_service.rb +55 -0
  11. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/client.rb +16 -4
  12. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/rest/client.rb +16 -4
  13. data/lib/google/cloud/discovery_engine/v1/rest.rb +4 -2
  14. data/lib/google/cloud/discovery_engine/v1/search_service/client.rb +204 -30
  15. data/lib/google/cloud/discovery_engine/v1/search_service/rest/client.rb +204 -30
  16. data/lib/google/cloud/discovery_engine/v1/session_service/client.rb +920 -0
  17. data/lib/google/cloud/discovery_engine/v1/session_service/credentials.rb +47 -0
  18. data/lib/google/cloud/discovery_engine/v1/session_service/paths.rb +330 -0
  19. data/lib/google/cloud/discovery_engine/v1/session_service/rest/client.rb +859 -0
  20. data/lib/google/cloud/discovery_engine/v1/session_service/rest/service_stub.rb +462 -0
  21. data/lib/google/cloud/discovery_engine/v1/session_service/rest.rb +52 -0
  22. data/lib/google/cloud/discovery_engine/v1/session_service.rb +55 -0
  23. data/lib/google/cloud/discovery_engine/v1/user_event_service/client.rb +2 -2
  24. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/client.rb +2 -2
  25. data/lib/google/cloud/discovery_engine/v1/version.rb +1 -1
  26. data/lib/google/cloud/discovery_engine/v1.rb +5 -3
  27. data/lib/google/cloud/discoveryengine/v1/assist_answer_pb.rb +59 -0
  28. data/lib/google/cloud/discoveryengine/v1/assistant_pb.rb +45 -0
  29. data/lib/google/cloud/discoveryengine/v1/assistant_service_pb.rb +62 -0
  30. data/lib/google/cloud/discoveryengine/v1/assistant_service_services_pb.rb +45 -0
  31. data/lib/google/cloud/discoveryengine/v1/search_service_pb.rb +4 -1
  32. data/lib/google/cloud/discoveryengine/v1/session_pb.rb +1 -1
  33. data/lib/google/cloud/discoveryengine/v1/session_service_pb.rb +49 -0
  34. data/lib/google/cloud/discoveryengine/v1/session_service_services_pb.rb +64 -0
  35. data/proto_docs/google/cloud/discoveryengine/v1/assist_answer.rb +278 -0
  36. data/proto_docs/google/cloud/discoveryengine/v1/assistant.rb +39 -0
  37. data/proto_docs/google/cloud/discoveryengine/v1/assistant_service.rb +207 -0
  38. data/proto_docs/google/cloud/discoveryengine/v1/conversational_search_service.rb +15 -3
  39. data/proto_docs/google/cloud/discoveryengine/v1/search_service.rb +164 -14
  40. data/proto_docs/google/cloud/discoveryengine/v1/session.rb +20 -4
  41. data/proto_docs/google/cloud/discoveryengine/v1/user_event_service.rb +2 -2
  42. metadata +26 -3
@@ -210,7 +210,7 @@ module Google
210
210
  # @param options [::Gapic::CallOptions, ::Hash]
211
211
  # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
212
212
  #
213
- # @overload search(serving_config: nil, branch: nil, query: nil, image_query: nil, page_size: nil, page_token: nil, offset: nil, one_box_page_size: nil, data_store_specs: nil, filter: nil, canonical_filter: nil, order_by: nil, user_info: nil, language_code: nil, facet_specs: nil, boost_spec: nil, params: nil, query_expansion_spec: nil, spell_correction_spec: nil, user_pseudo_id: nil, content_search_spec: nil, safe_search: nil, user_labels: nil, search_as_you_type_spec: nil, display_spec: nil, session: nil, session_spec: nil, relevance_threshold: nil, relevance_score_spec: nil)
213
+ # @overload search(serving_config: nil, branch: nil, query: nil, image_query: nil, page_size: nil, page_token: nil, offset: nil, one_box_page_size: nil, data_store_specs: nil, filter: nil, canonical_filter: nil, order_by: nil, user_info: nil, language_code: nil, facet_specs: nil, boost_spec: nil, params: nil, query_expansion_spec: nil, spell_correction_spec: nil, user_pseudo_id: nil, content_search_spec: nil, safe_search: nil, user_labels: nil, search_as_you_type_spec: nil, display_spec: nil, session: nil, session_spec: nil, relevance_threshold: nil, relevance_score_spec: nil, ranking_expression: nil, ranking_expression_backend: nil)
214
214
  # Pass arguments to `search` via keyword arguments. Note that at
215
215
  # least one keyword argument is required. To specify no parameters, or to keep all
216
216
  # the default parameter values, pass an empty Hash as a request object (see above).
@@ -408,22 +408,16 @@ module Google
408
408
  # between /search API calls and /answer API calls.
409
409
  #
410
410
  # Example #1 (multi-turn /search API calls):
411
- # 1. Call /search API with the auto-session mode (see below).
412
- # 2. Call /search API with the session ID generated in the first call.
413
- # Here, the previous search query gets considered in query
414
- # standing. I.e., if the first query is "How did Alphabet do in 2022?"
415
- # and the current query is "How about 2023?", the current query will
416
- # be interpreted as "How did Alphabet do in 2023?".
411
+ # Call /search API with the session ID generated in the first call.
412
+ # Here, the previous search query gets considered in query
413
+ # standing. I.e., if the first query is "How did Alphabet do in 2022?"
414
+ # and the current query is "How about 2023?", the current query will
415
+ # be interpreted as "How did Alphabet do in 2023?".
417
416
  #
418
417
  # Example #2 (coordination between /search API calls and /answer API calls):
419
- # 1. Call /search API with the auto-session mode (see below).
420
- # 2. Call /answer API with the session ID generated in the first call.
421
- # Here, the answer generation happens in the context of the search
422
- # results from the first search call.
423
- #
424
- # Auto-session mode: when `projects/.../sessions/-` is used, a new session
425
- # gets automatically created. Otherwise, users can use the create-session API
426
- # to create a session manually.
418
+ # Call /answer API with the session ID generated in the first call.
419
+ # Here, the answer generation happens in the context of the search
420
+ # results from the first search call.
427
421
  #
428
422
  # Multi-turn Search feature is currently at private GA stage. Please use
429
423
  # v1alpha or v1beta version instead before we launch this feature to public
@@ -442,6 +436,99 @@ module Google
442
436
  # This feature is not supported for healthcare search.
443
437
  # @param relevance_score_spec [::Google::Cloud::DiscoveryEngine::V1::SearchRequest::RelevanceScoreSpec, ::Hash]
444
438
  # Optional. The specification for returning the relevance score.
439
+ # @param ranking_expression [::String]
440
+ # The ranking expression controls the customized ranking on retrieval
441
+ # documents. This overrides
442
+ # {::Google::Cloud::DiscoveryEngine::V1::ServingConfig#ranking_expression ServingConfig.ranking_expression}.
443
+ # The syntax and supported features depend on the
444
+ # `ranking_expression_backend` value. If `ranking_expression_backend` is not
445
+ # provided, it defaults to `RANK_BY_EMBEDDING`.
446
+ #
447
+ # If
448
+ # {::Google::Cloud::DiscoveryEngine::V1::SearchRequest#ranking_expression_backend ranking_expression_backend}
449
+ # is not provided or set to `RANK_BY_EMBEDDING`, it should be a single
450
+ # function or multiple functions that are joined by "+".
451
+ #
452
+ # * ranking_expression = function, { " + ", function };
453
+ #
454
+ # Supported functions:
455
+ #
456
+ # * double * relevance_score
457
+ # * double * dotProduct(embedding_field_path)
458
+ #
459
+ # Function variables:
460
+ #
461
+ # * `relevance_score`: pre-defined keywords, used for measure relevance
462
+ # between query and document.
463
+ # * `embedding_field_path`: the document embedding field
464
+ # used with query embedding vector.
465
+ # * `dotProduct`: embedding function between `embedding_field_path` and
466
+ # query embedding vector.
467
+ #
468
+ # Example ranking expression:
469
+ #
470
+ # If document has an embedding field doc_embedding, the ranking expression
471
+ # could be `0.5 * relevance_score + 0.3 * dotProduct(doc_embedding)`.
472
+ #
473
+ # If
474
+ # {::Google::Cloud::DiscoveryEngine::V1::SearchRequest#ranking_expression_backend ranking_expression_backend}
475
+ # is set to `RANK_BY_FORMULA`, the following expression types (and
476
+ # combinations of those chained using + or
477
+ # * operators) are supported:
478
+ #
479
+ # * `double`
480
+ # * `signal`
481
+ # * `log(signal)`
482
+ # * `exp(signal)`
483
+ # * `rr(signal, double > 0)` -- reciprocal rank transformation with second
484
+ # argument being a denominator constant.
485
+ # * `is_nan(signal)` -- returns 0 if signal is NaN, 1 otherwise.
486
+ # * `fill_nan(signal1, signal2 | double)` -- if signal1 is NaN, returns
487
+ # signal2 | double, else returns signal1.
488
+ #
489
+ # Here are a few examples of ranking formulas that use the supported
490
+ # ranking expression types:
491
+ #
492
+ # - `0.2 * semantic_similarity_score + 0.8 * log(keyword_similarity_score)`
493
+ # -- mostly rank by the logarithm of `keyword_similarity_score` with slight
494
+ # `semantic_smilarity_score` adjustment.
495
+ # - `0.2 * exp(fill_nan(semantic_similarity_score, 0)) + 0.3 *
496
+ # is_nan(keyword_similarity_score)` -- rank by the exponent of
497
+ # `semantic_similarity_score` filling the value with 0 if it's NaN, also
498
+ # add constant 0.3 adjustment to the final score if
499
+ # `semantic_similarity_score` is NaN.
500
+ # - `0.2 * rr(semantic_similarity_score, 16) + 0.8 *
501
+ # rr(keyword_similarity_score, 16)` -- mostly rank by the reciprocal rank
502
+ # of `keyword_similarity_score` with slight adjustment of reciprocal rank
503
+ # of `semantic_smilarity_score`.
504
+ #
505
+ # The following signals are supported:
506
+ #
507
+ # * `semantic_similarity_score`: semantic similarity adjustment that is
508
+ # calculated using the embeddings generated by a proprietary Google model.
509
+ # This score determines how semantically similar a search query is to a
510
+ # document.
511
+ # * `keyword_similarity_score`: keyword match adjustment uses the Best
512
+ # Match 25 (BM25) ranking function. This score is calculated using a
513
+ # probabilistic model to estimate the probability that a document is
514
+ # relevant to a given query.
515
+ # * `relevance_score`: semantic relevance adjustment that uses a
516
+ # proprietary Google model to determine the meaning and intent behind a
517
+ # user's query in context with the content in the documents.
518
+ # * `pctr_rank`: predicted conversion rate adjustment as a rank use
519
+ # predicted Click-through rate (pCTR) to gauge the relevance and
520
+ # attractiveness of a search result from a user's perspective. A higher
521
+ # pCTR suggests that the result is more likely to satisfy the user's query
522
+ # and intent, making it a valuable signal for ranking.
523
+ # * `freshness_rank`: freshness adjustment as a rank
524
+ # * `document_age`: The time in hours elapsed since the document was last
525
+ # updated, a floating-point number (e.g., 0.25 means 15 minutes).
526
+ # * `topicality_rank`: topicality adjustment as a rank. Uses proprietary
527
+ # Google model to determine the keyword-based overlap between the query and
528
+ # the document.
529
+ # * `base_rank`: the default rank of the result
530
+ # @param ranking_expression_backend [::Google::Cloud::DiscoveryEngine::V1::SearchRequest::RankingExpressionBackend]
531
+ # The backend to use for the ranking expression evaluation.
445
532
  # @yield [result, operation] Access the result along with the TransportOperation object
446
533
  # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::DiscoveryEngine::V1::SearchResponse::SearchResult>]
447
534
  # @yieldparam operation [::Gapic::Rest::TransportOperation]
@@ -531,7 +618,7 @@ module Google
531
618
  # @param options [::Gapic::CallOptions, ::Hash]
532
619
  # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
533
620
  #
534
- # @overload search_lite(serving_config: nil, branch: nil, query: nil, image_query: nil, page_size: nil, page_token: nil, offset: nil, one_box_page_size: nil, data_store_specs: nil, filter: nil, canonical_filter: nil, order_by: nil, user_info: nil, language_code: nil, facet_specs: nil, boost_spec: nil, params: nil, query_expansion_spec: nil, spell_correction_spec: nil, user_pseudo_id: nil, content_search_spec: nil, safe_search: nil, user_labels: nil, search_as_you_type_spec: nil, display_spec: nil, session: nil, session_spec: nil, relevance_threshold: nil, relevance_score_spec: nil)
621
+ # @overload search_lite(serving_config: nil, branch: nil, query: nil, image_query: nil, page_size: nil, page_token: nil, offset: nil, one_box_page_size: nil, data_store_specs: nil, filter: nil, canonical_filter: nil, order_by: nil, user_info: nil, language_code: nil, facet_specs: nil, boost_spec: nil, params: nil, query_expansion_spec: nil, spell_correction_spec: nil, user_pseudo_id: nil, content_search_spec: nil, safe_search: nil, user_labels: nil, search_as_you_type_spec: nil, display_spec: nil, session: nil, session_spec: nil, relevance_threshold: nil, relevance_score_spec: nil, ranking_expression: nil, ranking_expression_backend: nil)
535
622
  # Pass arguments to `search_lite` via keyword arguments. Note that at
536
623
  # least one keyword argument is required. To specify no parameters, or to keep all
537
624
  # the default parameter values, pass an empty Hash as a request object (see above).
@@ -729,22 +816,16 @@ module Google
729
816
  # between /search API calls and /answer API calls.
730
817
  #
731
818
  # Example #1 (multi-turn /search API calls):
732
- # 1. Call /search API with the auto-session mode (see below).
733
- # 2. Call /search API with the session ID generated in the first call.
734
- # Here, the previous search query gets considered in query
735
- # standing. I.e., if the first query is "How did Alphabet do in 2022?"
736
- # and the current query is "How about 2023?", the current query will
737
- # be interpreted as "How did Alphabet do in 2023?".
819
+ # Call /search API with the session ID generated in the first call.
820
+ # Here, the previous search query gets considered in query
821
+ # standing. I.e., if the first query is "How did Alphabet do in 2022?"
822
+ # and the current query is "How about 2023?", the current query will
823
+ # be interpreted as "How did Alphabet do in 2023?".
738
824
  #
739
825
  # Example #2 (coordination between /search API calls and /answer API calls):
740
- # 1. Call /search API with the auto-session mode (see below).
741
- # 2. Call /answer API with the session ID generated in the first call.
742
- # Here, the answer generation happens in the context of the search
743
- # results from the first search call.
744
- #
745
- # Auto-session mode: when `projects/.../sessions/-` is used, a new session
746
- # gets automatically created. Otherwise, users can use the create-session API
747
- # to create a session manually.
826
+ # Call /answer API with the session ID generated in the first call.
827
+ # Here, the answer generation happens in the context of the search
828
+ # results from the first search call.
748
829
  #
749
830
  # Multi-turn Search feature is currently at private GA stage. Please use
750
831
  # v1alpha or v1beta version instead before we launch this feature to public
@@ -763,6 +844,99 @@ module Google
763
844
  # This feature is not supported for healthcare search.
764
845
  # @param relevance_score_spec [::Google::Cloud::DiscoveryEngine::V1::SearchRequest::RelevanceScoreSpec, ::Hash]
765
846
  # Optional. The specification for returning the relevance score.
847
+ # @param ranking_expression [::String]
848
+ # The ranking expression controls the customized ranking on retrieval
849
+ # documents. This overrides
850
+ # {::Google::Cloud::DiscoveryEngine::V1::ServingConfig#ranking_expression ServingConfig.ranking_expression}.
851
+ # The syntax and supported features depend on the
852
+ # `ranking_expression_backend` value. If `ranking_expression_backend` is not
853
+ # provided, it defaults to `RANK_BY_EMBEDDING`.
854
+ #
855
+ # If
856
+ # {::Google::Cloud::DiscoveryEngine::V1::SearchRequest#ranking_expression_backend ranking_expression_backend}
857
+ # is not provided or set to `RANK_BY_EMBEDDING`, it should be a single
858
+ # function or multiple functions that are joined by "+".
859
+ #
860
+ # * ranking_expression = function, { " + ", function };
861
+ #
862
+ # Supported functions:
863
+ #
864
+ # * double * relevance_score
865
+ # * double * dotProduct(embedding_field_path)
866
+ #
867
+ # Function variables:
868
+ #
869
+ # * `relevance_score`: pre-defined keywords, used for measure relevance
870
+ # between query and document.
871
+ # * `embedding_field_path`: the document embedding field
872
+ # used with query embedding vector.
873
+ # * `dotProduct`: embedding function between `embedding_field_path` and
874
+ # query embedding vector.
875
+ #
876
+ # Example ranking expression:
877
+ #
878
+ # If document has an embedding field doc_embedding, the ranking expression
879
+ # could be `0.5 * relevance_score + 0.3 * dotProduct(doc_embedding)`.
880
+ #
881
+ # If
882
+ # {::Google::Cloud::DiscoveryEngine::V1::SearchRequest#ranking_expression_backend ranking_expression_backend}
883
+ # is set to `RANK_BY_FORMULA`, the following expression types (and
884
+ # combinations of those chained using + or
885
+ # * operators) are supported:
886
+ #
887
+ # * `double`
888
+ # * `signal`
889
+ # * `log(signal)`
890
+ # * `exp(signal)`
891
+ # * `rr(signal, double > 0)` -- reciprocal rank transformation with second
892
+ # argument being a denominator constant.
893
+ # * `is_nan(signal)` -- returns 0 if signal is NaN, 1 otherwise.
894
+ # * `fill_nan(signal1, signal2 | double)` -- if signal1 is NaN, returns
895
+ # signal2 | double, else returns signal1.
896
+ #
897
+ # Here are a few examples of ranking formulas that use the supported
898
+ # ranking expression types:
899
+ #
900
+ # - `0.2 * semantic_similarity_score + 0.8 * log(keyword_similarity_score)`
901
+ # -- mostly rank by the logarithm of `keyword_similarity_score` with slight
902
+ # `semantic_smilarity_score` adjustment.
903
+ # - `0.2 * exp(fill_nan(semantic_similarity_score, 0)) + 0.3 *
904
+ # is_nan(keyword_similarity_score)` -- rank by the exponent of
905
+ # `semantic_similarity_score` filling the value with 0 if it's NaN, also
906
+ # add constant 0.3 adjustment to the final score if
907
+ # `semantic_similarity_score` is NaN.
908
+ # - `0.2 * rr(semantic_similarity_score, 16) + 0.8 *
909
+ # rr(keyword_similarity_score, 16)` -- mostly rank by the reciprocal rank
910
+ # of `keyword_similarity_score` with slight adjustment of reciprocal rank
911
+ # of `semantic_smilarity_score`.
912
+ #
913
+ # The following signals are supported:
914
+ #
915
+ # * `semantic_similarity_score`: semantic similarity adjustment that is
916
+ # calculated using the embeddings generated by a proprietary Google model.
917
+ # This score determines how semantically similar a search query is to a
918
+ # document.
919
+ # * `keyword_similarity_score`: keyword match adjustment uses the Best
920
+ # Match 25 (BM25) ranking function. This score is calculated using a
921
+ # probabilistic model to estimate the probability that a document is
922
+ # relevant to a given query.
923
+ # * `relevance_score`: semantic relevance adjustment that uses a
924
+ # proprietary Google model to determine the meaning and intent behind a
925
+ # user's query in context with the content in the documents.
926
+ # * `pctr_rank`: predicted conversion rate adjustment as a rank use
927
+ # predicted Click-through rate (pCTR) to gauge the relevance and
928
+ # attractiveness of a search result from a user's perspective. A higher
929
+ # pCTR suggests that the result is more likely to satisfy the user's query
930
+ # and intent, making it a valuable signal for ranking.
931
+ # * `freshness_rank`: freshness adjustment as a rank
932
+ # * `document_age`: The time in hours elapsed since the document was last
933
+ # updated, a floating-point number (e.g., 0.25 means 15 minutes).
934
+ # * `topicality_rank`: topicality adjustment as a rank. Uses proprietary
935
+ # Google model to determine the keyword-based overlap between the query and
936
+ # the document.
937
+ # * `base_rank`: the default rank of the result
938
+ # @param ranking_expression_backend [::Google::Cloud::DiscoveryEngine::V1::SearchRequest::RankingExpressionBackend]
939
+ # The backend to use for the ranking expression evaluation.
766
940
  # @yield [result, operation] Access the result along with the TransportOperation object
767
941
  # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::DiscoveryEngine::V1::SearchResponse::SearchResult>]
768
942
  # @yieldparam operation [::Gapic::Rest::TransportOperation]