AWS SDK 또는 ListFoundationModels CLI와 함께 사용 - Amazon Bedrock

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

AWS SDK 또는 ListFoundationModels CLI와 함께 사용

다음 코드 예제는 ListFoundationModels의 사용 방법을 보여줍니다.

.NET
AWS SDK for .NET
참고

더 많은 정보가 있습니다 GitHub. AWS 코드 예제 리포지토리에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요.

사용 가능한 Bedrock 기본 모델을 나열합니다.

/// <summary> /// List foundation models. /// </summary> /// <param name="bedrockClient"> The Amazon Bedrock client. </param> private static async Task ListFoundationModelsAsync(AmazonBedrockClient bedrockClient) { Console.WriteLine("List foundation models with no filter"); try { ListFoundationModelsResponse response = await bedrockClient.ListFoundationModelsAsync(new ListFoundationModelsRequest() { }); if (response?.HttpStatusCode == System.Net.HttpStatusCode.OK) { foreach (var fm in response.ModelSummaries) { WriteToConsole(fm); } } else { Console.WriteLine("Something wrong happened"); } } catch (AmazonBedrockException e) { Console.WriteLine(e.Message); } }
Go
SDK for Go V2
참고

자세한 내용은 다음과 같습니다 GitHub. AWS 코드 예제 리포지토리에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요.

사용 가능한 Bedrock 기본 모델을 나열합니다.

// FoundationModelWrapper encapsulates Amazon Bedrock actions used in the examples. // It contains a Bedrock service client that is used to perform foundation model actions. type FoundationModelWrapper struct { BedrockClient *bedrock.Client } // ListPolicies lists Bedrock foundation models that you can use. func (wrapper FoundationModelWrapper) ListFoundationModels() ([]types.FoundationModelSummary, error) { var models []types.FoundationModelSummary result, err := wrapper.BedrockClient.ListFoundationModels(context.TODO(), &bedrock.ListFoundationModelsInput{}) if err != nil { log.Printf("Couldn't list foundation models. Here's why: %v\n", err) } else { models = result.ModelSummaries } return models, err }
Java
SDK for Java 2.x
참고

자세한 내용은 다음과 같습니다 GitHub. AWS 코드 예제 리포지토리에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요.

동기식 Amazon Bedrock 클라이언트를 사용하여 사용 가능한 Amazon Bedrock 기반 모델을 나열하십시오.

/** * Lists Amazon Bedrock foundation models that you can use. * You can filter the results with the request parameters. * * @param bedrockClient The service client for accessing Amazon Bedrock. * @return A list of objects containing the foundation models' details */ public static List<FoundationModelSummary> listFoundationModels(BedrockClient bedrockClient) { try { ListFoundationModelsResponse response = bedrockClient.listFoundationModels(r -> {}); List<FoundationModelSummary> models = response.modelSummaries(); if (models.isEmpty()) { System.out.println("No available foundation models in " + region.toString()); } else { for (FoundationModelSummary model : models) { System.out.println("Model ID: " + model.modelId()); System.out.println("Provider: " + model.providerName()); System.out.println("Name: " + model.modelName()); System.out.println(); } } return models; } catch (SdkClientException e) { System.err.println(e.getMessage()); throw new RuntimeException(e); } }

비동기식 Amazon Bedrock 클라이언트를 사용하여 사용 가능한 Amazon Bedrock 기반 모델을 나열하십시오.

/** * Lists Amazon Bedrock foundation models that you can use. * You can filter the results with the request parameters. * * @param bedrockClient The async service client for accessing Amazon Bedrock. * @return A list of objects containing the foundation models' details */ public static List<FoundationModelSummary> listFoundationModels(BedrockAsyncClient bedrockClient) { try { CompletableFuture<ListFoundationModelsResponse> future = bedrockClient.listFoundationModels(r -> {}); List<FoundationModelSummary> models = future.get().modelSummaries(); if (models.isEmpty()) { System.out.println("No available foundation models in " + region.toString()); } else { for (FoundationModelSummary model : models) { System.out.println("Model ID: " + model.modelId()); System.out.println("Provider: " + model.providerName()); System.out.println("Name: " + model.modelName()); System.out.println(); } } return models; } catch (InterruptedException e) { Thread.currentThread().interrupt(); System.err.println(e.getMessage()); throw new RuntimeException(e); } catch (ExecutionException e) { System.err.println(e.getMessage()); throw new RuntimeException(e); } }
JavaScript
JavaScript (v3) 용 SDK
참고

더 많은 내용이 있습니다. GitHub AWS 코드 예제 리포지토리에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요.

사용 가능한 파운데이션 모델을 나열합니다.

// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 import { fileURLToPath } from "url"; import { BedrockClient, ListFoundationModelsCommand, } from "@aws-sdk/client-bedrock"; /** * List the available Amazon Bedrock foundation models. * * @return {FoundationModelSummary[]} - The list of available bedrock foundation models. */ export const listFoundationModels = async () => { const client = new BedrockClient(); const input = { // byProvider: 'STRING_VALUE', // byCustomizationType: 'FINE_TUNING' || 'CONTINUED_PRE_TRAINING', // byOutputModality: 'TEXT' || 'IMAGE' || 'EMBEDDING', // byInferenceType: 'ON_DEMAND' || 'PROVISIONED', }; const command = new ListFoundationModelsCommand(input); const response = await client.send(command); return response.modelSummaries; }; // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { const models = await listFoundationModels(); console.log(models); }
Kotlin
SDK for Kotlin
참고

자세한 내용은 다음과 같습니다 GitHub. AWS 코드 예제 리포지토리에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요.

사용 가능한 Amazon Bedrock 기초 모델을 나열하세요.

suspend fun listFoundationModels(): List<FoundationModelSummary>? { BedrockClient { region = "us-east-1" }.use { bedrockClient -> val response = bedrockClient.listFoundationModels(ListFoundationModelsRequest {}) response.modelSummaries?.forEach { model -> println("==========================================") println(" Model ID: ${model.modelId}") println("------------------------------------------") println(" Name: ${model.modelName}") println(" Provider: ${model.providerName}") println(" Input modalities: ${model.inputModalities}") println(" Output modalities: ${model.outputModalities}") println(" Supported customizations: ${model.customizationsSupported}") println(" Supported inference types: ${model.inferenceTypesSupported}") println("------------------------------------------\n") } return response.modelSummaries } }
PHP
SDK for PHP
참고

자세한 내용은 여기에서 확인할 수 있습니다. GitHub AWS 코드 예제 리포지토리에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요.

사용 가능한 Amazon Bedrock 기초 모델을 나열하세요.

public function listFoundationModels() { $result = $this->bedrockClient->listFoundationModels(); return $result; }
Python
SDK for Python(Boto3)
참고

자세한 내용은 다음과 같습니다 GitHub. AWS 코드 예제 리포지토리에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요.

사용 가능한 Amazon Bedrock 기초 모델을 나열하세요.

def list_foundation_models(self): """ List the available Amazon Bedrock foundation models. :return: The list of available bedrock foundation models. """ try: response = self.bedrock_client.list_foundation_models() models = response["modelSummaries"] logger.info("Got %s foundation models.", len(models)) return models except ClientError: logger.error("Couldn't list foundation models.") raise
  • API에 대한 자세한 내용은 파이썬용AWS SDK (Boto3) API 레퍼런스를 참조하십시오 ListFoundationModels.

AWS SDK 개발자 가이드 및 코드 예제의 전체 목록은 을 참조하십시오. AWS SDK와 함께 이 서비스 사용 이 주제에는 시작하기에 대한 정보와 이전 SDK 버전에 대한 세부 정보도 포함되어 있습니다.