# 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.

steps:
  - id: Install dependencies
    name: python:3.11
    dir: llm_demo 
    script: pip install -r requirements.txt -r requirements-test.txt --user

  - id: "Run evaluation service"
    name: python:3.11
    dir: llm_demo
    env: # Set env var expected by tests
      - "ORCHESTRATION_TYPE=${_ORCHESTRATION_TYPE}"
      - "RETRIEVAL_EXPERIMENT_NAME=${_RETRIEVAL_EXPERIMENT_NAME}"
      - "RESPONSE_EXPERIMENT_NAME=${_RESPONSE_EXPERIMENT_NAME}"
    secretEnv:
      - CLIENT_ID
      - BASE_URL
    script: |
        #!/usr/bin/env bash
        python run_evaluation.py

serviceAccount: "projects/$PROJECT_ID/serviceAccounts/evaluation-testing@retrieval-app-testing.iam.gserviceaccount.com" # Necessary for ID token creation
options:
  logging: CLOUD_LOGGING_ONLY # Necessary for custom service account
  dynamic_substitutions: true

substitutions:
  _ORCHESTRATION_TYPE: "langchain-tools"
  _RETRIEVAL_EXPERIMENT_NAME: "retrieval-phase-eval-${_PR_NUMBER}"
  _RESPONSE_EXPERIMENT_NAME:  "response-phase-eval-${_PR_NUMBER}"

availableSecrets:
  secretManager:
    - versionName: projects/$PROJECT_ID/secrets/client_id/versions/latest
      env: CLIENT_ID
    - versionName: projects/$PROJECT_ID/secrets/retrieval_url/versions/latest
      env: BASE_URL
