Cantumkan aplikasi
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Cantumkan aplikasi
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 code sample demonstrates how to list engines using the Vertex AI Agent Builder Python API.\u003c/p\u003e\n"],["\u003cp\u003eAuthentication for Vertex AI Agent Builder is required, and Application Default Credentials should be set up.\u003c/p\u003e\n"],["\u003cp\u003eThe code uses the \u003ccode\u003ediscoveryengine.EngineServiceClient\u003c/code\u003e to interact with the API, creating a client with custom options.\u003c/p\u003e\n"],["\u003cp\u003eThe sample function \u003ccode\u003elist_engines_sample\u003c/code\u003e retrieves and prints the list of engines based on the provided project ID and location.\u003c/p\u003e\n"],["\u003cp\u003eYou can find more code samples for other Google Cloud products through the Google Cloud sample browser.\u003c/p\u003e\n"]]],[],null,["# List apps\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 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\n\n def list_engines_sample(\n project_id: str,\n location: str,\n ) -\u003e discoveryengine.ListEnginesResponse:\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.EngineServiceClient(client_options=client_options)\n\n # The full resource name of the parent collection\n # e.g. projects/{project}/locations/{location}/collections/default_collection\n parent = client.collection_path(\n project=project_id,\n location=location,\n collection=\"default_collection\",\n )\n\n # Make the request\n response = client.list_engines(parent=parent)\n\n # Handle response\n print(response)\n\n return response\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)."]]