### Quick Start: Clone, Setup, and Run Development Server Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/README.md Provides the three essential commands to quickly get the Databricks agent demo application up and running, including cloning the repository, interactive environment setup, and starting the development server. ```bash git clone ./setup.sh # Interactive environment setup ./watch.sh # Start development server ``` -------------------------------- ### Run React Development Server with npm start Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/client/README.md Starts the application in development mode, opening it in the browser at http://localhost:3000. The page reloads automatically upon code edits, and any lint errors are displayed in the console. ```NPM npm start ``` -------------------------------- ### Build React App for Production with npm run build Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/client/README.md Builds the React application for production, outputting optimized and minified assets to the 'build' folder. This process bundles React in production mode, includes hashes in filenames, and prepares the app for deployment. ```NPM npm run build ``` -------------------------------- ### Launch React Test Runner with npm test Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/client/README.md Launches the interactive test runner, allowing developers to run tests and monitor results. Refer to the official documentation for more details on running tests. ```NPM npm test ``` -------------------------------- ### Install Development Prerequisites (Bun, UV) Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/README.md Installs necessary development tools, `uv` and `bun`, using Homebrew on macOS to prepare the environment for local development. ```bash brew install uv bun ``` -------------------------------- ### Frontend Development Commands and TypeScript Imports Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/CLAUDE.md This section outlines common Bun commands for frontend development, including starting the dev server, building the project, and managing packages. It also shows an example of a TypeScript path alias import for UI components, highlighting the use of shadcn/ui. ```Bash bun start bun dev bun run build bun add bun remove npx shadcn@latest add ``` ```TypeScript import { Button } from "@/components/ui/button" ``` -------------------------------- ### Run Setup Script Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/CLAUDE.md Command to execute the interactive setup script, which configures the `.env.local` file with all required environment variables for the project. This streamlines the initial project setup process. ```Bash ./setup.sh ``` -------------------------------- ### Eject Create React App Configuration with npm run eject Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/client/README.md This is a one-way operation that removes the single build dependency from the project. It copies all configuration files (e.g., webpack, Babel, ESLint) directly into your project, giving you full control over the build setup. Once ejected, this action cannot be undone. ```NPM npm run eject ``` -------------------------------- ### Manual .env.local Configuration Example Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/README.md Provides an example of the `.env.local` file content, detailing required environment variables for Databricks host, token, app name, monitoring destination, and local source code path. ```bash DATABRICKS_HOST="e2-dogfood.staging.cloud.databricks.com" DATABRICKS_TOKEN="..." DATABRICKS_CONFIG_PROFILE="..." # Your LHA name here: DATABRICKS_APP_NAME="nikhil-chatbot-fastapi" # The agents monitoring destination. See external trace logging SDK for configuration of this param. If not defined, will not monitor the traces in mlflow. DATABRICKS_AGENTS_MONITORING_DESTINATION="rag.external_agent_monitoring.nikhil_chatbot-fastapi" # The source code path is only necessary for local dev: LHA_SOURCE_CODE_PATH="/Workspace/Users/nikhil.thorat@databricks.com/nikhil-chatbot-fastapi" ``` -------------------------------- ### Install Shadcn UI Components Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/README.md This command uses `bunx` to install the latest Shadcn UI components, which are then placed in `client/src/components/ui/`. ```bash bunx --bun shadcn@latest add ``` -------------------------------- ### Run Interactive Environment Setup Script Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/README.md Executes the interactive setup script to create the `.env.local` file, which configures essential environment variables for the project. ```bash ./setup.sh ``` -------------------------------- ### Development Automation Scripts Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/README.md Lists various utility scripts for project setup, code formatting, quality checks, running local development servers, and testing the agent directly. ```bash ./setup.sh - Interactive setup to create .env.local file - ./fix.sh - Format all code (ruff for Python, prettier for TypeScript) - ./check.sh - Run code quality checks **Development and testing:** - ./watch.sh - Run fast-edit refresh python + typescript locally - ./start_prod.sh - Run the production server locally - ./test_agent.sh - Test agent directly without starting full web app ``` -------------------------------- ### Start Databricks App Development Server Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/CLAUDE.md This command initiates the local development server for the Databricks application. It is a prerequisite for interacting with the UI using tools like Playwright and for local testing. ```Bash ./dev.sh ``` -------------------------------- ### Development Server Management Commands Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/CLAUDE.md Commands for managing the project's development server, including starting it in a detached screen session using `./watch.sh` and reattaching to the screen session. The server runs both the FastAPI backend and React frontend with hot reload. ```Bash ./watch.sh screen -r lha-dev ``` -------------------------------- ### Example Shadcn UI Component Usage in React Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/README.md Demonstrates how to import and use Shadcn UI components like Button, Dialog, and Card within a React functional component, following the canonical '@/' import pattern. ```tsx import { Button } from "@/components/ui/button" import { Dialog } from "@/components/ui/dialog" import { Card, CardContent, CardHeader } from "@/components/ui/card" function MyComponent() { return ( My Card ) } ``` -------------------------------- ### Test Agent Code Directly Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/CLAUDE.md Commands to run the agent's test script directly, allowing for faster iteration and debugging of agent behavior without starting the full web application. This is particularly useful for changes to `server/agents/databricks_assistant.py`. ```Bash ./test_agent.sh uv run python test_agent.py ``` -------------------------------- ### Add Debug Prints for Hot Reload Testing Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/CLAUDE.md Example of adding a debug print statement in Python server code to verify endpoint hits during hot-reloading. The `uvicorn` server automatically reloads on file changes, allowing immediate testing with cURL without manual restarts. ```Python print(f"🔥 ENDPOINT HIT: {data}") ``` -------------------------------- ### Project Directory Structure Overview Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/README.md Outlines the main directories and files of the project, detailing the FastAPI backend, React frontend, scripts, and environment configuration. ```text ├── server/ # FastAPI backend │ ├── agents/ # Agent implementations │ │ ├── databricks_assistant.py # Main agent (customize this!) │ │ └── model_serving.py # Direct model endpoint calls │ ├── app.py # FastAPI routes and setup │ └── tracing.py # MLflow integration ├── client/ # React frontend │ ├── src/components/ # UI components (shadcn/ui based) │ ├── src/queries/ # API client and React Query hooks │ └── build/ # Production build output ├── scripts/ # Build and utility scripts ├── *.sh # Development automation scripts └── .env.local # Environment configuration (create with ./setup.sh) ``` -------------------------------- ### Add UI Components with bunx shadcn/ui Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/README.md These shell commands demonstrate how to add pre-built, accessible UI components from the shadcn/ui library to the project using the `bunx` package runner. This ensures consistent styling and functionality across the frontend. ```Shell # Add a new component (run from project root) bunx --bun shadcn@latest add button bunx --bun shadcn@latest add dialog bunx --bun shadcn@latest add form ``` -------------------------------- ### Execute Databricks App Deployment Script Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/CLAUDE.md This snippet shows the command to initiate the deployment of a Databricks application. The `./deploy.sh` script handles the configuration and deployment process, including updating `app.yaml` and verifying success. ```Bash ./deploy.sh ``` -------------------------------- ### Troubleshoot Development Server Processes and Ports Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/CLAUDE.md Commands to diagnose issues with the development server, including checking running `uvicorn` processes and verifying port usage to identify conflicts or ensure the server is listening correctly. This helps in resolving common server startup problems. ```Bash ps aux | grep uvicorn lsof -i :8000 ``` -------------------------------- ### Python Package Management with uv Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/CLAUDE.md This section describes the use of `uv` for Python package management, emphasizing its role in dependency management and virtual environment handling. It provides commands for adding and removing dependencies. ```Bash uv add uv remove ``` -------------------------------- ### Python LangChain Agent for Databricks Unity Catalog Exploration Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/README.md This Python function, `databricks_agent`, implements a LangChain tool-calling agent. It leverages `ChatDatabricks` for LLM interaction, `create_catalog_tools` for Unity Catalog exploration (listing catalogs, schemas, tables, volumes), and `AgentExecutor` for orchestrating tool calls. The function is instrumented with `@mlflow.trace` for observability. ```Python @mlflow.trace(span_type='LLM') def databricks_agent(messages): """A LangChain agent that can explore Databricks catalogs and answer questions.""" # Initialize ChatDatabricks LLM llm = ChatDatabricks( endpoint='databricks-claude-sonnet-4', max_tokens=1000, temperature=0.1, ) # Create catalog exploration tools tools = create_catalog_tools() # list_catalogs, list_schemas, list_tables, list_volumes # Create tool-calling agent with custom prompt agent = create_tool_calling_agent(llm=llm, tools=tools, prompt=prompt) # Execute agent with AgentExecutor for tool orchestration agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True) result = agent_executor.invoke({'input': user_query}) return formatted_response # Formatted for UI compatibility ``` -------------------------------- ### Test FastAPI Endpoint with cURL and Check Logs Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/CLAUDE.md Workflow for testing FastAPI endpoints, demonstrating how to send a POST request using cURL and then immediately check server logs from the screen session to verify the response and MLflow tracing. This ensures proper functionality and data flow. ```Bash curl -X POST http://localhost:8000/api/agent \ -H "Content-Type: application/json" \ -d '{"inputs": {"messages": [{"role": "user", "content": "What is Databricks?"}]}}' screen -S lha-dev -X hardcopy /tmp/server_logs.txt && tail -30 /tmp/server_logs.txt ``` -------------------------------- ### Shell Command to List Screen Sessions Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/README.md Use this command to display a list of all currently running GNU Screen sessions. It shows the session ID and name, which is helpful for managing persistent terminal environments. ```Shell screen -list ``` -------------------------------- ### Playwright MCP Browser Interaction Commands Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/CLAUDE.md This lists various Playwright commands available through the MCP (Managed Compute Platform) for interacting with and debugging a web application's UI. These commands facilitate navigation, screenshot capture, DOM inspection, network monitoring, and user interaction simulation for testing. ```APIDOC mcp__playwright__browser_navigate(url: str) mcp__playwright__browser_take_screenshot() mcp__playwright__browser_snapshot() mcp__playwright__browser_network_requests() mcp__playwright__browser_click(selector: str) mcp__playwright__browser_type(selector: str, text: str) mcp__playwright__browser_console_messages() ``` -------------------------------- ### Format Code with Fix Script Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/CLAUDE.md Command to run the project's formatting script, which applies `ruff` for Python and `prettier` for TypeScript/JavaScript to ensure consistent code style across the entire codebase before committing changes. ```Bash ./fix.sh ``` -------------------------------- ### Generate FastAPI Client Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/CLAUDE.md Command to automatically generate the TypeScript client for the FastAPI backend from its OpenAPI specification. This ensures the frontend client (`client/src/fastapi_client/`) is always in sync with backend API changes. ```Bash uv run python -m scripts.make_fastapi_client ``` -------------------------------- ### Deploy Application to Lakehouse App (LHA) Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/README.md Executes the deployment script to deploy the application to a Databricks Lakehouse App. This process requires the `DATABRICKS_APP_NAME` environment variable to be correctly set. ```bash ./deploy.sh ``` -------------------------------- ### Databricks App Production URL Pattern Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/CLAUDE.md This describes the standard URL format for accessing a deployed Databricks application in a production environment. It includes placeholders for the app name, deployment ID, and region, providing a predictable access point. ```APIDOC https://{app-name}-{deployment-id}.{region}.databricksapps.com ``` -------------------------------- ### Python Project Dependency List Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/requirements.txt This snippet details the required Python packages and their specific version constraints for the project. The list is automatically generated from `pyproject.toml` and uses semantic versioning ranges to prevent conflicts with packages already present in Databricks environments. ```Python # Auto-generated from pyproject.toml with semantic versioning ranges # to avoid conflicts with pre-installed packages in Databricks Apps fastapi[standard]>=0.115.8 mlflow[databricks]>=3.1 python-dotenv>=1.0.1 uvicorn>=0.34.0 openai>=1.66.0 httpx>=0.28.0 pydantic>=2.10.0 langchain>=0.3.0 langchain-community>=0.3.0 databricks-sdk>=0.44.1 tenacity==9.0.0 pillow==11.1.0 websockets==15.0 pyarrow==18.1.0 markupsafe==3.0.2 rich==14.0.0 protobuf>=3.12.0,<5 pandas==2.3.0 flask==3.1.0 werkzeug==3.1.3 ``` -------------------------------- ### List Databricks Applications Status Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/CLAUDE.md This command is used to programmatically check the status of deployed Databricks applications. It helps verify if an app appears after deployment and its current state (ACTIVE/FAILED), aiding in post-deployment verification. ```Bash databricks apps list ``` -------------------------------- ### Push Git Changes Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/CLAUDE.md Custom Git command for pushing changes, used as an alias or wrapper instead of the standard `git push`. This might incorporate additional project-specific logic or checks. ```Bash git pp ``` -------------------------------- ### Retrieve MLflow Tracing Experiment Link Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/CLAUDE.md This describes an API endpoint used to programmatically obtain the link to the associated MLflow experiment for tracing. This is crucial for monitoring agent interactions and debugging, providing direct access to experiment details. ```APIDOC /api/tracing_experiment ``` -------------------------------- ### Shell Command to Check Port Usage Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/README.md This command identifies processes listening on a specific TCP/IP port, useful for troubleshooting 'address already in use' errors. It lists the process ID and name associated with port 8000. ```Shell lsof -i :8000 ``` -------------------------------- ### Shell Command to Quit a Specific Screen Session Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/README.md This command forces the termination of a GNU Screen session identified by its name, 'lha-dev'. It's used to resolve stuck sessions or clean up background processes. ```Shell screen -X -S lha-dev quit ``` -------------------------------- ### Resolve Python Dependency Conflicts in pyproject.toml Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/CLAUDE.md This snippet provides a strategy for resolving Python package dependency conflicts in Databricks Apps. It advises pinning exact versions of conflicting packages in `pyproject.toml` to match pre-installed versions and highlights Python version requirements for specific packages like `databricks-connect`. ```APIDOC # Example for pyproject.toml # Pin conflicting packages to exact versions # e.g., tenacity = "==8.2.3" # e.g., pillow = "==9.5.0" # Ensure Python version matches requirements for specific packages # e.g., databricks-connect==16.2.0 requires Python>=3.12 ``` -------------------------------- ### Databricks App Log Access Methods Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/CLAUDE.md This outlines the two primary methods for accessing Databricks application logs. It specifies both a web UI endpoint and a WebSocket stream, noting that both require OAuth authentication for access. ```APIDOC Web UI: https://{app-url}/logz WebSocket stream: wss://{app-url}/logz/stream ``` -------------------------------- ### Databricks App Key Monitoring Endpoints Source: https://github.com/databricks-solutions/agent-monitoring-demo-app/blob/main/CLAUDE.md This section lists critical API endpoints for monitoring a deployed Databricks application. It includes access to real-time logs, a health check endpoint, and guidance on finding the MLflow experiment ID for tracing. ```APIDOC App Logs: {app-url}/logz Health Check: {app-url}/api/health MLflow Experiment: Check the experiment ID in deployment output for agent traces ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.