Versions
Overview
The Confident AI SDK exposes every Version 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
List Versions
Lists every version released for the prompt, oldest first.
from confident_ai import ConfidentAI
client = ConfidentAI()
prompt = client.prompt(prompt_id="<PROMPT-ID>")
result = prompt.list_versions()For async mode, call a_list_versions and await it as shown below:
result = await prompt.a_list_versions(...)import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const prompt = client.prompt("<PROMPT-ID>");
const result = await prompt.listVersions();Returns
This method returns an object of type PromptVersionList.
Create Version
Releases a commit as a new version of the prompt. Versions the commit with the given hash, or the head commit of main when no hash is given.
from confident_ai import ConfidentAI
client = ConfidentAI()
prompt = client.prompt(prompt_id="<PROMPT-ID>")
result = prompt.create_version(hash="bab04ce")For async mode, call a_create_version and await it as shown below:
result = await prompt.a_create_version(...)Parameters
| Parameter | Type | Description |
|---|---|---|
hash | Optional[str] | The hash of the commit to release as a new version. Only commits newer than the last versioned commit can be released. When omitted, the head commit of main is versioned. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const prompt = client.prompt("<PROMPT-ID>");
const result = await prompt.createVersion({ hash: "bab04ce" });Parameters
| Parameter | Type | Description |
|---|---|---|
hash | string | The hash of the commit to release as a new version. Only commits newer than the last versioned commit can be released. When omitted, the head commit of main is versioned. |
Returns
This method returns an object of type CreatePromptVersionResult.
Methods (Stateless)
These methods take every argument themselves, so a caller reaches them through client.prompts without opening a Prompt first.
Get Versions
Lists every version released for the prompt, oldest first.
from confident_ai import ConfidentAI
client = ConfidentAI()
result = client.prompts.get_versions(prompt_id="<PROMPT-ID>")For async mode, call a_get_versions and await it as shown below:
result = await client.prompts.a_get_versions(...)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.getVersions("<PROMPT-ID>");Parameters
| Parameter | Type | Description |
|---|---|---|
promptId | string | Required. The unique id of the prompt. |
Returns
This method returns an object of type PromptVersionList.
Create Version
Releases a commit as a new version of the prompt. Versions the commit with the given hash, or the head commit of main when no hash is given.
from confident_ai import ConfidentAI
client = ConfidentAI()
result = client.prompts.create_version(
prompt_id="<PROMPT-ID>",
hash="bab04ce",
)For async mode, call a_create_version and await it as shown below:
result = await client.prompts.a_create_version(...)Parameters
| Parameter | Type | Description |
|---|---|---|
prompt_id | str | Required. The unique id of the prompt. |
hash | Optional[str] | The hash of the commit to release as a new version. Only commits newer than the last versioned commit can be released. When omitted, the head commit of main is versioned. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const result = await client.prompts.createVersion(
"<PROMPT-ID>",
{ hash: "bab04ce" },
);Parameters
| Parameter | Type | Description |
|---|---|---|
promptId | string | Required. The unique id of the prompt. |
hash | string | The hash of the commit to release as a new version. Only commits newer than the last versioned commit can be released. When omitted, the head commit of main is versioned. |
Returns
This method returns an object of type CreatePromptVersionResult.
Types
CreatePromptVersionResult
class CreatePromptVersionResult:
version: str
hash: strversionstrRequired
The version number generated by Confident AI for the new version. It is always incremental.
Example: "00.00.02"
hashstrRequired
The hash of the commit that was versioned. This is the hash you passed, or the head of main when you omitted it.
Example: "bab04ce"
interface CreatePromptVersionResult {
version: string;
hash: string;
}versionstringRequired
The version number generated by Confident AI for the new version. It is always incremental.
Example: "00.00.02"
hashstringRequired
The hash of the commit that was versioned. This is the hash you passed, or the head of main when you omitted it.
Example: "bab04ce"
PromptType
This is the type of the prompt, which can be either a simple text or a list of messages.
class PromptType(Enum):
TEXT = "TEXT"
LIST = "LIST"enum PromptType {
TEXT = "TEXT",
LIST = "LIST",
}TEXT · LIST
PromptVersion
class PromptVersion:
id: str
version: stridstrRequired
This is the id of the prompt version generated by Confident AI, not to be confused with the version number.
Example: "<PROMPT-VERSION-ID>"
versionstrRequired
This is the version number of the prompt version.
Example: "00.00.01"
interface PromptVersion {
id: string;
version: string;
}idstringRequired
This is the id of the prompt version generated by Confident AI, not to be confused with the version number.
Example: "<PROMPT-VERSION-ID>"
versionstringRequired
This is the version number of the prompt version.
Example: "00.00.01"
PromptVersionList
class PromptVersionList:
versions: List[PromptVersion]
type: PromptTypeversionsList[PromptVersion]Required
This is the list of versions released for the prompt, oldest first.
See PromptVersion.
typePromptTypeRequired
See PromptType.
interface PromptVersionList {
versions: PromptVersion[];
type: PromptType;
}versionsPromptVersion[]Required
This is the list of versions released for the prompt, oldest first.
See PromptVersion.
typePromptTypeRequired
See PromptType.
Last updated on