다음을 통해 공유


카탈로그 API 참조

중요합니다

  • Foundry Local은 미리 보기로 제공됩니다. 공개 미리 보기 릴리스는 활성 배포 중인 기능에 대한 초기 액세스를 제공합니다.
  • 기능, 접근 방식 및 프로세스는 GA(일반 공급) 전에 기능이 변경되거나 제한될 수 있습니다.

Foundry Local을 사용하면 고유한 카탈로그 서비스를 빌드하고 통합할 수 있습니다. 이 문서에서 다루는 내용:

  • 카탈로그 API에 필요한 모델 형식
  • 카탈로그 API가 Foundry Local과 통합되는 데 필요한 요청 및 응답 형식

필수 조건

  • Foundry Local이 설치되어 있습니다.
  • 엔드포인트를 노출하는 웹 서비스를 실행할 수 있습니다 POST .
  • 모델 아티팩트가 ONNX 형식으로 제공됩니다.
  • Azure RBAC(역할 기반 액세스 제어): 해당되지 않습니다.

모델 형식

Foundry Local을 사용하려면 모델 카탈로그 에 ONNX(Open Neural Network Exchange) 형식의 모델 파일이 포함되어야 합니다. 포옹 얼굴 및 PyTorch 모델을 ONNX로 컴파일하는 방법을 알아보려면 Foundry Local에서 실행되도록 포옹 얼굴 모델 컴파일을 참조하세요.

API 형식

요청

JSON 요청 본문을 수락하는 카탈로그 서비스에서 POST 엔드포인트를 구현합니다. 카탈로그 API에 대한 요청 형식은 다음과 같습니다.

  • 메서드: POST
  • Content-Type: application/json

요청 예제

curl -X POST <your-catalog-api-endpoint> \
-H "Content-Type: application/json" \
-d '{
  "resourceIds": [
    {
      "resourceId": "azureml",
      "entityContainerType": "Registry"
    }
  ],
  "indexEntitiesRequest": {
    "filters": [
      {
        "field": "type",
        "operator": "eq",
        "values": [
          "models"
        ]
      },
      {
        "field": "kind",
        "operator": "eq",
        "values": [
          "Versioned"
        ]
      },
      {
        "field": "properties/variantInfo/variantMetadata/device",
        "operator": "eq",
        "values": [
          "cpu",
          "gpu"
        ]
      },
      {
        "field": "properties/variantInfo/variantMetadata/executionProvider",
        "operator": "eq",
        "values": [
          "cpuexecutionprovider",
          "webgpuexecutionprovider"
        ]
      }
    ],
    "pageSize": 10,
    "skip": null,
    "continuationToken": null
  }
}'

카탈로그 서비스 URL로 대체 <your-catalog-api-endpoint> 합니다.

고려해야 할 사항

  • 성공적인 응답에는 개체가 indexEntitiesResponse 포함됩니다.
  • 검색 결과가 반환됩니다.indexEntitiesResponse.value

참조:

요청 본문은 다음 필드가 있는 JSON 개체여야 합니다.

  • resourceIds: 쿼리할 리소스를 지정하는 리소스 ID의 배열입니다. 각 항목에는 다음이 포함됩니다.
    • resourceId: 리소스의 ID입니다.
    • entityContainerType: 엔터티 컨테이너의 형식(예: Registry, Workspace및 기타)입니다.
  • indexEntitiesRequest: 검색 매개 변수를 포함하는 개체입니다.
    • filters: 검색 결과를 필터링하기 위한 조건을 지정하는 필터 개체의 배열입니다. 각 필터에는 다음이 포함됩니다.
      • field: 필터링할 필드(예: type, kind및 기타)입니다.
      • operator: 필터에 사용할 연산자입니다. 예를 들어 eq (같음), ne (같지 않음), gt (보다 큼), lt (보다 작음) 및 기타입니다.
      • values: 필드와 일치시킬 값의 배열입니다.
    • orderBy: 결과를 정렬할 필드의 배열입니다.
    • searchText: 결과에서 검색할 문자열입니다.
    • pageSize: 반환할 최대 결과 수입니다(페이지 매김의 경우).
    • skip: 건너뛸 결과 수입니다(페이지 매김의 경우).
    • continuationToken: 이전 요청에서 계속하기 위한 페이지 매김에 대한 토큰입니다.

필터링 가능한 필드(선택 사항)

요청 형식을 수락할 수 있도록 카탈로그 API를 구현합니다. 서버 쪽 필터링은 선택 사항입니다. 서버 쪽 필터링을 건너뛰는 것은 구현 속도가 빠르지만 모델 검색에는 효율성이 떨어집니다.

서버 쪽 필터링을 구현하는 경우 다음 필드를 사용합니다.

  • type: 모델의 형식(예: models, datasets및 기타)입니다.
  • kind: 모델 종류(예: Versioned, Unversioned및 기타)입니다.
  • properties/variantInfo/variantMetadata/device: 디바이스 유형(예: cpu, gpu및 기타)입니다.
  • properties/variantInfo/variantMetadata/executionProvider: 실행 공급자(예: cpuexecutionprovider, webgpuexecutionprovider및 기타)입니다.

응답

카탈로그 API는 검색 결과가 포함된 JSON 개체를 반환합니다.

응답 예제

{
  "indexEntitiesResponse": {
    "totalCount": 1,
    "value": [
      {
        "assetId": "example-asset-id",
        "version": "1",
        "properties": {
          "name": "example-model",
          "version": 1,
          "variantInfo": {
            "variantMetadata": {
              "device": "cpu",
              "executionProvider": "cpuexecutionprovider"
            }
          }
        }
      }
    ],
    "nextSkip": null,
    "continuationToken": null
  }
}

응답 스키마

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "indexEntitiesResponse": {
      "type": "object",
      "properties": {
        "totalCount": {
          "type": "integer",
          "description": "The total count of entities."
        },
        "value": {
          "type": "array",
          "description": "An array of LocalModel objects.",
          "items": {
            "$ref": "#/definitions/LocalModel"
          }
        },
        "nextSkip": {
          "type": "integer",
          "description": "The number of items to skip for the next request."
        },
        "continuationToken": {
          "type": "string",
          "description": "A token to continue fetching results."
        }
      }
    }
  },
  "definitions": {
    "LocalModel": {
      "type": "object",
      "properties": {
        "annotations": {
          "type": "object",
          "description": "Annotations associated with the model.",
          "properties": {
            "tags": {
              "type": "object",
              "description": "Tags associated with the annotation.",
              "properties": {
                "author": { "type": "string" },
                "alias": { "type": "string" },
                "directoryPath": { "type": "string" },
                "license": { "type": "string" },
                "licenseDescription": { "type": "string" },
                "promptTemplate": { "type": "string" },
                "task": { "type": "string" }
              }
            },
            "systemCatalogData": {
              "type": "object",
              "properties": {
                "publisher": { "type": "string" },
                "displayName": { "type": "string" }
              }
            },
            "name": { "type": "string" }
          }
        },
        "properties": {
          "type": "object",
          "description": "Properties of the model.",
          "properties": {
            "name": { "type": "string" },
            "version": { "type": "integer" },
            "alphanumericVersion": { "type": "string" },
            "variantInfo": {
              "type": "object",
              "properties": {
                "parents": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "assetId": { "type": "string" }
                    }
                  }
                },
                "variantMetadata": {
                  "type": "object",
                  "properties": {
                    "modelType": { "type": "string" },
                    "device": { "type": "string" },
                    "executionProvider": { "type": "string" },
                    "fileSizeBytes": { "type": "integer" }
                  }
                }
              }
            }
          }
        },
        "version": {
          "type": "string",
          "description": "The version of the model."
        },
        "assetId": {
          "type": "string",
          "description": "The asset ID of the model."
        }
      }
    }
  }
}

참조: