### Backend Setup and Server Start Source: https://github.com/bagofwords1/bagofwords/blob/main/docs/design/sandbox-feedback-loop.md Sets up the Python virtual environment, installs backend dependencies, configures environment variables, runs database migrations, and starts the development server with auto-reloading. ```bash cd backend # Use Python 3.12 venv (system python may be 3.11) python3.12 -m venv .venv source .venv/bin/activate # Install deps pip install uv && uv sync --frozen --extra dev # Required env vars (dev config references these) export BOW_DATABASE_URL="sqlite:///db/app.db" export BOW_SMTP_PASSWORD="dummy" # Create directories and run migrations mkdir -p db uploads/files uploads/branding alembic upgrade head # Start server (auto-reloads on .py changes) python main.py & ``` -------------------------------- ### Frontend Setup and Development Server Source: https://github.com/bagofwords1/bagofwords/blob/main/docs/design/sandbox-feedback-loop.md Installs frontend dependencies using yarn and starts the development server with Hot Module Replacement (HMR) for .vue and .ts files. ```bash cd frontend yarn install # Start dev server (HMR on .vue/.ts changes) yarn dev & ``` -------------------------------- ### Install Oracle Instant Client Source: https://github.com/bagofwords1/bagofwords/blob/main/documents/data_sources.md Installs Oracle Instant Client for Linux. Includes downloading, extracting, setting environment variables, and installing required libraries. ```bash # Download Oracle Instant Client wget https://download.oracle.com/otn_software/linux/instantclient/2360000/instantclient-basic-linux.x64-23.6.0.24.10.zip # Extract the Oracle Instant Client sudo mkdir -p /opt/oracle sudo unzip instantclient-basic-linux.x64-23.6.0.24.10.zip -d /opt/oracle # Set environment variables echo "export LD_LIBRARY_PATH=/opt/oracle/instantclient_23_6: $LD_LIBRARY_PATH" >> ~/.bashrc echo "export PATH=/opt/oracle/instantclient_23_6: $PATH" >> ~/.bashrc source ~/.bashrc # Install required libraries sudo apt-get install libaio1 # Verify the installation ls /opt/oracle/instantclient_23_6 ``` -------------------------------- ### Playwright Verification Setup Commands Source: https://github.com/bagofwords1/bagofwords/blob/main/sandbox-feedback-loop-save-button.md These bash commands set up the necessary directory, copy verification files, and install Playwright dependencies for running the test loop. ```bash mkdir -p /tmp/sticky-verify && cd /tmp/sticky-verify cp /tools/sandbox/save-button-sticky/* . npm i @playwright/test@1.56.1 export PLAYWRIGHT_BROWSERS_PATH=/opt/pw-browsers ``` -------------------------------- ### Start Backend Server Source: https://github.com/bagofwords1/bagofwords/blob/main/DEV.md Starts the backend Python server using uv. The server will be available at http://localhost:8000. ```bash uv run python main.py ``` -------------------------------- ### Install Dependencies and Set Up Environment Source: https://github.com/bagofwords1/bagofwords/blob/main/sandbox-feedback-loop.md Installs project dependencies using uv and sets the database URL for local SQLite usage. Ensure you are using Python 3.12. ```bash cd backend pip install uv uv sync --frozen --extra dev # Required by bow-config.dev.yaml (database.url: ${BOW_DATABASE_URL}) export BOW_DATABASE_URL="sqlite:///db/app.db" mkdir -p db ``` -------------------------------- ### Install Backend Dependencies with uv Source: https://github.com/bagofwords1/bagofwords/blob/main/DEV.md Installs development dependencies for the backend using uv, creating a virtual environment. ```bash cd backend uv sync --extra dev ``` -------------------------------- ### Install Frontend Dependencies with Yarn Source: https://github.com/bagofwords1/bagofwords/blob/main/DEV.md Installs frontend dependencies using Yarn. ```bash cd frontend yarn install ``` -------------------------------- ### Install System Dependencies Source: https://github.com/bagofwords1/bagofwords/blob/main/docs/design/sandbox-feedback-loop.md Installs necessary system packages for building psycopg2 and upgrades setuptools for dependency management. ```bash # Needed for psycopg2 build apt-get install -y libpq-dev # Upgrade setuptools (needed for thrift transitive dep) pip install --upgrade setuptools ``` -------------------------------- ### Set Up Python 3.12 Virtual Environment Source: https://github.com/bagofwords1/bagofwords/blob/main/docs/design/druid-connector.md Installs necessary packages for unit testing the Druid connector. It creates a virtual environment, installs a light set of requirements, and sets up the database URL. ```bash cd backend python3.12 -m venv /tmp/venv312 /tmp/venv312/bin/pip install -q --upgrade pip grep -ivE '^psycopg2|^pyspark|^thrift|^pyodbc|^grpcio-tools|^confluent-kafka|^snowflake|^cx[-_]Oracle|^oracledb|^pymssql|^sqlalchemy-bigquery|^google-cloud|^pydruid' \ requirements_versioned.txt > /tmp/reqs_lite.txt /tmp/venv312/bin/pip install -q -r /tmp/reqs_lite.txt # Required by bow-config.dev.yaml (database.url: ${BOW_DATABASE_URL}) export BOW_DATABASE_URL="sqlite:///db/app.db" mkdir -p db ``` -------------------------------- ### Install with TLS and Google OAuth Source: https://github.com/bagofwords1/bagofwords/blob/main/k8s/AGENTS.md Helm command to install the application with TLS enabled and Google OAuth configured. Assumes cert-manager is installed for automatic certificate provisioning. ```bash helm upgrade -i -n bow/bagofwords --set host= --set postgresql.auth.username= --set postgresql.auth.password= --set postgresql.auth.database= --set config.googleOauthEnabled=true --set config.googleClientId= --set config.googleClientSecret= ``` -------------------------------- ### Install Dependencies Source: https://github.com/bagofwords1/bagofwords/blob/main/frontend/README.md Installs project dependencies using npm, pnpm, yarn, or bun. ```bash # npm npm install # pnpm pnpm install # yarn yarn install # bun bun install ``` -------------------------------- ### Install backend dependencies with uv Source: https://github.com/bagofwords1/bagofwords/blob/main/docs/snyk-dependency-scanning.md Synchronize the backend environment using uv to ensure all locked dependencies, including pip, are installed. ```bash cd backend # 1. Install the locked environment (and pip, which Snyk's pip plugin imports) uv sync --frozen --no-dev uv pip install pip ``` -------------------------------- ### Install Demo Data Source (Chinook) Source: https://github.com/bagofwords1/bagofwords/blob/main/docs/design/sandbox-feedback-loop.md Installs the Chinook SQLite demo data source into the sandbox environment. This involves two steps: initiating the demo installation and then saving the resulting data source ID. ```bash # 4. Install demo data source (chinook SQLite) curl http://localhost:8000/api/data_sources/demos \ -H "Authorization: Bearer $TOKEN" \ -H "X-Organization-Id: $ORG_ID" ``` ```bash curl -X POST http://localhost:8000/api/data_sources/demos/$DEMO_ID \ -H "Authorization: Bearer $TOKEN" \ -H "X-Organization-Id: $ORG_ID" ``` -------------------------------- ### Start Development Server Source: https://github.com/bagofwords1/bagofwords/blob/main/frontend/README.md Starts the Nuxt 3 development server on http://localhost:3000 using npm, pnpm, yarn, or bun. ```bash # npm npm run dev # pnpm pnpm run dev # yarn yarn dev # bun bun run dev ``` -------------------------------- ### Start Frontend Development Server Source: https://github.com/bagofwords1/bagofwords/blob/main/DEV.md Starts the frontend development server using Yarn. This runs the application in regular mode. ```bash yarn dev ``` -------------------------------- ### Install Runtime Dependencies with uv Source: https://github.com/bagofwords1/bagofwords/blob/main/sandbox-feedback-loop-bigquery-db-dtypes.md Install the application's runtime dependencies using 'uv sync --frozen --no-dev'. This command installs packages from the locked file, including db-dtypes. ```bash cd backend pip install uv UV_HTTP_TIMEOUT=300 uv sync --frozen --no-dev ``` -------------------------------- ### Install pydruid Source: https://github.com/bagofwords1/bagofwords/blob/main/docs/design/druid-connector.md Installs the pydruid library, required for interacting with Druid. ```bash /tmp/venv312/bin/pip install pydruid==0.6.9 ``` -------------------------------- ### Example Prompt for Benchmarking Source: https://github.com/bagofwords1/bagofwords/blob/main/docs/design/sse-create-data-bloat.md This is the prompt used during the benchmark to measure SSE payload size and server resource usage. ```text show me list of albums ``` -------------------------------- ### Environment Setup and Test Execution Source: https://github.com/bagofwords1/bagofwords/blob/main/sandbox-feedback-loop.md Sets up necessary environment variables for database, Entra tenant, and OAuth testing, then executes integration tests for OAuth delegated flows. ```bash cd backend export BOW_DATABASE_URL="sqlite:///db/app.db" export BOW_ENTRA_TENANT_ID=... # app registration tenant export BOW_ENTRA_CLIENT_ID=... export BOW_ENTRA_CLIENT_SECRET=... export BOW_OAUTH_TEST_DEMO1_EMAIL=... export BOW_OAUTH_TEST_DEMO1_PASSWORD=... export BOW_OAUTH_TEST_DEMO2_EMAIL=... export BOW_OAUTH_TEST_DEMO2_PASSWORD=... export BOW_FABRIC_SERVER=... # .datawarehouse.fabric.microsoft.com /tmp/venv312/bin/python -m pytest tests/integrations/test_oauth_delegated.py \ -k "TestClientCredentials or TestROPCLogin or TestOBOExchange or TestOBOServiceFunction" -v ``` -------------------------------- ### Install Chromium for Playwright Source: https://github.com/bagofwords1/bagofwords/blob/main/docs/design/sandbox-feedback-loop.md Install the Chromium browser executable required by Playwright. This command should be run from the 'frontend' directory. ```bash cd frontend && npx playwright install chromium ``` -------------------------------- ### Set up Snyk and uv CLI versions Source: https://github.com/bagofwords1/bagofwords/blob/main/docs/snyk-dependency-scanning.md Ensure you have the minimum required versions of the Snyk CLI and uv installed. Export your Snyk auth token as an environment variable. ```bash export SNYK_TOKEN= snyk --version # must be >= 1.1304.0 uv --version # must be >= 0.9.29 ``` -------------------------------- ### Bow Configuration Example Source: https://github.com/bagofwords1/bagofwords/blob/main/documents/installation.md An example YAML configuration file for the Bow application, detailing deployment type, base URL, feature flags, OAuth settings, LLM providers, SMTP settings, and encryption key. ```yaml ## Bow Config: # Deployment Configuration deployment: type: "saas" # Options: "saas" or "self_hosted" base_url: http://0.0.0.0:3000 # Feature Flags features: allow_uninvited_signups: true allow_multiple_organizations: true # If true, there could be more than 1 organization in the system verify_emails: false enable_google_oauth: true google_oauth: # Enable Google OAuth and enable Google People API client_id: "YOUR_CLIENT_ID" client_secret: "YOUR_CLIENT_SECRET" default_llm: - provider_type: "bow" provider_name: "Bow" api_key: "YOUR_API_KEY" models: - model_id: "gpt-4o-mini" model_name: "bow-small" is_default: true is_enabled: true # - provider_type: "anthropic" # provider_name: "Anthropic" # api_key: "YOUR_API_KEY" # models: # - model_id: "claude-3-5-sonnet" # model_name: "claude-3-5-sonnet" smtp_settings: host: "smtp.gmail.com" port: 587 username: "YOUR_EMAIL" password: "YOUR_PASSWORD" encryption_key: "YOUR_ENCRYPTION_KEY" # Example self-hosted configuration: # deployment: # type: "self_hosted" # features: # allow_signups: false # allow_multiple_organizations: false # show_billing_page: false # show_license_page: true ``` -------------------------------- ### Instructions API Calls Source: https://github.com/bagofwords1/bagofwords/blob/main/docs/design/sandbox-feedback-loop.md These commands show how to create a new global instruction and list existing instructions. Instructions guide the AI's behavior. ```bash # Create instruction curl -X POST http://localhost:8000/api/instructions \ -H "Authorization: Bearer $TOKEN" \ -H "X-Organization-Id: $ORG_ID" \ -H "Content-Type: application/json" \ -d '{"content": "Always use metric units", "scope": "global"}' ``` ```bash # List instructions curl http://localhost:8000/api/instructions \ -H "Authorization: Bearer $TOKEN" \ -H "X-Organization-Id: $ORG_ID" ``` -------------------------------- ### Start Bag of Words with Docker Compose Source: https://github.com/bagofwords1/bagofwords/blob/main/documents/deployment-options.mdx Starts the Bag of Words services using Docker Compose. Ensure a .env file is configured for domain and database credentials. ```bash docker compose up -d ``` -------------------------------- ### Install Playwright Browsers Source: https://github.com/bagofwords1/bagofwords/blob/main/docs/design/sandbox-feedback-loop.md Installs the Chromium browser and its dependencies for Playwright, used for taking frontend screenshots. ```bash cd frontend npx playwright install --with-deps chromium ``` -------------------------------- ### Install Sandbox Dependencies Source: https://github.com/bagofwords1/bagofwords/blob/main/backend/email_sandbox/README.md Install the necessary packages for running the email sandbox. This includes pytest for testing, pytest-asyncio for async tests, and aiosmtplib/aiosmtpd for SMTP client/server functionality. ```bash pip install pytest pytest-asyncio aiosmtplib aiosmtpd cd backend/email_sandbox python -m pytest # asyncio_mode=auto via pytest.ini ``` -------------------------------- ### Verify Python and ODBC Installation Source: https://github.com/bagofwords1/bagofwords/blob/main/documents/installation.md Optional commands to run inside the container to verify that the Python ODBC library is installed and that the SQL Server ODBC driver is available. ```bash python -c "import pyodbc; print(pyodbc.version)" odbcinst -q -d -n "ODBC Driver 18 for SQL Server" ``` -------------------------------- ### Example Aurora Deployment with IAM Source: https://github.com/bagofwords1/bagofwords/blob/main/k8s/README.md A concrete example of deploying Bag of Words with an AWS Aurora cluster using IAM authentication, including specific hostnames and IAM role ARN. ```bash helm upgrade -i --create-namespace \ -nbowapp-1 bowapp bow/bagofwords \ --set host=bow.example.com \ --set database.auth.provider=aws_iam \ --set database.auth.region=us-east-1 \ --set database.auth.sslMode=require \ --set database.host=bow-pg1-instance-1.cry2og862pqb.us-east-1.rds.amazonaws.com \ --set database.port=5432 \ --set database.username=bow_user \ --set database.name=postgres \ --set serviceAccount.annotations.'eks\.amazonaws\.com/role-arn'=arn:aws:iam::123456789012:role/bow-rds-role ``` -------------------------------- ### Install with Managed PostgreSQL Source: https://github.com/bagofwords1/bagofwords/blob/main/k8s/AGENTS.md Helm command to install the Bag of Words application with a managed PostgreSQL instance, specifying database credentials. ```bash helm upgrade -i -n bow/bagofwords --set postgresql.auth.username= --set postgresql.auth.password= --set postgresql.auth.database= ``` -------------------------------- ### Use useI18n in Script Setup Source: https://github.com/bagofwords1/bagofwords/blob/main/docs/design/i18n.md In Vue's