diff --git a/.changeset/tidy-facts-admire.md b/.changeset/tidy-facts-admire.md new file mode 100644 index 000000000..c6414190a --- /dev/null +++ b/.changeset/tidy-facts-admire.md @@ -0,0 +1,5 @@ +--- +"braintrust": minor +--- + +feat(invoke): Allow passing `overrides` to `invoke()` diff --git a/js/src/functions/invoke.ts b/js/src/functions/invoke.ts index d56754d68..f7bbb35f5 100644 --- a/js/src/functions/invoke.ts +++ b/js/src/functions/invoke.ts @@ -111,6 +111,13 @@ export interface InvokeFunctionArgs< * if the variable names in the prompt do not match the input keys. */ strict?: boolean; + /** + * Per-call deep-merge into the resolved function data server-side. Useful for facet, + * code, global, and remote_eval functions (for example, overriding a facet's `model` + * or a global function's `config`). Has no effect on prompt functions, whose + * parameters live on a separate field that the override path does not touch. + */ + overrides?: Record; /** * A Zod schema to validate the output of the function and return a typed value. This * is only used if `stream` is false. @@ -159,6 +166,7 @@ export async function invoke( mode, schema, strict, + overrides, projectId, ...functionIdArgs } = args; @@ -204,6 +212,7 @@ export async function invoke( stream, mode, strict, + overrides, }; const headers: Record = {