Repository navigation
ci: add Braintrust evals GitHub Action workflow #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sweetmantech
merged 15 commits into
test
from
sweetmantech/myc-3988-evals-move-to-recoup-api-repo
Jan 21, 2026
+2,802
−34
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
cbe75cc
ci: add Braintrust evals GitHub Action workflow
sweetmantech 66859d5
fix: add permissions for eval-action to post PR comments
sweetmantech 403c7c2
feat: migrate evals from Recoup-Chat to Recoup-API
sweetmantech 405c95c
chore: update pnpm-lock.yaml with new dependencies
sweetmantech 22a54a1
fix: add missing dependencies for evals
sweetmantech 6ef962f
fix: correct ChatRequestBody property names in eval
sweetmantech e3c2d25
fix: add PRIVY_PROJECT_SECRET env var to evals workflow
sweetmantech d388bab
refactor: move env vars to job level in evals workflow
sweetmantech b27d31b
fix: add external packages and env vars for evals
sweetmantech 0f9c740
fix: run pnpm eval directly instead of using eval-action
sweetmantech 3b95753
fix: make Composio client lazy-loaded to fix braintrust bundling
sweetmantech c753315
fix: add paths and package_manager to eval-action
sweetmantech 479680f
fix: add SUPABASE_URL and SUPABASE_KEY env vars to evals
sweetmantech d398fdf
fix: gracefully skip Composio tools when unavailable
sweetmantech ee8d420
fix: remove COMPOSIO_API_KEY from evals workflow
sweetmantech File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| name: Evals | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main, test] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| evals: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 11 | ||
| env: | ||
| PRIVY_PROJECT_SECRET: ${{ secrets.PRIVY_PROJECT_SECRET }} | ||
| # Note: COMPOSIO_API_KEY intentionally omitted - @composio packages | ||
| # are incompatible with Braintrust's bundler (createRequire issue) | ||
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | ||
| AI_GATEWAY_API_KEY: ${{ secrets.AI_GATEWAY_API_KEY }} | ||
| SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | ||
| SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }} | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "20" | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 9 | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install | ||
|
|
||
| - name: Run Evals | ||
| uses: braintrustdata/eval-action@v1 | ||
| with: | ||
| api_key: ${{ secrets.BRAINTRUST_API_KEY }} | ||
| runtime: node | ||
| paths: "evals/" | ||
| package_manager: pnpm | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Recoup Evaluation System | ||
|
|
||
| This directory contains our **Braintrust-based evaluation framework** for testing and improving our AI systems. | ||
|
|
||
| ## 🚀 Quick Start | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - Node.js >= 18 | ||
| - Braintrust API key in `.env` file: `BRAINTRUST_API_KEY=your_key_here` | ||
|
|
||
| ### Running Evaluations | ||
|
|
||
| ```bash | ||
| # Run all evaluation scripts | ||
| pnpm eval | ||
|
|
||
| # Run specific evaluation | ||
| pnpm eval evals/first-week-album-sales.eval.ts | ||
|
|
||
| # Or use npx directly with external packages flag | ||
| npx braintrust eval --external-packages playwright playwright-core chromium-bidi @browserbasehq/stagehand | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| import { Eval } from "braintrust"; | ||
| import { callChatFunctions } from "@/lib/evals"; | ||
| import { CatalogAvailability } from "@/lib/evals/scorers/CatalogAvailability"; | ||
|
|
||
| /** | ||
| * Catalog Opportunity Analysis Evaluation | ||
| * | ||
| * This evaluation tests whether the AI system can effectively analyze catalog opportunities | ||
| * and provide relevant song recommendations for specific use cases like playlists, sync opportunities, | ||
| * or thematic collections. It focuses on the system's ability to understand context and suggest | ||
| * appropriate songs from the catalog. | ||
| * | ||
| * Run: npx braintrust eval evals/catalog-opportunity-analysis.eval.ts | ||
| */ | ||
|
|
||
| const expected = `Here are some great Halloween-themed songs perfect for a Peloton Halloween playlist: | ||
| - Lord Infamous & II-Tone - "Helloween" | ||
| - th1rt3en & Pharoahe Monch – "The Exorcist" | ||
| - DC The Don – "Zombieland" | ||
| - DC The Don – "Freddy Krueger" | ||
|
|
||
| These songs provide the perfect spooky atmosphere while maintaining the high-energy vibe needed for Peloton workouts. The mix includes both classic Halloween hits and darker, more intense tracks that will keep riders motivated during their Halloween-themed rides.`; | ||
|
|
||
| Eval("Catalog Opportunity Analysis Evaluation", { | ||
| data: () => [ | ||
| { | ||
| input: "Peloton needs songs for a Halloween playlist", | ||
| expected, | ||
| metadata: { | ||
| category: "playlist_recommendation", | ||
| use_case: "peloton_halloween", | ||
| expected_tool_usage: true, | ||
| data_type: "catalog_analysis", | ||
| requires_web_search: true, | ||
| target_platform: "peloton", | ||
| theme: "halloween", | ||
| }, | ||
| }, | ||
| { | ||
| input: "Brands need Christmas Songs for Sync", | ||
| expected, | ||
| metadata: { | ||
| category: "sync_licensing", | ||
| use_case: "brand_christmas_sync", | ||
| expected_tool_usage: true, | ||
| data_type: "catalog_analysis", | ||
| requires_web_search: true, | ||
| target_platform: "brand_sync", | ||
| theme: "christmas", | ||
| }, | ||
| }, | ||
| { | ||
| input: "Spotify needs songs for a LGBTQ+ Valentines Mix", | ||
| expected, | ||
| metadata: { | ||
| category: "playlist_recommendation", | ||
| use_case: "spotify_lgbtq_valentines", | ||
| expected_tool_usage: true, | ||
| data_type: "catalog_analysis", | ||
| requires_web_search: true, | ||
| target_platform: "spotify", | ||
| theme: "lgbtq_valentines", | ||
| }, | ||
| }, | ||
| { | ||
| input: "Spotify needs songs for Black History Month", | ||
| expected, | ||
| metadata: { | ||
| category: "playlist_recommendation", | ||
| use_case: "spotify_black_history_month", | ||
| expected_tool_usage: true, | ||
| data_type: "catalog_analysis", | ||
| requires_web_search: true, | ||
| target_platform: "spotify", | ||
| theme: "black_history_month", | ||
| }, | ||
| }, | ||
| { | ||
| input: "Apple needs songs for International Women's Day", | ||
| expected, | ||
| metadata: { | ||
| category: "playlist_recommendation", | ||
| use_case: "apple_international_womens_day", | ||
| expected_tool_usage: true, | ||
| data_type: "catalog_analysis", | ||
| requires_web_search: true, | ||
| target_platform: "apple", | ||
| theme: "international_womens_day", | ||
| }, | ||
| }, | ||
| ], | ||
|
|
||
| task: async (input: string): Promise<string> => { | ||
| try { | ||
| const response = await callChatFunctions(input); | ||
| return response; | ||
| } catch (error) { | ||
| return `Error: ${error instanceof Error ? error.message : "Function call failed"}`; | ||
| } | ||
| }, | ||
|
|
||
| scores: [CatalogAvailability], | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { Eval } from "braintrust"; | ||
| import { Factuality, AnswerCorrectness } from "autoevals"; | ||
| import { | ||
| callChatFunctionsWithResult, | ||
| extractTextFromResult, | ||
| } from "@/lib/evals"; | ||
| import getCatalogSongsCountData from "@/lib/evals/getCatalogSongsCountData"; | ||
|
|
||
| /** | ||
| * Catalog Songs Count Evaluation | ||
| * | ||
| * This evaluation tests whether your AI system properly uses tool calls | ||
| * to fetch catalog data and return accurate song counts instead of defaulting | ||
| * to "I don't have access" responses. | ||
| * | ||
| * Run: npx braintrust eval evals/catalog-songs-count.eval.ts | ||
| */ | ||
| Eval("Catalog Songs Count Evaluation", { | ||
| data: getCatalogSongsCountData, | ||
| task: async (input: string): Promise<string> => { | ||
| try { | ||
| const response = await callChatFunctionsWithResult(input); | ||
| const output = extractTextFromResult(response); | ||
| return output; | ||
| } catch (error) { | ||
| return `Error: ${error instanceof Error ? error.message : "Function call failed"}`; | ||
| } | ||
| }, | ||
|
|
||
| scores: [AnswerCorrectness, Factuality], | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| import { Eval } from "braintrust"; | ||
| import { Factuality } from "autoevals"; | ||
| import { callChatFunctions } from "@/lib/evals"; | ||
|
|
||
| /** | ||
| * Album Sales Tool Call Evaluation | ||
| * | ||
| * This evaluation tests whether your AI system properly uses tool calls | ||
| * to fetch album sales data instead of defaulting to "I don't have access" responses. | ||
| * | ||
| * Run: npx braintrust eval evals/first-week-album-sales.eval.ts | ||
| */ | ||
|
|
||
| Eval("First Week Album Sales Evaluation", { | ||
| data: () => [ | ||
| { | ||
| input: | ||
| "how many albums did Halsey The Great Impersonator sell the first week of release", | ||
| expected: | ||
| "Halsey's album 'The Great Impersonator' sold between 93,000 and 100,000 copies in its first week of release. It debuted at No. 2 on the Billboard 200 chart.", | ||
| metadata: { | ||
| artist: "Halsey", | ||
| album: "The Great Impersonator", | ||
| expected_tool_usage: true, | ||
| data_type: "first_week_album_sales", | ||
| }, | ||
| }, | ||
| { | ||
| input: | ||
| "what were the first week sales for Taylor Swift's Midnights album?", | ||
| expected: | ||
| "Taylor Swift's Midnights sold 1.578 million equivalent album units in its first week in the United States, which included between 1 million and 1.5 million pure album sales. This marked the biggest sales week for any album since Adele's 25 in 2015 and the best sales week for a vinyl album in the modern tracking era.", | ||
| metadata: { | ||
| artist: "Taylor Swift", | ||
| album: "Midnights", | ||
| expected_tool_usage: true, | ||
| data_type: "first_week_album_sales", | ||
| }, | ||
| }, | ||
| { | ||
| input: | ||
| "how many copies did Drake's Certified Lover Boy sell in the first week", | ||
| expected: | ||
| "Drake's 'Certified Lover Boy' sold approximately 613,000 album-equivalent units in its first week, securing the #1 spot on the Billboard 200 chart.", | ||
| metadata: { | ||
| artist: "Drake", | ||
| album: "Certified Lover Boy", | ||
| expected_tool_usage: true, | ||
| data_type: "first_week_album_sales", | ||
| }, | ||
| }, | ||
| { | ||
| input: | ||
| "what are the first week streaming numbers for Bad Bunny's Un Verano Sin Ti", | ||
| expected: | ||
| "In its first week of release in the United States, Bad Bunny's album Un Verano Sin Ti garnered over 355 million on-demand streams and 274,000 album-equivalent units, the most for any album that year and the largest streaming week for a Latin album ever at that time. The album also set a record for the biggest debut for a Latin album in Spotify's history.", | ||
| metadata: { | ||
| artist: "Bad Bunny", | ||
| album: "Un Verano Sin Ti", | ||
| expected_tool_usage: true, | ||
| data_type: "first_week_streaming_numbers", | ||
| }, | ||
| }, | ||
| ], | ||
|
|
||
| task: async (input: string): Promise<string> => { | ||
| try { | ||
| const response = await callChatFunctions(input); | ||
| return response; | ||
| } catch (error) { | ||
| return `Error: ${error instanceof Error ? error.message : "Function call failed"}`; | ||
| } | ||
| }, | ||
|
|
||
| scores: [Factuality], | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import { Eval } from "braintrust"; | ||
| import { | ||
| callChatFunctionsWithResult, | ||
| extractTextFromResult, | ||
| createToolsCalledScorer, | ||
| } from "@/lib/evals"; | ||
|
|
||
| /** | ||
| * Memory & Storage Tools Evaluation | ||
| * | ||
| * This evaluation tests whether the AI properly uses memory/storage tools when | ||
| * asked to save information. The AI should: | ||
| * 1. Use write_file to save to artist's file storage | ||
| * 2. Use create_knowledge_base to save to artist's knowledge base | ||
| * 3. NOT just use generate_txt_file (which doesn't persist properly) | ||
| * 4. Keep saved content concise with high signal, low noise | ||
| * | ||
| * Test cases: | ||
| * - "Can I save all this info somewhere?" - Should use write_file or create_knowledge_base | ||
| * | ||
| * Required Tools: write_file, create_knowledge_base | ||
| * Penalized Tools: generate_txt_file (when used alone without write_file) | ||
| * | ||
| * Run: npx braintrust eval evals/memory-tools.eval.ts | ||
| */ | ||
|
|
||
| const REQUIRED_TOOLS = ["write_file", "create_knowledge_base"]; | ||
|
|
||
| const PENALIZED_TOOLS = ["generate_txt_file"]; | ||
|
|
||
| Eval("Memory & Storage Tools Evaluation", { | ||
| data: () => [ | ||
| { | ||
| input: "Can I save all this info somewhere?", | ||
| expected: | ||
| "Confirmation that info was saved using write_file or create_knowledge_base (not just generate_txt_file)", | ||
| metadata: { | ||
| artist: "Unknown", | ||
| platform: "n/a", | ||
| request_type: "save_information", | ||
| expected_tool_usage: true, | ||
| requiredTools: REQUIRED_TOOLS, | ||
| penalizedTools: PENALIZED_TOOLS, | ||
| }, | ||
| }, | ||
| ], | ||
|
|
||
| task: async (input: string) => { | ||
| try { | ||
| const result = await callChatFunctionsWithResult(input); | ||
| const output = extractTextFromResult(result); | ||
| const toolCalls = | ||
| result.toolCalls?.map((tc) => ({ | ||
| toolName: tc.toolName, | ||
| args: {}, | ||
| })) || []; | ||
|
|
||
| return { output, toolCalls }; | ||
| } catch (error) { | ||
| return { | ||
| output: `Error: ${error instanceof Error ? error.message : "Function call failed"}`, | ||
| toolCalls: [], | ||
| }; | ||
| } | ||
| }, | ||
|
|
||
| scores: [createToolsCalledScorer(REQUIRED_TOOLS, PENALIZED_TOOLS)], | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import { Eval } from "braintrust"; | ||
| import { AnswerSimilarity } from "autoevals"; | ||
| import { callChatFunctions } from "@/lib/evals"; | ||
| import { EVAL_ARTISTS } from "@/lib/consts"; | ||
| import { getDynamicDates } from "@/lib/evals/getMonthlyListenersDates"; | ||
|
|
||
| /** | ||
| * Monthly Listeners Tracking Evaluation | ||
| * | ||
| * This evaluation tests whether Recoup properly sets up monthly listener reporting | ||
| * for artists when users request tracking data between specific dates. | ||
| * | ||
| * Run: npx braintrust eval evals/monthly-listeners-tracking.eval.ts | ||
| */ | ||
| Eval("Monthly Listeners Tracking Evaluation", { | ||
| data: () => { | ||
| const { startDateFormatted, endDateFormatted } = getDynamicDates(); | ||
|
|
||
| const testCases = EVAL_ARTISTS.map((artist) => ({ | ||
| input: `what is the increase for ${artist} monthlies from ${startDateFormatted} to ${endDateFormatted}`, | ||
| expected: `I've set up a monthlies tracking for ${artist}. would you like to receive the updated list in your email?`, | ||
| metadata: { | ||
| artist, | ||
| start_date: startDateFormatted, | ||
| end_date: endDateFormatted, | ||
| expected_tool_usage: true, | ||
| data_type: "monthly_listeners_tracking", | ||
| tracking_setup: true, | ||
| }, | ||
| })); | ||
|
|
||
| return testCases; | ||
| }, | ||
|
|
||
| task: async (input: string): Promise<string> => { | ||
| try { | ||
| const response = await callChatFunctions(input); | ||
| return response; | ||
| } catch (error) { | ||
| return `Error: ${error instanceof Error ? error.message : "Function call failed"}`; | ||
| } | ||
| }, | ||
|
|
||
| scores: [AnswerSimilarity], | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.