Introducing Confident Voice: Watch the Launch Video Now

Managing Prompt Labels via Confident AI SDK

Overview

The Confident AI SDK exposes every Label method on the platform. This page documents how to call these methods in all supported languages. See the introduction to install the SDK and set your API key.

Methods

Get Labels

Lists every label defined on the prompt, in alphabetical order, each with the version it points at.

from confident_ai import ConfidentAI

client = ConfidentAI()

result = client.prompts.get_labels(prompt_id="<PROMPT-ID>")

For async mode, call a_get_labels and await it as shown below:

result = await client.prompts.a_get_labels(...)

Parameters

ParameterTypeDescription
prompt_idstrRequired. The unique id of the prompt.

Returns

This method returns an object of type PromptLabelList.

Set Label

Points label at a released version of the prompt, creating the label if it is new. A label sits on one version at a time, so this moves it off any version that carried it, and pulls by label return the new version from then on.

from confident_ai import ConfidentAI

client = ConfidentAI()

result = client.prompts.set_label(
    prompt_id="<PROMPT-ID>",
    label="production",
    version="00.00.02",
)

For async mode, call a_set_label and await it as shown below:

result = await client.prompts.a_set_label(...)

Parameters

ParameterTypeDescription
prompt_idstrRequired. The unique id of the prompt.
labelstrRequired. A label of the prompt, such as production. A label is unique within the prompt and points at one version at a time.
versionstrRequired. The version number the label should point at. The version must already be released; create a version first to release a commit.

Returns

This method returns an object of type PromptLabel.

Delete Label

Removes label from the prompt and returns the version it pointed at. The version itself is kept. A label referenced by an AI connection cannot be removed.

from confident_ai import ConfidentAI

client = ConfidentAI()

result = client.prompts.delete_label(
    prompt_id="<PROMPT-ID>",
    label="production",
)

For async mode, call a_delete_label and await it as shown below:

result = await client.prompts.a_delete_label(...)

Parameters

ParameterTypeDescription
prompt_idstrRequired. The unique id of the prompt.
labelstrRequired. A label of the prompt, such as production. A label is unique within the prompt and points at one version at a time.

Returns

This method returns an object of type PromptLabel.

Types

PromptLabel

A label of a prompt and the version it points at.

class PromptLabel:
    label: str
    version: str

labelstrRequired

The label, unique within the prompt.

Example: "production"

versionstrRequired

The version number the label points at.

Example: "00.00.02"

PromptLabelList

The labels defined on a prompt.

class PromptLabelList:
    labels: List[PromptLabel]

labelsList[PromptLabel]Required

This is the list of labels defined on the prompt, in alphabetical order, each with the version it points at.

See PromptLabel.

Building a production pipeline?Design a scalable API workflow for evals, datasets, traces, and promptsTalk to an engineer

Last updated on

Built byConfident AI