--- title: ThoughtSpot Demo Builder emoji: ๐Ÿš€ colorFrom: blue colorTo: purple sdk: gradio sdk_version: "4.44.1" app_file: app.py pinned: false license: mit python_version: "3.11" --- # DemoPrep โ€” AI-Powered ThoughtSpot Demo Builder A Gradio application that generates and deploys complete ThoughtSpot demo environments end to end โ€” company research, an LLM-authored data blueprint, deterministic data generation, a Snowflake schema + data load, and a ThoughtSpot semantic model and liveboard. > **Deployed on Hugging Face Spaces.** `app.py` is the entry point. See [DEPLOYMENT.md](DEPLOYMENT.md) for setup. ## ๐Ÿ–ฅ๏ธ The interface The app is a **tabbed Gradio UI**, and the **App tab is the primary way to build a demo**: fill in a short form and press **GO**, and the full pipeline runs automatically with live progress. > **Naming note:** the whole application lives in **`chat_interface.py`** โ€” that name is *historical*. It is **not** just a chat interface; that single file hosts every tab (App, Chat, Admin, Settings, Run History, โ€ฆ), and the **App tab is the main path**. A **Chat tab** offers an alternative conversational flow that runs the same pipeline. `app.py` simply configures and launches this app. ## ๐Ÿš€ Features - **AI-powered research** โ€” researches the company and industry with an LLM - **Single blueprint pipeline** โ€” one path, no keyword routing or fallback: research โ†’ LLM-authored `DemoBlueprint` โ†’ deterministic engine โ†’ validation โ†’ derived DDL โ†’ load - **Realistic data** โ€” bounded/related measures (a part never exceeds its whole, rates stay โ‰ค 1, prices are stable per entity) plus planted, discoverable "Demo to Win" insights the validator proves are visible - **ThoughtSpot integration** โ€” deploys the connection, tables, semantic model, and an enhanced liveboard - **Interactive UI** โ€” tabbed Gradio app with real-time progress ## ๐Ÿ› ๏ธ Tech Stack - **Frontend**: Gradio (Python web UI) - **Backend**: Python 3.11 - **Database**: Snowflake (keypair auth) - **Analytics**: ThoughtSpot (per-environment trusted auth) - **AI**: multiple LLM providers (OpenAI and Anthropic/Claude), routed via `llm_config.py` - **Settings**: Supabase (admin + per-user settings) ## ๐Ÿ“‹ Prerequisites - Python 3.11 - Snowflake account (keypair configured) - ThoughtSpot Cloud account - An LLM API key (OpenAI and/or Anthropic) - Supabase project (settings storage) ## ๐Ÿš€ Quick Start 1. **Clone the repository** ```bash git clone cd demoprep ``` 2. **Set up a virtual environment** ```bash python -m venv .venv source .venv/bin/activate # Windows: .venv\Scripts\activate ``` 3. **Install dependencies** ```bash pip install -r requirements.txt ``` 4. **Configure bootstrap environment variables** (see Configuration) ```bash cp .env.example .env # edit .env ``` 5. **Run the application** ```bash python app.py ``` `app.py` launches the full Gradio app defined in `chat_interface.py`. 6. **Open your browser** Navigate to `http://localhost:7860` and use the **App** tab. ## โš™๏ธ Configuration `.env` holds only the **bootstrap** secrets needed to start the app and reach Supabase and the LLM providers. All other credentials โ€” the Snowflake keypair and the ThoughtSpot **per-environment trusted-auth keys** โ€” live in **Supabase admin settings** and are loaded at runtime. ```env # Supabase (settings storage) SUPABASE_URL=... SUPABASE_ANON_KEY=... # LLM providers OPENAI_API_KEY=... GOOGLE_API_KEY=... # optional (Gemini) # Slack deployment notifications (optional, outbound-only) SLACK_BOT_TOKEN=xoxb-... SLACK_DEPLOYMENT_CHANNEL_ID=C0123456789 ``` Slack notifications use the Slack Web API to post deployment status into one approved channel. This path is outbound-only: no Socket Mode, event subscriptions, slash commands, or public request URL. The Slack app needs only the `chat:write` bot scope and must be invited to the target channel. ## ๐ŸŽฏ Usage The **App tab** is the primary interface โ€” fill the form, press **GO**, and the pipeline runs end to end: 1. **Fill the form** โ€” vertical / line of business / function (or a custom use case), the company URL, and the target **ThoughtSpot environment** 2. **Press GO** โ€” research โ†’ blueprint โ†’ data generation โ†’ validation โ†’ Snowflake load โ†’ ThoughtSpot model + liveboard 3. **Review** โ€” model and liveboard links, a Demo Pack, and a Spotter Viz story appear on completion ## ๐Ÿ“ Project Structure ``` demoprep/ โ”œโ”€โ”€ app.py # Entry point โ€” launches the Gradio app on :7860 โ”œโ”€โ”€ chat_interface.py # The full Gradio app (App/Chat/Admin/Settings/โ€ฆ) โ€” historical name โ”œโ”€โ”€ thoughtspot_deployer.py # ThoughtSpot deploy: connection, tables, model, liveboard โ”œโ”€โ”€ liveboard_creator.py # MCP liveboard creation + TML post-processing (enhance_mcp_liveboard) โ”œโ”€โ”€ snowflake_auth.py # Snowflake keypair authentication โ”œโ”€โ”€ llm_config.py # LLM provider/model routing (single source of truth) โ”œโ”€โ”€ demo_personas.py # Vertical ร— Function use-case configs โ”œโ”€โ”€ demoprep_app/ # The demo-generation pipeline package โ”‚ โ”œโ”€โ”€ pipeline/build_demo.py # the single build entry point โ”‚ โ”œโ”€โ”€ scenario/ # blueprint contract + LLM authoring + directives โ”‚ โ”œโ”€โ”€ dataset/ # deterministic engine + validator โ”‚ โ”œโ”€โ”€ ddl/ # Snowflake DDL derived from the dataset โ”‚ โ””โ”€โ”€ integrations/snowflake/ # Snowflake row loader โ”œโ”€โ”€ requirements.txt # Python dependencies โ”œโ”€โ”€ docs/ # Documentation โ”œโ”€โ”€ tests/ # Unit tests + the e2e quality harness (e2e_quality.py) โ””โ”€โ”€ results/ # Generated demo results ``` ## ๐Ÿงช Testing ```bash # Unit tests (pytest collects test_*.py) python -m pytest tests/ # End-to-end quality harness โ€” drives a running app via the browser and grades the output python tests/e2e_quality.py --env-name test ``` ## ๐Ÿค Contributing 1. Fork the repository 2. Create a feature branch (`git checkout -b feature/amazing-feature`) 3. Commit your changes (`git commit -m 'Add amazing feature'`) 4. Push to the branch (`git push origin feature/amazing-feature`) 5. Open a Pull Request ## ๐Ÿ“„ License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. ## ๐Ÿ™ Acknowledgments - ThoughtSpot for the analytics platform - Snowflake for the data warehouse - OpenAI and Anthropic for the AI capabilities - Gradio for the web interface ## ๐Ÿ“š Development Notes Sprint planning and working notes live in `dev_notes/` (gitignored); architecture and handoff docs are in `docs/`. ## ๐Ÿ“ž Support For support, create an issue in this repository. --- **Built with โค๏ธ for the ThoughtSpot community**