From 40a4276125f5ae0064e988fd56d7208692321506 Mon Sep 17 00:00:00 2001 From: jacob-buster Date: Fri, 18 Jul 2025 14:11:23 -0600 Subject: [PATCH] Added setup script + few new changes to address {{variable}} issues --- package.json | 1 + .../analyst-agent-instructions.ts | 1 + .../think-and-prep-instructions.ts | 1 + packages/database/package.json | 2 +- scripts/setup.sh | 78 +++++++++++++++++++ 5 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 scripts/setup.sh diff --git a/package.json b/package.json index 82307b8d5..f4ecb9ddd 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "format:fix": "biome format --write ${1:-.}", "lint": "turbo lint", "new:package": "bun run scripts/new-package.ts", + "setup": "bash scripts/setup.sh", "test": "dotenv -e .env -- turbo test", "test:unit": "dotenv -e .env -- turbo run test:unit", "test:integration": "dotenv -e .env -- turbo run test:integration", diff --git a/packages/ai/src/agents/analyst-agent/analyst-agent-instructions.ts b/packages/ai/src/agents/analyst-agent/analyst-agent-instructions.ts index db7a335cb..d2c656fb3 100644 --- a/packages/ai/src/agents/analyst-agent/analyst-agent-instructions.ts +++ b/packages/ai/src/agents/analyst-agent/analyst-agent-instructions.ts @@ -181,6 +181,7 @@ ${params.sqlDialectGuidance} - Use explicit ordering for custom buckets or categories. - Avoid division by zero errors by using NULLIF() or CASE statements (e.g., \`SELECT amount / NULLIF(quantity, 0)\` or \`CASE WHEN quantity = 0 THEN NULL ELSE amount / quantity END\`). - Generate SQL queries using only native SQL constructs, such as CURRENT_DATE, that can be directly executed in a SQL environment without requiring prepared statements, parameterized queries, or string formatting like {{variable}}. + - You are not able to build interactive dashboards and metrics that allow users to change the filters, you can only build static dashboards and metrics. - Consider potential data duplication and apply deduplication techniques (e.g., \`DISTINCT\`, \`GROUP BY\`) where necessary. - Fill Missing Values: For metrics, especially in time series, fill potentially missing values (NULLs) using \`COALESCE(, 0)\` to default them to zero, ensuring continuous data unless the user specifically requests otherwise. - Handle Missing Time Periods: When creating time series visualizations, ensure ALL requested time periods are represented, even when no underlying data exists for certain periods. This is critical for avoiding confusing gaps in charts and tables. diff --git a/packages/ai/src/agents/think-and-prep-agent/think-and-prep-instructions.ts b/packages/ai/src/agents/think-and-prep-agent/think-and-prep-instructions.ts index dbba93d8b..f81cbbad6 100644 --- a/packages/ai/src/agents/think-and-prep-agent/think-and-prep-instructions.ts +++ b/packages/ai/src/agents/think-and-prep-agent/think-and-prep-instructions.ts @@ -400,6 +400,7 @@ ${params.sqlDialectGuidance} - Use explicit ordering for custom buckets or categories. - Avoid division by zero errors by using NULLIF() or CASE statements (e.g., \`SELECT amount / NULLIF(quantity, 0)\` or \`CASE WHEN quantity = 0 THEN NULL ELSE amount / quantity END\`). - Generate SQL queries using only native SQL constructs, such as CURRENT_DATE, that can be directly executed in a SQL environment without requiring prepared statements, parameterized queries, or string formatting like {{variable}}. + - You are not able to build interactive dashboards and metrics that allow users to change the filters, you can only build static dashboards and metrics. - Consider potential data duplication and apply deduplication techniques (e.g., \`DISTINCT\`, \`GROUP BY\`) where necessary. - Fill Missing Values: For metrics, especially in time series, fill potentially missing values (NULLs) using \`COALESCE(, 0)\` to default them to zero, ensuring continuous data unless the user specifically requests otherwise. - Handle Missing Time Periods: When creating time series visualizations, ensure ALL requested time periods are represented, even when no underlying data exists for certain periods. This is critical for avoiding confusing gaps in charts and tables. diff --git a/packages/database/package.json b/packages/database/package.json index 345b3c19e..859b88f8f 100644 --- a/packages/database/package.json +++ b/packages/database/package.json @@ -31,7 +31,7 @@ "db:pull": "drizzle-kit pull", "db:push": "drizzle-kit push", "db:reset": "supabase db reset", - "db:seed": "pnpm run scripts/setup-db.ts && pnpm run scripts/seed.ts", + "db:seed": "bun run scripts/setup-db.ts && bun run scripts/seed.ts", "db:start-supabase": "supabase start", "db:stop": "supabase stop", "db:studio": "drizzle-kit studio", diff --git a/scripts/setup.sh b/scripts/setup.sh new file mode 100644 index 000000000..6d93afdce --- /dev/null +++ b/scripts/setup.sh @@ -0,0 +1,78 @@ +#!/bin/bash + +#You need to have docker installed and running to use this script +# https://www.docker.com/ + + +# Check current git branch +current_branch=$(git rev-parse --abbrev-ref HEAD) + +if [ "$current_branch" != "staging" ]; then + echo "It is best to do this in staging. Would you like to move to staging? (Y/N)" + read -r response + if [ "$response" = "Y" ] || [ "$response" = "y" ]; then + git checkout staging + fi +fi + +# Check if Homebrew is installed +if ! command -v brew &> /dev/null; then + echo "Homebrew not found. Installing Homebrew..." + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +else + echo "Homebrew is already installed." +fi + +# Check if NPM is installed +if ! command -v npm &> /dev/null; then + echo "NPM not found. Installing NPM..." + brew install npm +else + echo "NPM is already installed." +fi + +# Check if PNPM is installed +if ! command -v pnpm &> /dev/null; then + echo "PNPM not found. Installing PNPM..." + brew install pnpm +else + echo "PNPM is already installed." +fi + +if ! command -v bun &> /dev/null; then + echo "Bun not found. Installing Bun..." + brew install bun +else + echo "Bun is already installed." +fi + +# Run pnpm install +echo "Running pnpm install..." +pnpm i + +# Run turbo build +echo "Running turbo build..." +if ! pnpm exec turbo build; then + echo "Turbo build failed. Please fix the issues and rerun this script." + + echo "If you are only running braintrust evals, you only need to build the AI package, would you like to do that? (Y/N)" + read -r response + if [ "$response" = "Y" ] || [ "$response" = "y" ]; then + if ! pnpm exec turbo build --filter @buster/ai; then + echo "Turbo build failed. Please fix the issues and rerun this script." + exit 1 + fi + else + exit 1 + fi +fi + +#Docker setup +echo "Setting up docker..." +open -a Docker + +echo "Initializing database..." +pnpm exec turbo run db:init + + +echo "Setup complete, you can now run evals" \ No newline at end of file