Menambahkan situs ke penyimpanan data
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Menambahkan situs ke penyimpanan data
Mempelajari lebih lanjut
Untuk dokumentasi mendetail yang menyertakan contoh kode ini, lihat artikel berikut:
Contoh kode
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis content demonstrates how to add a website to a data store using the Vertex AI Agent Builder Python API.\u003c/p\u003e\n"],["\u003cp\u003eThe process involves creating a \u003ccode\u003eSiteSearchEngineServiceClient\u003c/code\u003e and defining a \u003ccode\u003eTargetSite\u003c/code\u003e with the website's URI pattern.\u003c/p\u003e\n"],["\u003cp\u003eAuthentication to Vertex AI Agent Builder requires setting up Application Default Credentials, and a reference is provided.\u003c/p\u003e\n"],["\u003cp\u003eThe sample code shows how to make a request to create a target site, handle the response, and get operation metadata.\u003c/p\u003e\n"],["\u003cp\u003eUsers can find more code samples for Google Cloud products using the Google Cloud sample browser link provided.\u003c/p\u003e\n"]]],[],null,["# Add a website to a data store\n\nExplore further\n---------------\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Create a search data store](/generative-ai-app-builder/docs/create-data-store-es)\n\nCode sample\n-----------\n\n### Python\n\n\nFor more information, see the\n[AI Applications Python API\nreference documentation](/python/docs/reference/discoveryengine/latest).\n\n\nTo authenticate to AI Applications, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n # from google.api_core.client_options import ClientOptions\n #\n # from google.cloud import discoveryengine_v1 as discoveryengine\n #\n # # TODO(developer): Uncomment these variables before running the sample.\n # # project_id = \"YOUR_PROJECT_ID\"\n # # location = \"YOUR_LOCATION\" # Values: \"global\"\n # # data_store_id = \"YOUR_DATA_STORE_ID\"\n # # NOTE: Do not include http or https protocol in the URI pattern\n # # uri_pattern = \"cloud.google.com/generative-ai-app-builder/docs/*\"\n #\n # # For more information, refer to:\n # # https://cloud.google.com/generative-ai-app-builder/docs/locations#specify_a_multi-region_for_your_data_store\n # client_options = (\n # ClientOptions(api_endpoint=f\"{location}-discoveryengine.googleapis.com\")\n # if location != \"global\"\n # else None\n # )\n #\n # # Create a client\n # client = discoveryengine.SiteSearchEngineServiceClient(\n # client_options=client_options\n # )\n #\n # # The full resource name of the data store\n # # e.g. projects/{project}/locations/{location}/dataStores/{data_store_id}\n # site_search_engine = client.site_search_engine_path(\n # project=project_id, location=location, data_store=data_store_id\n # )\n #\n # # Target Site to index\n # target_site = discoveryengine.TargetSite(\n # provided_uri_pattern=uri_pattern,\n # # Options: INCLUDE, EXCLUDE\n # type_=discoveryengine.TargetSite.Type.INCLUDE,\n # exact_match=False,\n # )\n #\n # # Make the request\n # operation = client.create_target_site(\n # parent=site_search_engine,\n # target_site=target_site,\n # )\n #\n # print(f\"Waiting for operation to complete: {operation.operation.name}\")\n # response = operation.result()\n #\n # # After the operation is complete,\n # # get information from operation metadata\n # metadata = discoveryengine.CreateTargetSiteMetadata(operation.metadata)\n #\n # # Handle the response\n # print(response)\n # print(metadata)\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=genappbuilder)."]]