Tried to use Python data qna library to create a question or to get autocomplete suggested queries, but so far no luck. It keeps saying method not found. (grpc) does anyone have working sample code( Java, Python or NodeJS)?
It breaks trying to call the suggest query function:
suggestions_response = suggest_client.suggest_queries(SuggestQueriesRequest(parent=parent, scopes=[scope]))
import os
from google.api_core.client_options import ClientOptions
from google.cloud.dataqna import AutoSuggestionServiceClient, Question, QuestionServiceClient, SuggestQueriesRequest
# Please Note: This is not part of the Data QnA generated library.
# You'll need to install it separately using instructions here:
# https://cloud.google.com/bigquery/docs/reference/libraries#client-libraries-install-python
from google.cloud import bigquery
# Fill-in these four variables and everything else should flow through.
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = '/path/to/credentials/json/file'
project = "<your-project>"
location = "<your-location>" # "us" or "eu"
scope = f"//bigquery.googleapis.com/projects/{project}/datasets/<your-dataset>/tables/<your-table>"
# Initialize the clients
client_options = ClientOptions(api_endpoint=f"{location}-dataqna.googleapis.com:443")
suggest_client = AutoSuggestionServiceClient(client_options=client_options)
questions_client = QuestionServiceClient(client_options=client_options)
bq_client = bigquery.Client()
parent = questions_client.common_location_path(project, location)
# Please Note: The suggestions API is designed to be used as a way to get
# auto-complete/auto-suggest suggestions for completing a question as the user is
# typing. Or to show a list of potential questions to help user know what kind of questions they can ask.
# You can skip this step and go to create_question call if you are not implementing auto-complete.
suggestions_response = suggest_client.suggest_queries(SuggestQueriesRequest(parent=parent, scopes=[scope]))
suggested_query = suggestions_response.suggestions[0].suggestion_info.annotated_suggestion.text_formatted
question from:
https://stackoverflow.com/questions/65868110/suggetedqueries-not-working-in-google-data-qna-python-client-library 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…