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
| Parameter | Type | Description |
|---|---|---|
prompt_id | str | Required. The unique id of the prompt. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const result = await client.prompts.getLabels("<PROMPT-ID>");Parameters
| Parameter | Type | Description |
|---|---|---|
promptId | string | Required. 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
| Parameter | Type | Description |
|---|---|---|
prompt_id | str | Required. The unique id of the prompt. |
label | str | Required. A label of the prompt, such as production. A label is unique within the prompt and points at one version at a time. |
version | str | Required. The version number the label should point at. The version must already be released; create a version first to release a commit. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const result = await client.prompts.setLabel(
"<PROMPT-ID>",
"production",
"00.00.02",
);Parameters
| Parameter | Type | Description |
|---|---|---|
promptId | string | Required. The unique id of the prompt. |
label | string | Required. A label of the prompt, such as production. A label is unique within the prompt and points at one version at a time. |
version | string | Required. 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
| Parameter | Type | Description |
|---|---|---|
prompt_id | str | Required. The unique id of the prompt. |
label | str | Required. A label of the prompt, such as production. A label is unique within the prompt and points at one version at a time. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const result = await client.prompts.deleteLabel(
"<PROMPT-ID>",
"production",
);Parameters
| Parameter | Type | Description |
|---|---|---|
promptId | string | Required. The unique id of the prompt. |
label | string | Required. 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: strlabelstrRequired
The label, unique within the prompt.
Example: "production"
versionstrRequired
The version number the label points at.
Example: "00.00.02"
interface PromptLabel {
label: string;
version: string;
}labelstringRequired
The label, unique within the prompt.
Example: "production"
versionstringRequired
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.
interface PromptLabelList {
labels: PromptLabel[];
}labelsPromptLabel[]Required
This is the list of labels defined on the prompt, in alphabetical order, each with the version it points at.
See PromptLabel.
Last updated on