# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: blueprints.cloud.google.com/v1alpha1
kind: BlueprintMetadata
metadata:
  name: terraform-genai-doc-summarization
  annotations:
    config.kubernetes.io/local-config: "true"
spec:
  info:
    title: Generative AI Document Summarization
    source:
      repo: https://github.com/GoogleCloudPlatform/terraform-genai-doc-summarization.git
      sourceType: git
    version: 0.2.0
    actuationTool:
      flavor: Terraform
      version: ">= 1.5"
    description:
      tagline: Create summaries of a large corpus of documents using Generative AI.
      detailed: This solution showcases how to summarize a large corpus of documents using Generative AI. It provides an end-to-end demonstration of document summarization going all the way from raw documents, detecting text in the documents and summarizing the documents on-demand using Vertex AI LLM APIs, Document AI Optical Character Recognition (OCR), and BigQuery.
      preDeploy: To deploy this blueprint you must have an active billing account and billing permissions.
    icon: assets/icon.png
    deploymentDuration:
      configurationSecs: "60"
      deploymentSecs: "300"
    costEstimate:
      description: Cost Details
      url: https://cloud.google.com/products/calculator?dl=CiQyN2Q1NmU4ZS0yNzg0LTQ1YjMtYTVkOC0wOTEwMmYxMjllYzcQEhokMTA1QTQyQUUtQTI2Ni00MzgzLTlCMDEtOTJEMjkxMjlFQTA1
    cloudProducts:
      - productId: VERTEX_SECTION
        label: Vertex AI
      - productId: document-ai
        label: Document AI OCR
      - productId: search_BIGQUERY_SECTION
        label: BigQuery
      - productId: FUNCTIONS_SECTION
        label: Cloud Functions
      - productId: STORAGE_SECTION
        label: Cloud Storage
      - productId: EVENTARC_SECTION
        label: Eventarc
  content:
    architecture:
      diagramUrl: https://www.gstatic.com/pantheon/images/solutions/gen_ai_document_summarization_architecture_v1.svg
      description:
        - User uploads a new document triggering the webhook Cloud Function.
        - Document AI extracts the text from the document file.
        - A Vertex AI Large Language Model summarizes the document text.
        - The document summaries are stored in BigQuery.
    documentation:
      - title: Generative AI Document Summary
        url: https://cloud.google.com/architecture/ai-ml/generative-ai-document-summarization
    examples:
      - name: simple_example
        location: examples/simple_example
  interfaces:
    variables:
      - name: disable_services_on_destroy
        description: Whether project services will be disabled when the resources are destroyed.
        varType: bool
        defaultValue: false
      - name: documentai_location
        description: Document AI location, see https://cloud.google.com/document-ai/docs/regions
        varType: string
        defaultValue: us
      - name: labels
        description: A set of key/value label pairs to assign to the resources deployed by this blueprint.
        varType: map(string)
        defaultValue: {}
      - name: project_id
        description: The Google Cloud project ID to deploy to
        varType: string
        required: true
      - name: region
        description: The Google Cloud region to deploy to
        varType: string
        defaultValue: us-central1
      - name: unique_names
        description: Whether to use unique names for resources
        varType: bool
        defaultValue: false
    outputs:
      - name: bigquery_dataset_id
        description: The name of the BigQuery dataset created
      - name: bucket_docs_name
        description: The name of the docs bucket created
      - name: bucket_main_name
        description: The name of the main bucket created
      - name: documentai_processor_id
        description: The full Document AI processor path ID
      - name: neos_walkthrough_url
        description: The URL to launch the in-console tutorial for the Generative AI Document Summarization solution
      - name: unique_id
        description: The unique ID for this deployment
  requirements:
    roles:
      - level: Project
        roles:
          - roles/clouddeploymentmanager.serviceAgent
          - roles/cloudfunctions.serviceAgent
          - roles/config.agent
          - roles/documentai.editor
          - roles/resourcemanager.projectIamAdmin
          - roles/serviceusage.serviceUsageViewer
    services:
      - aiplatform.googleapis.com
      - artifactregistry.googleapis.com
      - bigquery.googleapis.com
      - cloudbuild.googleapis.com
      - cloudfunctions.googleapis.com
      - cloudresourcemanager.googleapis.com
      - config.googleapis.com
      - documentai.googleapis.com
      - eventarc.googleapis.com
      - run.googleapis.com
      - serviceusage.googleapis.com
      - storage.googleapis.com
