$schema: https://azuremlschemas.azureedge.net/latest/commandComponent.schema.json
type: command

tags:
    Preview: ""

version: 0.0.77
name: llm_rag_update_acs_index
display_name: LLM - Update ACS Index
is_deterministic: true

description: |
  Uploads `embeddings` into Azure Cognitive Search instance specified in `acs_config`. The Index will be created if it doesn't exist.

  The Index will have the following fields populated:
  - "id", String, key=True
  - "content", String
  - "contentVector", Collection(Single)
  - "category", String
  - "url", String
  - "filepath", String
  - "content_hash", String
  - "meta_json_string", String

  "meta_json_string" contains all metadata for a document serialized as a JSON string.

inputs:
  embeddings:
    type: uri_folder
    mode: direct
    description: "Embeddings output produced from parallel_create_embeddings."
  acs_config:
    type: string
    description: 'JSON string containing the ACS configuration. e.g. {"endpoint": "https://my-cog.search.windows.net", "index_name": "my-index", "api_version": "2021-04-30-Preview", "endpoint_key_name": "ACS-PROD-KEY"}'
  index_connection_id:
    type: string
    optional: true
    description: "The connection id of the ACS Index provider to use."
outputs:
  index:
    type: uri_folder
    description: "Uri folder containing MLINdex yaml describing the newly created/updated ACS index"

environment: azureml:llm-rag-embeddings@latest
code: '../src/'

command: >-
  python -m azureml.rag.tasks.update_acs
  --embeddings '${{inputs.embeddings}}'
  --acs_config '${{inputs.acs_config}}'
  --output '${{outputs.index}}'
  $[[--connection_id '${{inputs.index_connection_id}}']]
