Logging Metadata

Tags are a way for attaching arbitrary data to your rows so they can be sliced and diced.

Tags overview

This section provides a more granular look at Tags. Tags are flexible way to append to your data metadata such as where predictions come from and the context predictions are served in. All Tags are strings. Tags show up as additional columns in a Gantry row:

A Tag is a key/value pair that can be attached to a record upon ingestion to facilitate identifying a record via filters. Examples of Tags might include:

  • Which environment a record came from (prod, sandbox, dev)
  • Which model version (like a code, data hash, or combination) generated the prediction that a record represents
  • Other arbitrary data, such as the end consumer of the prediction for cases where a single model service serves multiple user interfaces

Tags are created by populating the tags keyword argument in the Python SDK.

import gantry
gantry.init(api_key=GANTRY_API_KEY)
application = gantry.get_application(GANTRY_APP_NAME)

tags = { 
  "env": "prod",
  "version": "c09f689b93facc1f0e165b0d98f9a9cd52de0668",
  "consumer": "mobile-ios"
}

inputs = {
  "prompt": "I read the news today oh boy",
}

outputs = {
  "generation": "About a lucky man who made the grade"
}

application.log(
  inputs=[inputs],
  outputs=[outputs],
  row_tags=[tags],
)

The the UI, Tags can be searched by filtering by substring:

Request Attributes, Response Attributes, and Session ID

📘

This section is applicable to Completion applications only

For Completion applications, each Open AI request and response can be paired with metadata when logged via the SDK. A session_id can be sent along as well. The session_id parameter is intended to be used for grouping the data in together within each session. This is a str or uuid maintained by your application logic.

my_llm_app.log_completion(
        open_ai_api_request=request,
        open_ai_api_response=convert_to_dict(results),
        request_attributes={"prompt_values": values},
  			response_attributes={},
        version=version.version_number,
  			session_id="12"
    )