Vertex AI Search 확장 프로그램

이 문서에서는 Google Cloud 콘솔 및 Vertex AI API에서 Google 제공 Vertex AI Search 확장 프로그램을 등록하고 사용하는 방법을 보여줍니다. 이 확장 프로그램을 사용하면 웹사이트 코퍼스 및 구조화되지 않은 데이터에 액세스하고 검색하여 다음과 같은 자연어 질문에 관련 응답을 제공할 수 있습니다.

  • "지난 해 1분기에서 올해 1분기까지 회사의 경쟁적 위협은 어떻게 바뀌었나요?"
  • "회사의 어떤 부분이 가장 빠르게 성장하고 있나요? 얼마나 빠른가요?"

Vertex AI Search 확장 프로그램은 Vertex AI Search를 사용하여 데이터 스토어에서 의미 있는 결과를 검색합니다. Vertex AI Search 확장 프로그램은 OpenAPI 사양 vertex_ai_search.yaml 파일에 정의되어 있습니다.

Vertex AI Search 확장 프로그램을 사용하려면 검색 범위가 지정된 전역 리전에 데이터 스토어를 생성해야 합니다. 최상의 검색 결과를 얻으려면 웹사이트 데이터에 고급 색인 생성을 사용 설정하고 구조화되지 않은 데이터에 Enterprise 버전을 사용 설정합니다. 자세한 내용은 고급 기능 정보를 참조하세요.

openapi: "3.0.0"
info:
  title: Vertex AI Search
  version: v1alpha
  description: >
    Performs search on user ingested data including website and unstructured data type.

    This extension is used when user wants to search or retrieve meaningful results from their ingested data in the Vertex AI Search service.

    Supported AuthTypes:
    - GOOGLE_SERVICE_ACCOUNT_AUTH: (only supports using Vertex AI Extension Service Agent).
paths:
  /search:
    get:
      operationId: search
      description: Retrieves the results from user's query by searching in the data store.
      parameters:
      - name: query
        in: query
        schema:
          type: string
        description: User natural language instructions for search.
        required: true
      responses:
        default:
          description: Search execution result.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SearchResult"

components:
  schemas:
    SearchResult:
      description: Top results from search response.
      type: object
      properties:
        results:
          type: array
          items:
            type: object
            properties:
              title:
                type: string
                description: Retrieved document title.
              display_link:
                type: string
                description: Retrieved document link to display.
              link:
                type: string
                description: Retrieved document link.
              extractive_segments:
                type: array
                description: Extractive segments from the retrieved file.
                items:
                  type: string
              extractive_answers:
                type: array
                description: Extractive answers from the retrieved file. These are generated from the extractive segments.
                items:
                  type: string

    

엔드 투 엔드 튜토리얼이 포함된 Google 확장 프로그램에 대해 알아보려면 다음 Jupyter 노트북을 참조하세요.

  • Vertex AI 확장 프로그램을 사용한 비즈니스 분석가 워크플로: 코드 인터프리터 확장 프로그램 및 Vertex AI Search 확장 프로그램을 사용하여 비즈니스 이해관계자를 위한 주택 투자 기회 연구 보고서를 작성합니다.
    Colab | GitHub | Vertex AI Workbench
  • Vertex AI 확장 프로그램을 사용한 게임 리뷰 분석 워크플로: 코드 인터프리터 확장 프로그램을 사용하여 Steam의 게임 리뷰를 분석합니다. Vertex AI Search 확장 프로그램을 사용하여 웹사이트의 게임 리뷰를 요약합니다. 코드 인터프리터 확장 프로그램을 사용하여 생성된 모든 애셋이 포함된 보고서를 작성합니다.
    Colab | GitHub | Vertex AI Workbench

시작하기 전에

  1. Google Cloud 계정에 로그인합니다. Google Cloud를 처음 사용하는 경우 계정을 만들고 Google 제품의 실제 성능을 평가해 보세요. 신규 고객에게는 워크로드를 실행, 테스트, 배포하는 데 사용할 수 있는 $300의 무료 크레딧이 제공됩니다.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Google Cloud 프로젝트에 결제가 사용 설정되어 있는지 확인합니다.

  4. Vertex AI API 사용 설정

    API 사용 설정

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  6. Google Cloud 프로젝트에 결제가 사용 설정되어 있는지 확인합니다.

  7. Vertex AI API 사용 설정

    API 사용 설정

Vertex AI Search 확장 프로그램 등록 및 실행

다음 섹션에서는 Google Cloud 콘솔 및 Vertex AI API를 사용하여 Vertex AI Search 확장 프로그램을 등록하는 방법을 보여줍니다. 확장 프로그램을 등록한 후에는 Vertex AI API를 사용하여 실행할 수 있습니다.

콘솔

확장 프로그램 등록

Google Cloud 콘솔을 사용하여 Vertex AI Search 확장 프로그램을 등록하려면 다음 단계를 수행하세요.

  1. Google Cloud 콘솔에서 Vertex AI 확장 프로그램 페이지로 이동합니다.

    Vertex AI 확장 프로그램으로 이동

  2. 확장 프로그램 만들기를 클릭합니다.

  3. 새 확장 프로그램 만들기 대화상자에서 다음 필드를 작성합니다.

    • 확장 프로그램 이름: 확장 프로그램의 이름을 입력합니다(예: 'vertex_search_extension').
    • 설명: (선택사항) 확장 프로그램 설명을 입력합니다(예: 'Vertex AI Search 확장 프로그램').
    • 확장 프로그램 유형: Vertex AI search를 선택합니다.
  4. 이제 표시되는 OpenAPI 사양 파일 섹션에서 다음 필드가 올바르게 설정되었는지 확인합니다.

    • API 이름: vertex_ai_search.
    • API 설명: Performs search on user ingested data including website and unstructured data type...
    • 소스: Cloud Storage.
    • OpenAPI 사양: vertex-extension-public/vertex_ai_search.yaml.
    • 인증: Google service account.
  5. 런타임 구성 섹션에서 서빙 구성 이름을 지정합니다. 서빙 구성 이름은 vertexAiSearchRuntimeConfig에 지정됩니다. projects/PROJECT_ID/locations/global/collections/COLLECTION_NAME/engines/ENGINE/servingConfigs/SERVING_CONFIG과 같이 형식이 지정되고 완료됩니다.

    • COLLECTION_NAMEdefault_collection로 설정합니다.
    • ENGINE을 검색 애플리케이션을 만들 때 받은 애플리케이션 ID로 설정합니다. 자세한 내용은 웹사이트 데이터용 검색 앱 만들기를 참조하세요.
    • SERVING_CONFIGdefault_search로 설정합니다.
  6. 확장 프로그램 만들기를 클릭합니다.

REST

확장 프로그램 등록

Vertex AI API extensions.import 요청을 제출하여 Vertex AI Search 확장 프로그램을 등록합니다.

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: Google Cloud 프로젝트의 ID
  • REGION: Compute Engine 리전
  • DISPLAY_NAME: 사용자에게 표시되는 확장 프로그램의 이름(예: 'my_search_extension')
  • DESCRIPTION: (선택사항) 사용자에게 표시되는 확장 프로그램 설명(예: '검색 확장 프로그램')
  • SERVICE_ACCOUNT: (선택사항) Vertex AI Search 확장 프로그램은 샘플 요청 본문에 표시된 것처럼 GOOGLE_SERVICE_ACCOUNT_AUTH를 사용합니다. 서비스 계정을 지정하지 않으면 확장 프로그램이 기본 Vertex AI Extension 서비스 에이전트 서비스 계정을 사용합니다. 다른 서비스 계정을 지정하면 지정된 서비스 계정에 대한 iam.serviceAccounts.getAccessToken 권한이 Vertex AI 확장 프로그램 서비스 에이전트 서비스 계정에 부여됩니다.
  • SERVING_CONFIG_NAME: 서빙 구성 이름은 vertexAiSearchRuntimeConfig에 지정됩니다. projects/PROJECT_ID/locations/global/collections/COLLECTION_NAME/engines/ENGINE/servingConfigs/SERVING_CONFIG과 같이 형식이 지정되고 완료됩니다.
    • PROJECT_ID: Google Cloud 프로젝트의 ID
    • COLLECTION_NAMEdefault_collection로 설정합니다.
    • ENGINE: 검색 애플리케이션을 만들 때 받은 애플리케이션 ID입니다. 자세한 내용은 웹사이트 데이터용 검색 앱 만들기를 참조하세요.
    • SERVING_CONFIGdefault_search로 설정합니다.
    확장 프로그램이 gs:// 프리픽스(예: gs://sample-bucket-name)를 포함한 입력 파일을 읽는 데 사용할 Cloud Storage 버킷입니다. 이를 지정하면 이 버킷의 roles/storage.objectViewer 역할을 Vertex 확장 프로그램 커스텀 코드 서비스 에이전트에 할당해야 합니다.

HTTP 메서드 및 URL:

POST https://REGION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/extensions:import

JSON 요청 본문:

{
  "displayName":"DISPLAY_NAME",
  "description":"DESCRIPTION",
  "manifest":{
    "name":"code_interpreter_tool",
    "description":"A Google Code Interpreter tool",
    "apiSpec":{
      "openApiGcsUri":"gs://vertex-extension-public/code_interpreter.yaml"
    },
    "authConfig":{
      "authType":"GOOGLE_SERVICE_ACCOUNT_AUTH",
      "googleServiceAccountConfig":{
        "serviceAccount":"SERVICE_ACCOUNT"
      }
    }
  }
  "runtimeConfig": {
     "vertexAiSearchRuntimeConfig": {
        "servingConfigName": "SERVING_CONFIG_NAME",
     }
  }
}

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

요청 본문을 request.json 파일에 저장하고 다음 명령어를 실행합니다.

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://REGION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/extensions:import"

PowerShell

요청 본문을 request.json 파일에 저장하고 다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://REGION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/extensions:import" | Select-Object -Expand Content

확장 프로그램 실행

Vertex AI API에 execute 작업을 제출하여 데이터 스토어에서 의미 있는 결과를 가져올 수 있습니다.

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: Google Cloud 프로젝트의 ID
  • REGION: Compute Engine 리전
  • EXTENSION_ID: Google Cloud 콘솔의 확장 프로그램 세부정보에 나열된 Vertex AI Search 확장 프로그램의 ID

HTTP 메서드 및 URL:

POST https://REGION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/extensions/EXTENSION_ID:execute

JSON 요청 본문:

{
  "operation_id":"search",
  "operation_params":{
    "query":"Housing affordability since 2010",
  }
}

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

요청 본문을 request.json 파일에 저장하고 다음 명령어를 실행합니다.

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://REGION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/extensions/EXTENSION_ID:execute"

PowerShell

요청 본문을 request.json 파일에 저장하고 다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://REGION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/extensions/EXTENSION_ID:execute" | Select-Object -Expand Content