Launch Week 3: Five days of launches

Branches

Overview

The Confident AI SDK exposes every Branch 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 Branches

Lists the branches of the prompt.

from confident_ai import ConfidentAI

client = ConfidentAI()

prompt = client.prompt(prompt_id="<PROMPT-ID>")
result = prompt.list_branches()

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

result = await prompt.a_list_branches(...)

Returns

This method returns an object of type PromptBranchList.

Create Branch

Creates a branch of the prompt diverging from the head commit of main.

from confident_ai import ConfidentAI

client = ConfidentAI()

prompt = client.prompt(prompt_id="<PROMPT-ID>")
result = prompt.create_branch(name="experiment")

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

result = await prompt.a_create_branch(...)

Parameters

ParameterTypeDescription
namestrRequired. The name of the branch to create. It diverges from the head commit of main.

Returns

This method returns an object of type PromptBranch.

Update Branch

Renames a branch of the prompt. The main branch cannot be renamed.

from confident_ai import ConfidentAI

client = ConfidentAI()

prompt = client.prompt(prompt_id="<PROMPT-ID>")
result = prompt.update_branch(branch_id="<BRANCH-ID>", name="experiment-v2")

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

result = await prompt.a_update_branch(...)

Parameters

ParameterTypeDescription
branch_idstrRequired. The unique id of the branch.
namestrRequired. The new name of the branch. The main branch cannot be renamed.

Returns

This method returns an object of type PromptBranchRef.

Delete Branch

Deletes a branch of the prompt. The main branch, branches with open pull requests, and branches referenced by AI connections cannot be deleted.

from confident_ai import ConfidentAI

client = ConfidentAI()

prompt = client.prompt(prompt_id="<PROMPT-ID>")
result = prompt.delete_branch(branch_id="<BRANCH-ID>")

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

result = await prompt.a_delete_branch(...)

Parameters

ParameterTypeDescription
branch_idstrRequired. The unique id of the branch.

Returns

This method returns an object of type PromptBranchRef.

Methods (Stateless)

These methods take every argument themselves, so a caller reaches them through client.prompts without opening a Prompt first.

Get Branches

Lists the branches of the prompt.

from confident_ai import ConfidentAI

client = ConfidentAI()

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

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

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

Parameters

ParameterTypeDescription
prompt_idstrRequired. The unique id of the prompt.

Returns

This method returns an object of type PromptBranchList.

Create Branch

Creates a branch of the prompt diverging from the head commit of main.

from confident_ai import ConfidentAI

client = ConfidentAI()

result = client.prompts.create_branch(
    prompt_id="<PROMPT-ID>",
    name="experiment",
)

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

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

Parameters

ParameterTypeDescription
prompt_idstrRequired. The unique id of the prompt.
namestrRequired. The name of the branch to create. It diverges from the head commit of main.

Returns

This method returns an object of type PromptBranch.

Update Branch

Renames a branch of the prompt. The main branch cannot be renamed.

from confident_ai import ConfidentAI

client = ConfidentAI()

result = client.prompts.update_branch(
    prompt_id="<PROMPT-ID>",
    branch_id="<BRANCH-ID>",
    name="experiment-v2",
)

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

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

Parameters

ParameterTypeDescription
prompt_idstrRequired. The unique id of the prompt.
branch_idstrRequired. The unique id of the branch.
namestrRequired. The new name of the branch. The main branch cannot be renamed.

Returns

This method returns an object of type PromptBranchRef.

Delete Branch

Deletes a branch of the prompt. The main branch, branches with open pull requests, and branches referenced by AI connections cannot be deleted.

from confident_ai import ConfidentAI

client = ConfidentAI()

result = client.prompts.delete_branch(
    prompt_id="<PROMPT-ID>",
    branch_id="<BRANCH-ID>",
)

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

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

Parameters

ParameterTypeDescription
prompt_idstrRequired. The unique id of the prompt.
branch_idstrRequired. The unique id of the branch.

Returns

This method returns an object of type PromptBranchRef.

Types

PromptBranch

class PromptBranch:
    id: str
    name: str

idstrRequired

This is the unique id of the prompt branch.

Example: "<BRANCH-ID>"

namestrRequired

This is the name of the prompt branch.

Example: "experiment"

PromptBranchList

class PromptBranchList:
    branches: List[PromptBranch]

branchesList[PromptBranch]Required

This is the list of branches on the prompt.

See PromptBranch.

PromptBranchRef

class PromptBranchRef:
    id: str

idstrRequired

This is the unique id of the prompt branch.

Example: "<BRANCH-ID>"

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

Last updated on

Built byConfident AI