Class AsyncPromptManagement (1.117.0)

AsyncPromptManagement(api_client_: google.genai._api_client.BaseApiClient)

API documentation for AsyncPromptManagement class.

Methods

create_version

create_version(
    *,
    prompt: typing.Union[
        vertexai._genai.types.Prompt, vertexai._genai.types.PromptDict
    ],
    config: typing.Optional[
        typing.Union[
            vertexai._genai.types.CreatePromptConfig,
            vertexai._genai.types.CreatePromptConfigDict,
        ]
    ] = None
) -> vertexai._genai.types.Prompt

Creates a new version of a prompt in a Vertex Dataset resource.

If config.prompt_id is not provided, this method creates a new Dataset resource for the prompt and a new Dataset Version resource under that Dataset. If config.prompt_id is provided, this method creates a new Dataset Version resource under the existing Dataset resource with the provided prompt_id.

When creating new Dataset and Dataset Version resources, this waits for the Dataset operations to complete before returning.

delete_prompt

delete_prompt(
    *,
    prompt_id: str,
    config: typing.Optional[vertexai._genai.types.DeletePromptConfig] = None
) -> None

Deletes a prompt resource.

Exceptions
Type Description
TimeoutError If the delete operation does not complete within the timeout.
ValueError If the delete operation fails.

delete_version

delete_version(
    *,
    prompt_id: str,
    version_id: str,
    config: typing.Optional[vertexai._genai.types.DeletePromptConfig] = None
) -> None

Deletes a prompt version resource.

Exceptions
Type Description
TimeoutError If the delete operation does not complete within the timeout.
ValueError If the delete operation fails.

get

get(
    *,
    prompt_id: str,
    config: typing.Optional[vertexai._genai.types.GetPromptConfig] = None
) -> vertexai._genai.types.Prompt

Gets a prompt resource from a Vertex Dataset.

list_prompts

list_prompts(
    *,
    config: typing.Optional[
        typing.Union[
            vertexai._genai.types.ListPromptsConfig,
            vertexai._genai.types.ListPromptsConfigDict,
        ]
    ] = None
) -> typing.AsyncIterator[vertexai._genai.types.PromptRef]

Lists prompt resources in a project.

This method retrieves all the prompts from the project provided in the vertexai.Client constructor and returns a list of prompt references containing the prompt_id and model for the prompt.

To get the full types.Prompt resource for a PromptRef after calling this method, use the get() method with the prompt_id as the prompt_id argument. Example usage:

prompt_refs = client.aio.prompt_management.list_prompts()
async for prompt_ref in prompt_refs:
  await client.prompt_management.get(prompt_id=prompt_ref.prompt_id)

list_versions

list_versions(
    *,
    prompt_id: str,
    config: typing.Optional[
        typing.Union[
            vertexai._genai.types.ListPromptsConfig,
            vertexai._genai.types.ListPromptsConfigDict,
        ]
    ] = None
) -> typing.AsyncIterator[vertexai._genai.types.PromptVersionRef]

Lists prompt version resources for a provided prompt_id.

This method retrieves all the prompt versions for a provided prompt_id.

To get the full types.Prompt resource for a PromptVersionRef after calling this method, use the get() method with the returned prompt_id and version_id. Example usage:

prompt_version_refs = await client.prompt_management.list_versions(prompt_id="123")
async for version_ref in prompt_version_refs:
  await client.aio.prompt_management.get(prompt_id=version_ref.prompt_id, version_id=version_ref.version_id)

restore_version

restore_version(
    *,
    prompt_id: str,
    version_id: str,
    config: typing.Optional[vertexai._genai.types.RestoreVersionConfig] = None
) -> vertexai._genai.types.Prompt

Restores the provided prompt version to the latest version.