Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(discoveryengine): Update Search Sample to use Engine/App ID #11288

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion discoveryengine/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
google-cloud-discoveryengine==0.11.8
google-cloud-discoveryengine==0.11.10
google-api-core==2.17.1
18 changes: 6 additions & 12 deletions discoveryengine/search_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@

# TODO(developer): Uncomment these variables before running the sample.
# project_id = "YOUR_PROJECT_ID"
# location = "YOUR_LOCATION" # Values: "global", "us", "eu"
# data_store_id = "YOUR_DATA_STORE_ID"
# location = "YOUR_LOCATION" # Values: "global", "us", "eu"
# engine_id = "YOUR_APP_ID"
# search_query = "YOUR_SEARCH_QUERY"


def search_sample(
project_id: str,
location: str,
data_store_id: str,
engine_id: str,
search_query: str,
) -> List[discoveryengine.SearchResponse]:
# For more information, refer to:
Expand All @@ -43,14 +43,8 @@ def search_sample(
# Create a client
client = discoveryengine.SearchServiceClient(client_options=client_options)

# The full resource name of the search engine serving config
# e.g. projects/{project_id}/locations/{location}/dataStores/{data_store_id}/servingConfigs/{serving_config_id}
serving_config = client.serving_config_path(
project=project_id,
location=location,
data_store=data_store_id,
serving_config="default_config",
)
# The full resource name of the search app serving config
serving_config = f"projects/{project_id}/locations/{location}/collections/default_collection/engines/{engine_id}/servingConfigs/default_config"

# Optional: Configuration options for search
# Refer to the `ContentSearchSpec` reference for all supported fields:
Expand All @@ -72,7 +66,7 @@ def search_sample(
preamble="YOUR_CUSTOM_PROMPT"
),
model_spec=discoveryengine.SearchRequest.ContentSearchSpec.SummarySpec.ModelSpec(
version="stable", # Options: stable, preview
version="stable",
),
),
)
Expand Down
8 changes: 4 additions & 4 deletions discoveryengine/search_sample_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@

def test_search():
location = "global"
data_store_id = "test-search-engine_1689960780551"
engine_id = "test-search-engine_1689960780551"
response = search_sample.search_sample(
project_id=project_id,
location=location,
data_store_id=data_store_id,
engine_id=engine_id,
search_query=search_query,
)

Expand All @@ -40,11 +40,11 @@ def test_search():

def test_search_eu_endpoint():
location = "eu"
data_store_id = "alphabet-earnings-reports-eu"
engine_id = "test-search-engine-eu_1695154596291"
response = search_sample.search_sample(
project_id=project_id,
location=location,
data_store_id=data_store_id,
engine_id=engine_id,
search_query=search_query,
)

Expand Down
Loading