Skip to main content
Track, version, and manage your AI prompts in the W&B Registry by linking Weave prompt objects to a collection. Linking a prompt object to a collection moves the prompt version from a private, project-level scope to a shared, organization-level scope.
Before you start, check the following:
  • The object types that collection permits. For more information about collection types, see “Collection types” within Create a collection.
  • The registry that the collection belongs to already exists. To check that the registry exists, navigate to the Registry App and search for the name of the registry.
To track and manage your AI prompts, use the Weave Python SDK. The Weave Python SDK enables you to create, publish, and link prompt objects to a collection in a registry. The following steps outline how to link a prompt to a collection in a registry:
  1. Initialize a Weave client with weave.init().
  2. Create a Weave prompt object with a built-in prompt class such as weave.StringPrompt().
    weave.StringPrompt is a built-in prompt class for single-string prompts, such as a system prompt, user prompt, or reusable text template. For more information about creating prompt objects in Weave, and supported prompt types, see Create prompt objects.
  3. Publish the prompt to Weave with weave.publish().
  4. Link the published prompt version to a collection in a registry with weave_client.link_prompt_to_registry(). Pass the destination collection path to the target_path parameter. The path consists of the wandb-registry- prefix, the registry name, and the collection name:
Copy and paste the following code snippet into your Python script, replacing the placeholder values enclosed in <> with your own:

View linked prompts in a registry

  1. Navigate to the W&B Registry.
  2. Select the name of the registry that you linked the prompt to.
  3. Select the name of the collection.
  4. From the list of prompt versions, select the version you want to access. Version numbers are incrementally assigned to each linked prompt version starting with v0.
  5. To view details about a prompt version, click the version. From the tabs in this page, you can view that version’s overview, prompt, and use.

Use a prompt linked to a registry

Use the weave.get() method to retrieve a prompt object linked to a registry. You can fetch a prompt by its alias or version number. The following code snippet shows how to fetch a prompt by its alias and version number. To fetch a prompt object by its alias, use the following URI path:
Replace the placeholder values enclosed in <> with your own:
W&B autogenerates the URI path and sample code to fetch your prompt object. To view the sample code:
  1. Navigate to the W&B Registry.
  2. Select the name of the registry that you linked the prompt to.
  3. Select the name of the collection.
  4. From the list of prompt versions, select the version you want to access.
  5. Select the Use tab to view the sample code to fetch your prompt by alias or version number.