Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 150 additions & 0 deletions .changeset/changelog.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
const {
getInfo,
getInfoFromPullRequest,
} = require("@changesets/get-github-info");
const { config } = require("dotenv");

config({ quiet: true });

function readEnv() {
return {
githubServerUrl: process.env.GITHUB_SERVER_URL || "https://github.com",
githubToken: process.env.GITHUB_TOKEN || "",
};
}

function getIgnoredAuthors(options) {
return new Set(options.ignoredAuthors.map((author) => author.toLowerCase()));
}

function normalizeSummary(summary) {
let prFromSummary;
let commitFromSummary;
const usersFromSummary = [];

const text = summary
.replace(/^\s*(?:pr|pull|pull\s+request):\s*#?(\d+)/gim, (_, pr) => {
const parsed = Number(pr);
if (!Number.isNaN(parsed)) {
prFromSummary = parsed;
}
return "";
})
.replace(/^\s*commit:\s*([^\s]+)/gim, (_, commit) => {
commitFromSummary = commit;
return "";
})
.replace(/^\s*(?:author|user):\s*@?([^\s]+)/gim, (_, user) => {
usersFromSummary.push(user);
return "";
})
.split("\n")
.map((line) => line.trim())
.filter(Boolean)
.join(" ");

return { text, prFromSummary, commitFromSummary, usersFromSummary };
}

function uniqueUsers(users) {
const seen = new Set();
const result = [];

for (const user of users) {
const normalized = user.toLowerCase();
if (seen.has(normalized)) {
continue;
}

seen.add(normalized);
result.push(normalized);
}

return result;
}

function formatThanks(users, ignoredAuthors) {
const externalUsers = uniqueUsers(users).filter(
(user) => !ignoredAuthors.has(user),
);

if (externalUsers.length === 0) {
return "";
}

return ` Thanks ${externalUsers.map((user) => `@${user}`).join(", ")}!`;
}

async function readGithubInfo({
repo,
prFromSummary,
commitFromSummary,
fallbackCommit,
canQueryGithub,
}) {
if (prFromSummary !== undefined) {
if (!canQueryGithub) {
return { pull: prFromSummary, user: null };
}

const info = await getInfoFromPullRequest({ repo, pull: prFromSummary });
return { pull: prFromSummary, user: info.user };
}

const commit = commitFromSummary || fallbackCommit;
if (!commit || !canQueryGithub) {
return { pull: null, user: null };
}

const info = await getInfo({ repo, commit });
return { pull: info.pull, user: info.user };
}

const changelogFunctions = {
async getReleaseLine(changeset, _type, options) {
if (!options?.repo) {
throw new Error(
'Please provide a repo to this changelog generator like this:\n"changelog": ["./.changeset/changelog.cjs", { "repo": "org/repo" }]',
);
}

const { githubServerUrl, githubToken } = readEnv();
const ignoredAuthors = getIgnoredAuthors(options);
const { text, prFromSummary, commitFromSummary, usersFromSummary } =
normalizeSummary(changeset.summary);

const info = await readGithubInfo({
repo: options.repo,
prFromSummary,
commitFromSummary,
fallbackCommit: changeset.commit,
canQueryGithub: Boolean(githubToken),
});

const users = usersFromSummary.length
? usersFromSummary
: info.user
? [info.user]
: [];
const thanks = formatThanks(users, ignoredAuthors);
const pullUrl = info.pull
? ` (${githubServerUrl}/${options.repo}/pull/${info.pull})`
: "";

return `- ${text}${thanks}${pullUrl}`;
},

async getDependencyReleaseLine(_changesets, dependenciesUpdated) {
if (dependenciesUpdated.length === 0) {
return "";
}

const dependencies = dependenciesUpdated
.map((dependency) => `${dependency.name}@${dependency.newVersion}`)
.sort((left, right) => left.localeCompare(right));

return `- Updated dependencies: ${dependencies.join(", ")}`;
},
};

module.exports = changelogFunctions;
5 changes: 3 additions & 2 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"$schema": "https://unpkg.com/@changesets/config/schema.json",
"changelog": [
"@changesets/changelog-github",
"./.changeset/changelog.cjs",
{
"repo": "braintrustdata/braintrust-sdk-javascript"
"repo": "braintrustdata/braintrust-sdk-javascript",
"ignoredAuthors": ["abhiprasad", "lforst", "qard"]
}
],
"commit": false,
Expand Down
5 changes: 0 additions & 5 deletions .changeset/fluffy-games-build.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/grumpy-mangos-drum.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/lazy-dots-send.md

This file was deleted.

21 changes: 0 additions & 21 deletions .changeset/little-webs-hang.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/ninety-windows-act.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/slimy-bars-cheer.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/strong-walls-serve.md

This file was deleted.

10 changes: 5 additions & 5 deletions .github/workflows/publish-js-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ jobs:
with:
mode: prerelease
checkout_ref: ${{ inputs.branch || github.ref_name }}
version_command: pnpm exec changeset version --snapshot rc
version_command: pnpm run changeset:version -- --snapshot rc
publish_enabled: true
publish_command: pnpm exec changeset publish --tag rc --no-git-tag
slack_text: "🧪 JavaScript prerelease snapshots published"
Expand All @@ -213,7 +213,7 @@ jobs:
with:
mode: canary
checkout_ref: ${{ github.ref_name }}
version_command: pnpm exec changeset version --snapshot canary
version_command: pnpm run changeset:version -- --snapshot canary
publish_enabled: true
publish_command: pnpm exec changeset publish --tag canary --no-git-tag
run_canary_check: true
Expand All @@ -234,7 +234,7 @@ jobs:
with:
mode: dry-run-canary
checkout_ref: ${{ inputs.ref || 'main' }}
version_command: pnpm exec changeset version --snapshot canary
version_command: pnpm run changeset:version -- --snapshot canary
artifact_dir: artifacts/dry-run-canary
artifact_name: canary-dry-run-${{ github.run_id }}

Expand All @@ -249,7 +249,7 @@ jobs:
with:
mode: dry-run-stable
checkout_ref: ${{ inputs.ref || 'main' }}
version_command: pnpm exec changeset version && pnpm install --lockfile-only
version_command: pnpm run changeset:version:lockfile
artifact_dir: artifacts/dry-run-stable
artifact_name: stable-dry-run-${{ github.run_id }}

Expand All @@ -264,7 +264,7 @@ jobs:
with:
mode: dry-run-prerelease
checkout_ref: ${{ inputs.branch || github.ref_name }}
version_command: pnpm exec changeset version --snapshot rc
version_command: pnpm run changeset:version -- --snapshot rc
artifact_dir: artifacts/dry-run-prerelease
artifact_name: prerelease-dry-run-${{ github.run_id }}

Expand Down
26 changes: 26 additions & 0 deletions js/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# braintrust

## 3.9.0

### Notable Changes

- feat: Add instrumentation for `@huggingface/inference` ([#1807](https://github.com/braintrustdata/braintrust-sdk-javascript/issues/1807))
- feat: Add `cohere-ai` instrumentation ([#1781](https://github.com/braintrustdata/braintrust-sdk-javascript/issues/1781))
- feat: Add reranking instrumentation for AI SDK and Openrouter SDK [#1824](https://github.com/braintrustdata/braintrust-sdk-javascript/pull/1824)
- feat: Instrument Google GenAI `embedContent` for text ([#1821](https://github.com/braintrustdata/braintrust-sdk-javascript/pull/1821))

### Other Changes

- feat: Capture grounding metadata for Google GenAI ([#1773](https://github.com/braintrustdata/braintrust-sdk-javascript/issues/1773))
- feat: Track server tool use metrics for anthropic SDK ([#1772](https://github.com/braintrustdata/braintrust-sdk-javascript/issues/1772))
- feat: Add per-input `trialCount` support to `Eval()` ([#1814](https://github.com/braintrustdata/braintrust-sdk-javascript/pull/1814))
- feat(claude-agent-sdk): Improve task lifecycle and lifecycle details ([#1777](https://github.com/braintrustdata/braintrust-sdk-javascript/issues/1777))
- feat: Add `x-bt-use-gateway` header to allowed CORS headers ([#1836](https://github.com/braintrustdata/braintrust-sdk-javascript/pull/1836))
- perf: Remove `zod` from `deepCopyEvent` ([#1796](https://github.com/braintrustdata/braintrust-sdk-javascript/issues/1796))
- fix(auto-instrumentation): Use sync channel for AI SDK CJS `streamText`/`streamObject` in v4+ ([#1768](https://github.com/braintrustdata/braintrust-sdk-javascript/issues/1768))
- fix: Give AI SDK top-level api spans type function ([#1769](https://github.com/braintrustdata/braintrust-sdk-javascript/issues/1769))
- fix(openai): Collect `logprob` and `refulsals` output for streaming APIs ([#1774](https://github.com/braintrustdata/braintrust-sdk-javascript/issues/1774))
- fix(claude-agent-sdk): Don't drop tool spans for spawning subagents ([#1779](https://github.com/braintrustdata/braintrust-sdk-javascript/issues/1779))
- fix: Capture anthropic server tool use inputs for streaming APIs ([#1776](https://github.com/braintrustdata/braintrust-sdk-javascript/issues/1776))
- fix(ai-sdk): Restore prompt cache metrics ([#1825](https://github.com/braintrustdata/braintrust-sdk-javascript/pull/1825))
- fix(openai-agents): End child spans on trace end ([#1813](https://github.com/braintrustdata/braintrust-sdk-javascript/pull/1813))
- chore(auto-instrumentation): Upgrade `@apm-js-collab/code-transformer` to v0.12.0 ([#1708](https://github.com/braintrustdata/braintrust-sdk-javascript/issues/1708))

## 3.7.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "braintrust",
"version": "3.8.0",
"version": "3.9.0",
"description": "SDK for integrating Braintrust",
"repository": {
"type": "git",
Expand Down
1 change: 1 addition & 0 deletions knip.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"$schema": "node_modules/knip/schema-jsonc.json",
"include": ["files", "exports"],
"ignoreFiles": [
".changeset/changelog.cjs",
"integrations/otel-js/otel-v1/**",
"integrations/otel-js/otel-v2/**",
"integrations/val.town/vals/tutorial/code.ts",
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"test:e2e:update": "turbo run test:e2e:update",
"changeset": "changeset",
"changeset:status": "changeset status",
"changeset:version": "changeset version",
"changeset:version:lockfile": "changeset version && pnpm install --lockfile-only",
"changeset:version": "node scripts/release/run-changeset-version.mjs",
"changeset:version:lockfile": "node scripts/release/run-changeset-version.mjs && pnpm install --lockfile-only",
"playground": "turbo run playground --filter=\"braintrust\"",
"playground:cli:push": "turbo run playground:cli:push --filter=\"braintrust\"",
"playground:cli:eval": "turbo run playground:cli:eval --filter=\"braintrust\"",
Expand All @@ -46,6 +46,8 @@
"devDependencies": {
"@changesets/changelog-github": "^0.6.0",
"@changesets/cli": "^2.30.0",
"@changesets/get-github-info": "^0.8.0",
"dotenv": "^17.2.3",
"eslint": "^9.39.2",
"husky": "^9.1.7",
"knip": "^5.85.0",
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading