Module: Google::Cloud::DataQnA
- Defined in:
- lib/google/cloud/dataqna.rb,
lib/google/cloud/dataqna/version.rb
Constant Summary collapse
- VERSION =
"0.5.1"
Class Method Summary collapse
-
.auto_suggestion_service(version: :v1alpha, &block) ⇒ ::Object
Create a new client object for AutoSuggestionService.
-
.configure {|::Google::Cloud.configure.dataqna| ... } ⇒ ::Google::Cloud::Config
Configure the google-cloud-dataqna library.
-
.question_service(version: :v1alpha, &block) ⇒ ::Object
Create a new client object for QuestionService.
Class Method Details
.auto_suggestion_service(version: :v1alpha, &block) ⇒ ::Object
Create a new client object for AutoSuggestionService.
By default, this returns an instance of
Google::Cloud::DataQnA::V1alpha::AutoSuggestionService::Client
for a gRPC client for version V1alpha of the API.
However, you can specify a different API version by passing it in the
version
parameter. If the AutoSuggestionService service is
supported by that API version, and the corresponding gem is available, the
appropriate versioned client will be returned.
About AutoSuggestionService
This stateless API provides automatic suggestions for natural language queries for the data sources in the provided project and location.
The service provides a resourceless operation suggestQueries
that can be
called to get a list of suggestions for a given incomplete query and scope
(or list of scopes) under which the query is to be interpreted.
There are two types of suggestions, ENTITY for single entity suggestions and TEMPLATE for full sentences. By default, both types are returned.
Example Request:
GetSuggestions({
parent: "locations/us/projects/my-project"
scopes:
"//bigquery.googleapis.com/projects/my-project/datasets/my-dataset/tables/my-table"
query: "top it"
})
The service will retrieve information based on the given scope(s) and give suggestions based on that (e.g. "top item" for "top it" if "item" is a known dimension for the provided scope).
suggestions {
suggestion_info {
annotated_suggestion {
text_formatted: "top item by sum of usd_revenue_net"
markups {
type: DIMENSION
start_char_index: 4
length: 4
}
markups {
type: METRIC
start_char_index: 19
length: 15
}
}
query_matches {
start_char_index: 0
length: 6
}
}
suggestion_type: TEMPLATE
ranking_score: 0.9
}
suggestions {
suggestion_info {
annotated_suggestion {
text_formatted: "item"
markups {
type: DIMENSION
start_char_index: 4
length: 2
}
}
query_matches {
start_char_index: 0
length: 6
}
}
suggestion_type: ENTITY
ranking_score: 0.8
}
132 133 134 135 136 137 138 139 140 141 |
# File 'lib/google/cloud/dataqna.rb', line 132 def self.auto_suggestion_service version: :v1alpha, &block require "google/cloud/dataqna/#{version.to_s.downcase}" package_name = Google::Cloud::DataQnA .constants .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } .first service_module = Google::Cloud::DataQnA.const_get(package_name).const_get(:AutoSuggestionService) service_module.const_get(:Client).new(&block) end |
.configure {|::Google::Cloud.configure.dataqna| ... } ⇒ ::Google::Cloud::Config
Configure the google-cloud-dataqna library.
The following configuration parameters are supported:
credentials
(type:String, Hash, Google::Auth::Credentials
) - The path to the keyfile as a String, the contents of the keyfile as a Hash, or a Google::Auth::Credentials object.lib_name
(type:String
) - The library name as recorded in instrumentation and logging.lib_version
(type:String
) - The library version as recorded in instrumentation and logging.interceptors
(type:Array<GRPC::ClientInterceptor>
) - An array of interceptors that are run before calls are executed.timeout
(type:Numeric
) - Default timeout in seconds.metadata
(type:Hash{Symbol=>String}
) - Additional headers to be sent with the call.retry_policy
(type:Hash
) - The retry policy. The value is a hash with the following keys::initial_delay
(type:Numeric
) - The initial delay in seconds.:max_delay
(type:Numeric
) - The max delay in seconds.:multiplier
(type:Numeric
) - The incremental backoff multiplier.:retry_codes
(type:Array<String>
) - The error codes that should trigger a retry.
215 216 217 218 219 |
# File 'lib/google/cloud/dataqna.rb', line 215 def self.configure yield ::Google::Cloud.configure.dataqna if block_given? ::Google::Cloud.configure.dataqna end |
.question_service(version: :v1alpha, &block) ⇒ ::Object
Create a new client object for QuestionService.
By default, this returns an instance of
Google::Cloud::DataQnA::V1alpha::QuestionService::Client
for a gRPC client for version V1alpha of the API.
However, you can specify a different API version by passing it in the
version
parameter. If the QuestionService service is
supported by that API version, and the corresponding gem is available, the
appropriate versioned client will be returned.
About QuestionService
Service to interpret natural language queries.
The service allows to create Question
resources that are interpreted and
are filled with one or more interpretations if the question could be
interpreted. Once a Question
resource is created and has at least one
interpretation, an interpretation can be chosen for execution, which
triggers a query to the backend (for BigQuery, it will create a job).
Upon successful execution of that interpretation, backend specific
information will be returned so that the client can retrieve the results
from the backend.
The Question
resources are named projects/*/locations/*/questions/*
.
The Question
resource has a singletion sub-resource UserFeedback
named
projects/*/locations/*/questions/*/userFeedback
, which allows access to
user feedback.
176 177 178 179 180 181 182 183 184 185 |
# File 'lib/google/cloud/dataqna.rb', line 176 def self.question_service version: :v1alpha, &block require "google/cloud/dataqna/#{version.to_s.downcase}" package_name = Google::Cloud::DataQnA .constants .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } .first service_module = Google::Cloud::DataQnA.const_get(package_name).const_get(:QuestionService) service_module.const_get(:Client).new(&block) end |