### Initialize and Start the Application Source: https://github.com/deepgram-starters/bun-text-intelligence/blob/main/AGENTS.md Commands to initialize the project dependencies and start the backend and frontend servers. ```bash # Initialize (clone submodules + install deps) make init # Set up environment test -f .env || cp sample.env .env # then set DEEPGRAM_API_KEY # Start both servers make start # Backend: http://localhost:8081 # Frontend: http://localhost:8080 ``` -------------------------------- ### Install Dependencies Source: https://github.com/deepgram-starters/bun-text-intelligence/blob/main/AGENTS.md Commands to install dependencies for the backend and frontend. ```bash bun install cd frontend && bun install ``` -------------------------------- ### Start Backend and Frontend Servers Source: https://context7.com/deepgram-starters/bun-text-intelligence/llms.txt Starts both the backend and frontend development servers simultaneously. Ensure your .env file is configured. ```bash make start ``` -------------------------------- ### Initialize and Start Bun App Source: https://github.com/deepgram-starters/bun-text-intelligence/blob/main/README.md Use this Makefile to initialize dependencies, set up environment variables with your Deepgram API key, and start the local development server. ```bash make init cp sample.env .env # Add your DEEPGRAM_API_KEY make start ``` -------------------------------- ### Start Backend Server Only Source: https://context7.com/deepgram-starters/bun-text-intelligence/llms.txt Starts only the backend server, typically accessible at http://localhost:8081. Useful for backend-only development. ```bash make start-backend ``` -------------------------------- ### Start Frontend Server Only Source: https://context7.com/deepgram-starters/bun-text-intelligence/llms.txt Starts only the frontend development server, typically accessible at http://localhost:8080. Useful for frontend-only development. ```bash make start-frontend ``` -------------------------------- ### Initialize Project Source: https://context7.com/deepgram-starters/bun-text-intelligence/llms.txt Initializes the project by cloning git submodules and installing all necessary dependencies using pnpm. ```bash make init ``` -------------------------------- ### Start and Stop Commands Source: https://github.com/deepgram-starters/bun-text-intelligence/blob/main/AGENTS.md Utility commands for managing the application lifecycle. ```bash make start ``` ```bash # Terminal 1 — Backend bun run server.ts # Terminal 2 — Frontend cd frontend && bun run dev -- --port 8080 --no-open ``` ```bash lsof -ti:8080,8081 | xargs kill -9 2>/dev/null ``` ```bash rm -rf node_modules frontend/node_modules frontend/.vite make init ``` -------------------------------- ### Conventional Commits Examples Source: https://github.com/deepgram-starters/bun-text-intelligence/blob/main/AGENTS.md Examples of commit messages following the conventional commits format. Use these to maintain a consistent commit history. ```bash feat(bun-text-intelligence): add diarization support ``` ```bash fix(bun-text-intelligence): resolve WebSocket close handling ``` ```bash refactor(bun-text-intelligence): simplify session endpoint ``` ```bash chore(deps): update frontend submodule ``` -------------------------------- ### GET /api/metadata Source: https://context7.com/deepgram-starters/bun-text-intelligence/llms.txt Returns metadata about the starter application as defined in the configuration file. ```APIDOC ## GET /api/metadata ### Description Returns metadata about the starter application including title, description, author, repository URL, and tags. ### Method GET ### Endpoint /api/metadata ### Response #### Success Response (200) - **title** (string) - Application title. - **description** (string) - Application description. - **author** (string) - Author information. - **repository** (string) - GitHub repository URL. - **useCase** (string) - Primary use case. - **language** (string) - Programming language. - **framework** (string) - Framework used. - **sdk** (string) - SDK version. - **tags** (array) - List of relevant tags. #### Response Example { "title": "Bun Text Intelligence", "description": "Get started using Deepgram's Text Intelligence with this Bun demo app", "author": "Deepgram DX Team", "repository": "https://github.com/deepgram-starters/bun-text-intelligence", "useCase": "text-intelligence", "language": "typescript", "framework": "bun", "sdk": "4.11.3", "tags": ["text-intelligence", "nlp"] } ``` -------------------------------- ### Check Project Prerequisites Source: https://context7.com/deepgram-starters/bun-text-intelligence/llms.txt Verifies that the necessary prerequisites (git, bun, pnpm) are installed and available in your environment. ```bash make check-prereqs ``` -------------------------------- ### Get Application Metadata with cURL Source: https://context7.com/deepgram-starters/bun-text-intelligence/llms.txt Retrieve metadata about the starter application by making a GET request to the /api/metadata endpoint. This endpoint is unprotected and returns details defined in the deepgram.toml file. ```bash # Get application metadata curl -X GET http://localhost:8081/api/metadata # Response: # { # "title": "Bun Text Intelligence", # "description": "Get started using Deepgram's Text Intelligence with this Bun demo app", # "author": "Deepgram DX Team (https://developers.deepgram.com)", # "repository": "https://github.com/deepgram-starters/bun-text-intelligence", # "useCase": "text-intelligence", # "language": "typescript", # "framework": "bun", # "sdk": "4.11.3", # "tags": ["text-intelligence", "text-analysis", "nlp", "natural-language-processing", "typescript", "bun"] # } ``` -------------------------------- ### GET /api/metadata Source: https://github.com/deepgram-starters/bun-text-intelligence/blob/main/AGENTS.md Returns application metadata, including use case, framework, and language information. ```APIDOC ## GET /api/metadata ### Description Returns metadata about the application, such as its intended use case, the framework it's built upon, and the primary language used. ### Method GET ### Endpoint `/api/metadata` ### Parameters None ### Request Example None ### Response #### Success Response (200) - **useCase** (string) - The primary use case of the application. - **framework** (string) - The framework used for the backend (e.g., Bun). - **language** (string) - The programming language used (e.g., TypeScript). #### Response Example ```json { "useCase": "Text Intelligence", "framework": "Bun", "language": "TypeScript" } ``` ``` -------------------------------- ### GET /health Source: https://context7.com/deepgram-starters/bun-text-intelligence/llms.txt A simple health check endpoint that returns the service status. ```APIDOC ## GET /health ### Description Returns the service status. Useful for monitoring and load balancers. ### Method GET ### Endpoint /health ### Response #### Success Response (200) - **status** (string) - Service status (e.g., "ok"). - **service** (string) - Service name. #### Response Example { "status": "ok", "service": "text-intelligence" } ``` -------------------------------- ### GET /api/session Source: https://github.com/deepgram-starters/bun-text-intelligence/blob/main/AGENTS.md Issues a JSON Web Token (JWT) session token. This token is used for authenticating subsequent requests that require authentication. ```APIDOC ## GET /api/session ### Description Issues a JWT session token. This token is used for authenticating requests that require user sessions or specific permissions. ### Method GET ### Endpoint `/api/session` ### Parameters None ### Request Example None ### Response #### Success Response (200) - **token** (string) - The issued JWT session token. #### Response Example ```json { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." } ``` ``` -------------------------------- ### GET /api/session Source: https://context7.com/deepgram-starters/bun-text-intelligence/llms.txt Issues a signed JWT session token required for authenticating subsequent API calls. The token is valid for 1 hour. ```APIDOC ## GET /api/session ### Description Issues a signed JWT session token required for authenticating subsequent API calls. The token is valid for 1 hour and must be included in the Authorization header as a Bearer token. ### Method GET ### Endpoint /api/session ### Response #### Success Response (200) - **token** (string) - The JWT session token. #### Response Example { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." } ``` -------------------------------- ### Health Check Endpoint with cURL Source: https://context7.com/deepgram-starters/bun-text-intelligence/llms.txt Check the service status by sending a GET request to the /health endpoint. This is a simple, unprotected endpoint useful for monitoring and orchestration platforms. ```bash # Check service health curl -X GET http://localhost:8081/health # Response: # { # "status": "ok", # "service": "text-intelligence" # } ``` -------------------------------- ### Build Frontend for Production Source: https://context7.com/deepgram-starters/bun-text-intelligence/llms.txt Builds the frontend application for production deployment. This command optimizes assets and generates static files. ```bash make build ``` -------------------------------- ### Copy Sample Environment File Source: https://context7.com/deepgram-starters/bun-text-intelligence/llms.txt Copies the sample environment file to .env. This file should be edited to include your Deepgram API key and other configuration settings. ```bash cp sample.env .env ``` -------------------------------- ### Run Conformance Tests Source: https://context7.com/deepgram-starters/bun-text-intelligence/llms.txt Executes the project's conformance tests to ensure everything is functioning as expected. This is crucial for verifying code integrity. ```bash make test ``` -------------------------------- ### Initialize Deepgram Client Source: https://context7.com/deepgram-starters/bun-text-intelligence/llms.txt Initializes the Deepgram SDK client using your API key, which is typically loaded from environment variables. Ensure DEEPGRAM_API_KEY is set in your .env file. ```typescript import { createClient } from "@deepgram/sdk"; // Initialize client with API key const deepgram = createClient(process.env.DEEPGRAM_API_KEY); ``` -------------------------------- ### Testing Endpoints with cURL Source: https://github.com/deepgram-starters/bun-text-intelligence/blob/main/AGENTS.md Commands to run conformance tests and manually check API endpoints using cURL. Ensure the application is running before executing these commands. ```bash # Run conformance tests (requires app to be running) make test ``` ```bash # Manual endpoint check curl -sf http://localhost:8081/api/metadata | python3 -m json.tool ``` ```bash curl -sf http://localhost:8081/api/session | python3 -m json.tool ``` -------------------------------- ### API Endpoints Overview Source: https://github.com/deepgram-starters/bun-text-intelligence/blob/main/AGENTS.md This section provides an overview of the available API endpoints for the Bun Text Intelligence application, including their methods, authentication requirements, and purpose. ```APIDOC ## API Endpoints | Endpoint | Method | Auth | Purpose | |----------|--------|------|---------| | `/api/session` | GET | None | Issue JWT session token | | `/api/metadata` | GET | None | Return app metadata (useCase, framework, language) | | `/api/text-intelligence` | POST | JWT | Analyzes text for summaries, topics, sentiment, and intents. | ``` -------------------------------- ### Clean Build Artifacts Source: https://context7.com/deepgram-starters/bun-text-intelligence/llms.txt Removes build artifacts and temporary files generated during the build process. Use this to ensure a clean state before rebuilding. ```bash make clean ``` -------------------------------- ### Analyze Text Content with cURL Source: https://context7.com/deepgram-starters/bun-text-intelligence/llms.txt Send a POST request to the /api/text-intelligence endpoint to analyze text content. Include query parameters for desired features (summarize, topics, sentiment, intents) and an Authorization header with the JWT token. Supports both direct text input and URL fetching. ```bash # Analyze text with all intelligence features enabled curl -X POST "http://localhost:8081/api/text-intelligence?summarize=v2&topics=true&sentiment=true&intents=true&language=en" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "text": "I absolutely love this new product! The quality is amazing and the customer service team was incredibly helpful when I had questions. I would definitely recommend this to anyone looking for a reliable solution. However, the shipping took longer than expected which was a bit frustrating." }' # Response: # { # "results": { # "summary": { "text": "..." }, # "topics": { "segments": [...] }, # "sentiments": { "segments": [...], "average": { "sentiment": "positive", "confidence": 0.85 } }, # "intents": { "segments": [...] } # } # } # Analyze content from a URL curl -X POST "http://localhost:8081/api/text-intelligence?summarize=true&topics=true" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "url": "https://example.com/article.txt" }' # Error response for missing authentication: # { # "error": { # "type": "AuthenticationError", # "code": "MISSING_TOKEN", # "message": "Authorization header with Bearer token is required" # } # } ``` -------------------------------- ### Show Git and Submodule Status Source: https://context7.com/deepgram-starters/bun-text-intelligence/llms.txt Displays the current status of git repositories and submodules, including any uncommitted changes or outdated submodules. ```bash make status ``` -------------------------------- ### Obtain JWT Session Token with cURL Source: https://context7.com/deepgram-starters/bun-text-intelligence/llms.txt Use this cURL command to request a signed JWT session token from the /api/session endpoint. The token is valid for 1 hour and required for authenticating protected API calls. ```bash # Request a new session token curl -X GET http://localhost:8081/api/session # Response: # { # "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MDk1..." # } # Store the token for subsequent requests TOKEN=$(curl -s http://localhost:8081/api/session | jq -r '.token') echo "Session token: $TOKEN" ``` -------------------------------- ### Analyze Text with Multiple Deepgram Features Source: https://context7.com/deepgram-starters/bun-text-intelligence/llms.txt Analyzes provided text content using the Deepgram SDK, enabling multiple intelligence features like summarization, topic extraction, sentiment analysis, and intent detection. Configure features via the options object. ```typescript // Analyze text with multiple features const { result, error } = await deepgram.read.analyzeText( { text: "Your text content to analyze here..." }, { language: "en", summarize: "v2", // Enable summarization (true or "v2") topics: true, // Enable topic extraction sentiment: true, // Enable sentiment analysis intents: true // Enable intent detection } ); ``` -------------------------------- ### Eject Frontend Submodule Source: https://context7.com/deepgram-starters/bun-text-intelligence/llms.txt Ejects the frontend git submodule, allowing for standalone development and modification of the frontend code outside the main project structure. ```bash make eject-frontend ``` -------------------------------- ### POST /api/text-intelligence Source: https://context7.com/deepgram-starters/bun-text-intelligence/llms.txt Analyzes text content or content from a URL using Deepgram's Text Intelligence API. ```APIDOC ## POST /api/text-intelligence ### Description Processes text through Deepgram's API. Accepts raw text or a URL to fetch content from, and supports multiple analysis features via query parameters. ### Method POST ### Endpoint /api/text-intelligence ### Parameters #### Query Parameters - **summarize** (string) - Optional - Enable summarization (true or v2). - **topics** (boolean) - Optional - Enable topic extraction. - **sentiment** (boolean) - Optional - Enable sentiment analysis. - **intents** (boolean) - Optional - Enable intent detection. - **language** (string) - Optional - Language code (defaults to "en"). #### Request Body - **text** (string) - Optional - Raw text to analyze. - **url** (string) - Optional - URL to fetch content from. ### Request Example { "text": "I absolutely love this new product!" } ### Response #### Success Response (200) - **results** (object) - The analysis results including summary, topics, sentiments, and intents. #### Response Example { "results": { "summary": { "text": "..." }, "topics": { "segments": [] }, "sentiments": { "segments": [], "average": { "sentiment": "positive", "confidence": 0.85 } }, "intents": { "segments": [] } } } ``` -------------------------------- ### POST /api/text-intelligence Source: https://github.com/deepgram-starters/bun-text-intelligence/blob/main/AGENTS.md Analyzes provided text to extract summaries, topics, sentiment, and intents. Supports various analysis features via query parameters and different input modes (text or URL). ```APIDOC ## POST /api/text-intelligence ### Description Analyzes text for summaries, topics, sentiment, and intents. This endpoint can accept text directly or a URL from which to fetch text content. Analysis features can be enabled or disabled using query parameters. ### Method POST ### Endpoint `/api/text-intelligence` ### Query Parameters - **summarize** (boolean or string) - Optional - Enable text summarization. Use `true` for default or `v2` for advanced summarization. - **topics** (boolean) - Optional - Enable topic detection. - **sentiment** (boolean) - Optional - Enable sentiment analysis. - **intents** (boolean) - Optional - Enable intent detection. - **language** (string) - Optional - Specify the language for analysis (e.g., `en`). Defaults to `en`. ### Request Body - **text** (string) - Required if `url` is not provided - The text content to analyze. - **url** (string) - Required if `text` is not provided - The URL of the content to fetch and analyze. ### Request Example ```json { "text": "This is a sample text to analyze.", "summarize": true, "topics": true, "sentiment": true, "intents": true, "language": "en" } ``` ### Response #### Success Response (200) - **results.summary.text** (string) - The generated summary text. - **results.topics.segments[].topics[].topic** (string) - Detected topics with confidence. - **results.sentiments.average** (object) - Overall sentiment with score. - **results.sentiments.segments[]** (array) - Per-segment sentiment analysis. - **results.intents.segments[].intents[].intent** (string) - Detected intents with confidence. #### Response Example ```json { "results": { "summary": { "text": "A concise summary of the input text." }, "topics": { "segments": [ { "topics": [ { "topic": "example", "confidence": 0.95 } ] } ] }, "sentiments": { "average": { "score": 0.8, "label": "positive" }, "segments": [ { "text": "This is a sample text to analyze.", "sentiment": { "score": 0.8, "label": "positive" } } ] }, "intents": { "segments": [ { "text": "This is a sample text to analyze.", "intents": [ { "intent": "information_request", "confidence": 0.7 } ] } ] } } } ``` ``` -------------------------------- ### Update Git Submodules Source: https://context7.com/deepgram-starters/bun-text-intelligence/llms.txt Updates all git submodules within the project to their latest commit versions. This ensures you have the most recent code for any sub-projects. ```bash make update ``` -------------------------------- ### Handle Deepgram Text Analysis Response Source: https://context7.com/deepgram-starters/bun-text-intelligence/llms.txt Processes the response from the Deepgram text analysis API. Logs any errors encountered or displays the extracted summary, topics, sentiment, and intents from the result. ```typescript // Handle response if (error) { console.error("Analysis failed:", error.message); } else { console.log("Summary:", result.results.summary); console.log("Topics:", result.results.topics); console.log("Sentiment:", result.results.sentiments); console.log("Intents:", result.results.intents); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.