You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -4099,6 +4101,7 @@ export type LoadParametersByProjectIdWithEnvOptions =
4099
4101
projectId: string;
4100
4102
slug: string;
4101
4103
environment: string;
4104
+
version?: string;
4102
4105
};
4103
4106
4104
4107
exporttypeLoadParametersOptions=
@@ -4126,7 +4129,7 @@ type LoadParametersImplementationOptions = LoadParametersBaseOptions & {
4126
4129
* @param options.projectId The id of the project to load the prompt from. This takes precedence over `projectName` if specified.
4127
4130
* @param options.slug The slug of the prompt to load.
4128
4131
* @param options.version An optional version of the prompt (to read). If not specified, the latest version will be used.
4129
-
* @param options.environment Fetch the version of the prompt assigned to the specified environment (e.g. "production", "staging"). Cannot be specified at the same time as `version`.
4132
+
* @param options.environment Fetch the version of the prompt assigned to the specified environment (e.g. "production", "staging"). If both `version` and `environment` are provided, `version` takes precedence.
4130
4133
* @param options.id The id of a specific prompt to load. If specified, this takes precedence over all other parameters (project and slug).
4131
4134
* @param options.defaults (Optional) A dictionary of default values to use when rendering the prompt. Prompt values will override these defaults.
4132
4135
* @param options.noTrace If true, do not include logging metadata for this prompt when build() is called.
@@ -4162,11 +4165,11 @@ export async function loadPrompt({
4162
4165
forceLogin,
4163
4166
state: stateArg,
4164
4167
}: LoadPromptOptions){
4165
-
if(version&&environment){
4166
-
thrownewError(
4167
-
"Cannot specify both 'version' and 'environment' parameters. Please use only one (remove the other).",
4168
-
);
4169
-
}
4168
+
constversionOrEnvironment=version
4169
+
? { version }
4170
+
: environment
4171
+
? { environment }
4172
+
: {};
4170
4173
if(id){
4171
4174
// When loading by ID, we don't need project or slug
// Wrap single prompt response in objects array to match list API format
4195
4197
if(response){
4196
4198
response={objects: [response]};
@@ -4200,13 +4202,12 @@ export async function loadPrompt({
4200
4202
project_name: projectName,
4201
4203
project_id: projectId,
4202
4204
slug,
4203
-
version,
4204
-
...(environment&&{ environment }),
4205
+
...versionOrEnvironment,
4205
4206
});
4206
4207
}
4207
4208
}catch(e){
4208
4209
// If environment or version was specified, don't fall back to cache
4209
-
if(environment||version){
4210
+
if(versionOrEnvironment){
4210
4211
thrownewError(`Prompt not found with specified parameters: ${e}`);
4211
4212
}
4212
4213
@@ -4286,7 +4287,7 @@ export async function loadPrompt({
4286
4287
* @param options.projectId The id of the project to load the parameters from. This takes precedence over `projectName` if specified.
4287
4288
* @param options.slug The slug of the parameters to load.
4288
4289
* @param options.version An optional version of the parameters (to read). If not specified, the latest version will be used.
4289
-
* @param options.environment Fetch the version of the parameters assigned to the specified environment (e.g. "production", "staging"). Cannot be specified at the same time as `version`.
4290
+
* @param options.environment Fetch the version of the parameters assigned to the specified environment (e.g. "production", "staging"). If both `version` and `environment` are provided, `version` takes precedence.
4290
4291
* @param options.id The id of specific parameters to load. If specified, this takes precedence over all other parameters (project and slug).
4291
4292
* @param options.appUrl The URL of the Braintrust App. Defaults to https://www.braintrust.dev.
4292
4293
* @param options.apiKey The API key to use. If the parameter is not specified, will try to use the `BRAINTRUST_API_KEY` environment variable.
@@ -4339,11 +4340,15 @@ export async function loadParameters<
0 commit comments