Catalog

gllm-inference | Tutorial: Catalog | API Reference

Prerequisites

This example specifically requires completion of all setup steps listed on the Prerequisites page.

You should be familiar with these concepts and components:

Installation

# you can use a Conda environment
pip install --extra-index-url https://oauth2accesstoken:$(gcloud auth print-access-token)@glsdk.gdplabs.id/gen-ai-internal/simple/ gllm-inference

Prompt Builder Catalog

Prompt Builder Catalog enables you to load and manage multiple prompt builders from various data sources like Google Sheets, CSV files, or Python records. This allows you to centralize prompt management, making it easier to maintain, version, and share prompts across your applications.

For example, instead of hard-coding prompts in your code, you can store them in a Google Sheet with names like "summarize", "transform_query", and "draft_document", then load them all at once using the catalog.

Catalog Configuration

The PromptBuilderCatalog can be configured using a table (such as a CSV file or Google Sheet), or directly from a list of Python dictionaries (records). To function correctly, the table or records must include specific columns or keys:

Required Columns:

  1. name: The unique identifier for the prompt builder

  2. system: The system template (instructions for the AI)

  3. user: The user template (how user input is formatted)

Important Notes:

  • At least one of system or user columns must be filled

  • Templates support variable placeholders using {variable_name} syntax

Loading Catalog

Option 1: From Google Sheets

1

Obtain Worksheet ID and Credentials

From your Google Sheets URL, you can obtain:

  • sheet_id: between /d/ and /edit

  • worksheet_id: 0 (usually 0 for the first sheet)

2

Obtain Google Service Account JSON Credentials

Follow these steps:

3

Load with .from_gsheets() method

Option 2: From CSV File

1

Download/create CSV file

Prepare a CSV file that contains your prompt catalog definitions. You can find an example here #template-format-references.

2

Load with .from_csv() method

Option 3: From Python Records

1

**Define the catalog**

Provide the records in the format of list of dictionaries. An example can be found below:

{% endstep %}

{% step %} Load using `

.from_records()` method

Using Catalog

Once loaded, you can access any prompt builder by its name:


LM Request Processor Catalog

LM Request Processor Catalog enables you to load and manage multiple LM request processors from various data sources like Google Sheets, CSV files, or Python records. This allows you to centralize the configuration of complete AI pipelines, including prompts, models, credentials, and output parsing in one place.

For example, instead of manually configuring each LM request processor with its model, credentials, and prompts, you can store all configurations in a Google Sheet and load them by name like "summarizer", "question_answerer", and "code_generator".

Think of it as:

LM Request Processor Catalog is like having a configuration management system for your AI pipelines, where each row defines a complete, ready-to-use AI processor.

Catalog Configuration

The LMRequestProcessorCatalog can be configured using a table (such as a CSV file or Google Sheet), or directly from a list of Python dictionaries (records). To function correctly, the table or records must include specific columns or keys:

Required Columns:

  1. name: The unique identifier for the LM request processor

  2. system_template: The system template for the prompt builder

  3. user_template: The user template for the prompt builder

  4. model_id: The model identifier for the LM invoker

  5. credentials: Authentication credentials for the model

  6. config: Additional configuration for the LM invoker (JSON format)

  7. output_parser_type: Type of output parser to use

Important Notes:

  • At least one of system_template or user_template must be filled

  • model_id supports environment variable substitution using ${ENV_VAR_KEY} syntax

  • credentials and config are optional but provide advanced functionality

Loading Catalog

Option 1: From Google Sheets

1

Obtain Worksheet ID and Credentials

From your Google Sheets URL, you can obtain:

  • sheet_id: between /d/ and /edit

  • worksheet_id: 0 (usually 0 for the first sheet)

2

Obtain Google Service Account JSON Credentials

Follow these steps:

3

Load with .from_gsheets() method

Option 2: From CSV File

1

Download/create CSV file

Prepare a CSV file that contains your LM request processor catalog definitions. You can find an example here #template-format-references.

2

Load with .from_csv() method

Option 3: From Python Records

1

Define the catalog

Provide the records in the format of list of dictionaries. An example can be found below:

2

Load using .from_records() method

Using Catalog

Once loaded, you can use the LM request processors directly:

Output

Last updated