### Initialize and Start Project Source: https://github.com/deepgram-starters/csharp-text-intelligence/blob/main/AGENTS.md Commands to clone submodules, install dependencies, and launch 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 ``` -------------------------------- ### Initialize and Start Local Development Source: https://github.com/deepgram-starters/csharp-text-intelligence/blob/main/README.md Use this Makefile command to initialize the project, copy environment variables, and start the local development server. Ensure your DEEPGRAM_API_KEY is set in the .env file. ```bash make init cp sample.env .env # Add your DEEPGRAM_API_KEY make start ``` -------------------------------- ### Install Dependencies Source: https://github.com/deepgram-starters/csharp-text-intelligence/blob/main/AGENTS.md Commands to install required packages for the .NET backend and the Vite frontend. ```bash dotnet restore ``` ```bash cd frontend && corepack pnpm install ``` -------------------------------- ### Project Setup and Configuration Source: https://context7.com/deepgram-starters/csharp-text-intelligence/llms.txt Initialize and configure the project using the Makefile commands and environment variables. The project requires .NET SDK, Git, and a Deepgram API key. ```bash # Check prerequisites make check-prereqs # Initialize project (clone submodules + install dependencies) make init # Configure environment cp sample.env .env # Edit .env and set your Deepgram API key: ``` -------------------------------- ### Project Build and Run Commands Source: https://context7.com/deepgram-starters/csharp-text-intelligence/llms.txt Commands to start backend and frontend servers, run tests, clean build artifacts, and update submodules. ```bash make start # Backend: http://localhost:8081 # Frontend: http://localhost:8080 ``` ```bash make start-backend # Port 8081 ``` ```bash make start-frontend # Port 8080 ``` ```bash make test ``` ```bash make clean ``` ```bash make update ``` -------------------------------- ### Curl Request Examples for Text Intelligence API Source: https://context7.com/deepgram-starters/csharp-text-intelligence/llms.txt Examples demonstrating various error scenarios when interacting with the Text Intelligence API using curl. Includes missing authorization, invalid tokens, and malformed request bodies. ```bash # Missing authorization token curl -X POST "http://localhost:8081/api/text-intelligence?summarize=true" \ -H "Content-Type: application/json" \ -d '{"text": "Hello world"}' | jq ``` ```json { "error": { "type": "AuthenticationError", "code": "MISSING_TOKEN", "message": "Authorization header with Bearer token is required" } } ``` ```bash # Invalid/expired token curl -X POST "http://localhost:8081/api/text-intelligence" \ -H "Authorization: Bearer invalid_token" \ -H "Content-Type: application/json" \ -d '{"text": "Hello"}' | jq ``` ```json { "error": { "type": "AuthenticationError", "code": "INVALID_TOKEN", "message": "Invalid or expired session token" } } ``` ```bash # Missing text/url in body curl -X POST "http://localhost:8081/api/text-intelligence" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{}' | jq ``` ```json { "error": { "type": "validation_error", "code": "INVALID_TEXT", "message": "Request must contain either 'text' or 'url' field" } } ``` ```bash # Both text and url provided (invalid) curl -X POST "http://localhost:8081/api/text-intelligence" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"text": "Hello", "url": "https://example.com"}' | jq ``` ```json { "error": { "type": "validation_error", "code": "INVALID_TEXT", "message": "Request must contain either 'text' or 'url', not both" } } ``` -------------------------------- ### Start and Stop Commands Source: https://github.com/deepgram-starters/csharp-text-intelligence/blob/main/AGENTS.md Utility commands for managing the application lifecycle, including separate server execution and cleanup. ```bash make start ``` ```bash # Terminal 1 — Backend dotnet run # Terminal 2 — Frontend cd frontend && corepack pnpm run dev -- --port 8080 --no-open ``` ```bash lsof -ti:8080,8081 | xargs kill -9 2>/dev/null ``` ```bash rm -rf bin obj frontend/node_modules frontend/.vite make init ``` -------------------------------- ### Conventional Commit Examples Source: https://github.com/deepgram-starters/csharp-text-intelligence/blob/main/AGENTS.md Standardized commit message formats for the project. Do not include Co-Authored-By lines for Claude. ```text feat(csharp-text-intelligence): add diarization support fix(csharp-text-intelligence): resolve WebSocket close handling refactor(csharp-text-intelligence): simplify session endpoint chore(deps): update frontend submodule ``` -------------------------------- ### Get Application Metadata Source: https://context7.com/deepgram-starters/csharp-text-intelligence/llms.txt Returns application metadata from the `deepgram.toml` configuration file, including title, description, use case, language, framework, and SDK version information. ```bash # Get application metadata curl -s http://localhost:8081/api/metadata | jq ``` -------------------------------- ### Get Application Metadata API Source: https://context7.com/deepgram-starters/csharp-text-intelligence/llms.txt Returns application metadata from the `deepgram.toml` configuration file, including title, description, use case, language, framework, and SDK version information. ```APIDOC ## GET /api/metadata ### Description Returns application metadata from the `deepgram.toml` configuration file, including title, description, use case, language, framework, and SDK version information. ### Method GET ### Endpoint /api/metadata ### Request Example ```bash curl -s http://localhost:8081/api/metadata | jq ``` ### Response #### Success Response (200) - **title** (string) - The title of the application. - **description** (string) - A brief description of the application. - **author** (string) - Information about the author or team. - **repository** (string) - URL to the project repository. - **useCase** (string) - The primary use case of the application. - **language** (string) - The programming language used. - **framework** (string) - The framework used. - **sdk** (string) - The version of the SDK used. - **tags** (array) - An array of relevant tags. #### Response Example ```json { "title": "C# Text Intelligence", "description": "Get started using Deepgram's Text Intelligence with this C# demo app", "author": "Deepgram DX Team (https://developers.deepgram.com)", "repository": "https://github.com/deepgram-starters/csharp-text-intelligence", "useCase": "text-intelligence", "language": "csharp", "framework": "dotnet", "sdk": "6.6.1", "tags": ["text-intelligence", "text-analysis", "summarization", "sentiment", "csharp", "dotnet"] } ``` ``` -------------------------------- ### Get Session Token Source: https://context7.com/deepgram-starters/csharp-text-intelligence/llms.txt Retrieves a JWT session token required for authenticating subsequent API requests. The token is valid for 3600 seconds (1 hour) and must be included as a Bearer token in the Authorization header for protected endpoints. ```bash # Get a session token curl -s http://localhost:8081/api/session | jq # Response: { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." } # Store token for subsequent requests TOKEN=$(curl -s http://localhost:8081/api/session | jq -r '.token') echo "Session token: $TOKEN" ``` -------------------------------- ### Get Session Token API Source: https://context7.com/deepgram-starters/csharp-text-intelligence/llms.txt Retrieves a JWT session token required for authenticating subsequent API requests. The token is valid for 3600 seconds (1 hour) and must be included as a Bearer token in the Authorization header for protected endpoints. ```APIDOC ## GET /api/session ### Description Retrieves a JWT session token required for authenticating subsequent API requests. The token is valid for 3600 seconds (1 hour) and must be included as a Bearer token in the Authorization header for protected endpoints. ### Method GET ### Endpoint /api/session ### Request Example ```bash curl -s http://localhost:8081/api/session | jq ``` ### Response #### Success Response (200) - **token** (string) - The JWT session token. #### Response Example ```json { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." } ``` ``` -------------------------------- ### Project Testing Commands Source: https://github.com/deepgram-starters/csharp-text-intelligence/blob/main/AGENTS.md Commands to execute conformance tests and verify API endpoints manually. ```bash # Run conformance tests (requires app to be running) make test # Manual endpoint check curl -sf http://localhost:8081/api/metadata | python3 -m json.tool curl -sf http://localhost:8081/api/session | python3 -m json.tool ``` -------------------------------- ### Environment Variables Configuration Source: https://context7.com/deepgram-starters/csharp-text-intelligence/llms.txt Configure application behavior using environment variables in the .env file. Ensure DEEPGRAM_API_KEY is set. ```bash # Required - Deepgram API key from https://console.deepgram.com DEEPGRAM_API_KEY=your_api_key_here ``` ```bash # Optional - Backend server port (default: 8081) PORT=8081 ``` ```bash # Optional - Server bind address (default: 0.0.0.0) HOST=0.0.0.0 ``` ```bash # Optional - JWT signing secret for production (auto-generated if not set) SESSION_SECRET=your_secure_secret_for_production ``` -------------------------------- ### C# Deepgram SDK for Text Analysis Source: https://context7.com/deepgram-starters/csharp-text-intelligence/llms.txt Initialize the Deepgram library and client, configure analysis options, and analyze text content using the .NET SDK. Access results like summary, topics, sentiment, and intents. ```csharp using Deepgram; using Deepgram.Models.Analyze.v1; // Initialize the Deepgram library Library.Initialize(); // Create an analyze client with your API key var apiKey = Environment.GetEnvironmentVariable("DEEPGRAM_API_KEY"); var deepgramClient = ClientFactory.CreateAnalyzeClient(apiKey); // Configure analysis options var schema = new AnalyzeSchema { Language = "en", Summarize = true, // Enable summarization Topics = true, // Enable topic detection Sentiment = true, // Enable sentiment analysis Intents = true // Enable intent detection }; // Analyze text content var textContent = "Your text content to analyze here..."; var result = await deepgramClient.AnalyzeText( new TextSource(textContent), schema ); // Access results var summary = result.Results?.Summary?.Text; var topics = result.Results?.Topics?.Segments; var sentiment = result.Results?.Sentiments?.Average; var intents = result.Results?.Intents?.Segments; ``` -------------------------------- ### Health Check Endpoint Source: https://context7.com/deepgram-starters/csharp-text-intelligence/llms.txt Returns the health status of the backend service. Useful for monitoring, load balancers, and container orchestration systems. ```bash # Check service health curl -s http://localhost:8081/health | jq ``` -------------------------------- ### Health Check Endpoint Source: https://context7.com/deepgram-starters/csharp-text-intelligence/llms.txt Returns the health status of the backend service. Useful for monitoring, load balancers, and container orchestration systems. ```APIDOC ## GET /health ### Description Returns the health status of the backend service. Useful for monitoring, load balancers, and container orchestration systems. ### Method GET ### Endpoint /health ### Request Example ```bash curl -s http://localhost:8081/health | jq ``` ### Response #### Success Response (200) - **status** (string) - The health status of the service (e.g., "ok"). - **service** (string) - The name of the service. #### Response Example ```json { "status": "ok", "service": "text-intelligence" } ``` ``` -------------------------------- ### Analyze Text with Text Intelligence Source: https://context7.com/deepgram-starters/csharp-text-intelligence/llms.txt Analyzes text content for summaries, topics, sentiment, and intents using Deepgram's Text Intelligence API. The endpoint accepts either raw text or a URL in the JSON body, and supports multiple analysis features via query parameters. Requires JWT authentication. ```bash # Analyze text with all features enabled curl -X POST "http://localhost:8081/api/text-intelligence?summarize=true&topics=true&sentiment=true&intents=true" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"text": "I love this product! The quality is amazing and the customer service was incredibly helpful. I would definitely recommend it to my friends and family. The shipping was fast and the packaging was secure."}' | jq ``` ```bash # Analyze text from URL curl -X POST "http://localhost:8081/api/text-intelligence?summarize=v2&language=en" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"url": "https://example.com/article.txt"}' | jq ``` ```bash # Analyze with specific features only (summarize and sentiment) curl -X POST "http://localhost:8081/api/text-intelligence?summarize=true&sentiment=true" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"text": "The meeting was productive but ran longer than expected. We resolved several key issues."}' | jq ``` -------------------------------- ### Analyze Text with Text Intelligence API Source: https://context7.com/deepgram-starters/csharp-text-intelligence/llms.txt Analyzes text content for summaries, topics, sentiment, and intents using Deepgram's Text Intelligence API. The endpoint accepts either raw text or a URL in the JSON body, and supports multiple analysis features via query parameters. Requires JWT authentication. ```APIDOC ## POST /api/text-intelligence ### Description Analyzes text content for summaries, topics, sentiment, and intents using Deepgram's Text Intelligence API. The endpoint accepts either raw text or a URL in the JSON body, and supports multiple analysis features via query parameters. Requires JWT authentication. ### Method POST ### Endpoint /api/text-intelligence ### Query Parameters - **summarize** (boolean or string) - Optional - Enable text summarization. Can be `true` or `v2` for different summarization versions. - **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`). ### 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 analyze. ### Request Example ```bash # Analyze text with all features enabled curl -X POST "http://localhost:8081/api/text-intelligence?summarize=true&topics=true&sentiment=true&intents=true" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"text": "I love this product! The quality is amazing and the customer service was incredibly helpful. I would definitely recommend it to my friends and family. The shipping was fast and the packaging was secure."}' | jq # Analyze text from URL curl -X POST "http://localhost:8081/api/text-intelligence?summarize=v2&language=en" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"url": "https://example.com/article.txt"}' | jq # Analyze with specific features only (summarize and sentiment) curl -X POST "http://localhost:8081/api/text-intelligence?summarize=true&sentiment=true" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"text": "The meeting was productive but ran longer than expected. We resolved several key issues."}' | jq ``` ### Response #### Success Response (200) - **results** (object) - Contains the analysis results. - **summary** (object) - The summary of the text. - **text** (string) - The summarized text. - **topics** (object) - Detected topics in the text. - **segments** (array) - Array of topic segments. - **topics** (array) - Array of detected topics within a segment. - **topic** (string) - The identified topic. - **confidence** (number) - The confidence score for the topic. - **sentiments** (object) - Sentiment analysis results. - **average** (object) - The overall average sentiment. - **sentiment** (string) - The sentiment (e.g., 'positive', 'negative', 'neutral'). - **confidence** (number) - The confidence score for the sentiment. - **segments** (array) - Sentiment analysis for text segments. - **intents** (object) - Detected user intents. - **segments** (array) - Array of intent segments. - **intents** (array) - Array of detected intents within a segment. - **intent** (string) - The identified intent. - **confidence** (number) - The confidence score for the intent. #### Response Example ```json { "results": { "summary": { "text": "The customer expresses strong satisfaction with the product quality, customer service, shipping speed, and packaging." }, "topics": { "segments": [ { "topics": [ {"topic": "product quality", "confidence": 0.95}, {"topic": "customer service", "confidence": 0.92} ] } ] }, "sentiments": { "average": {"sentiment": "positive", "confidence": 0.98}, "segments": [...] }, "intents": { "segments": [ { "intents": [ {"intent": "recommendation", "confidence": 0.89} ] } ] } } } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.