Spaces:
Sleeping
Sleeping
| from google.cloud import aiplatform_v1 | |
| from google.oauth2 import service_account | |
| def list_models(project_id, location, credentials_path): | |
| credentials = service_account.Credentials.from_service_account_file(credentials_path) | |
| client = aiplatform_v1.ModelServiceClient(credentials=credentials) | |
| parent = f"projects/{project_id}/locations/{location}" | |
| response = client.list_models(parent=parent) | |
| models = list(response) | |
| if not models: | |
| print("No models found.") | |
| else: | |
| for model in models: | |
| print(f"Model display name: {model.display_name}") | |
| print(f"Model resource name: {model.name}") | |
| if __name__ == "__main__": | |
| project_id = "igneous-spanner-441609-h6" | |
| location = "us-central1" | |
| credentials_path = "secrets/GOOGLE_VERTEX_AI_KEY_SYTOSS-441609.json" | |
| list_models(project_id, location, credentials_path) | |