Skip to content

Conversation

@CLowbrow
Copy link
Contributor

@CLowbrow CLowbrow commented Jan 6, 2026

Test script:

import * as braintrust from "braintrust";
const prompt = await braintrust.loadPrompt({
  projectName: "Alex-Test-Project",
  slug: "my-prompt-433b",
});
const envs = await prompt.listPromptEnvironments();
await prompt.setPromptEnvironment({
  environmentSlug: "prod",
  version: "e8c5947221ac78b9",
});
await prompt.clearPromptEnvironment({ environmentSlug: "prod" });

@CLowbrow CLowbrow marked this pull request as ready for review January 7, 2026 22:08
Copy link
Collaborator

@ibolmo ibolmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a comment on dx and another on error handling

public listPromptEnvironments(
options: ListPromptEnvironmentsOptions,
): Promise<PromptEnvironmentAssociation[]> {
return listPromptEnvironments(options);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd expect an Environments class with a list, set, clear.

something like

prompt.environments.list() and so on

This would follow existing prompt.project etc.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd imagine this environment class would be used in logger instead of the function based approach

return id;
}

public listPromptEnvironments(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure i'd expect these methods here if the framework2 already has this. 🤔

if we want to keep them would imagine something like:

getEnvironments()
setEnvironments()
clearEnvironments()

(Prompt seemed duplicative)

forceLogin,
});

const response = await state
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing try catch? perhaps better error message

orgName ? { org_name: orgName } : {},
);

return (response.objects ?? []) as PromptEnvironmentAssociation[];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would this hide an upstream error?


// Use PUT for upsert behavior - need to use state.fetch since HTTPConnection doesn't have put method
const apiConn = state.apiConn();
const url = `${apiConn.base_url}/environment-object/prompt/${promptId}/${environmentSlug}`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we just fix this at the apiConn level? i.e. add a put_json()

const apiConn = state.apiConn();
const queryString = orgName ? `?org_name=${encodeURIComponent(orgName)}` : "";
const url = `${apiConn.base_url}/environment-object/prompt/${promptId}/${environmentSlug}${queryString}`;
const resp = await state.fetch(url, {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants