### Initialize and Start the Application Source: https://github.com/deepgram-starters/go-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 ``` -------------------------------- ### Install Dependencies Source: https://github.com/deepgram-starters/go-text-intelligence/blob/main/AGENTS.md Commands to install backend Go modules and frontend Node.js dependencies. ```bash go mod download cd frontend && corepack pnpm install ``` -------------------------------- ### Manage Application Lifecycle Source: https://github.com/deepgram-starters/go-text-intelligence/blob/main/AGENTS.md Commands for starting, stopping, and rebuilding the application environment. ```bash make start ``` ```bash # Terminal 1 — Backend go 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 frontend/node_modules frontend/.vite make init ``` -------------------------------- ### Initialize and run the Go application Source: https://github.com/deepgram-starters/go-text-intelligence/blob/main/README.md Use the Makefile to set up the environment and start the local server. Ensure the DEEPGRAM_API_KEY is configured in the .env file. ```bash make init cp sample.env .env # Add your DEEPGRAM_API_KEY make start ``` -------------------------------- ### Project Initialization and Development Commands Source: https://context7.com/deepgram-starters/go-text-intelligence/llms.txt Use these Makefile commands to manage project dependencies, start servers, and run tests. ```bash # Check prerequisites (git, go, pnpm) make check-prereqs # Initialize project (clone submodules + install dependencies) make init # Start both backend and frontend servers make start # Backend: http://localhost:8081 # Frontend: http://localhost:8080 # Start servers separately make start-backend # Go server on port 8081 make start-frontend # Vite dev server on port 8080 # Run conformance tests make test # Update frontend submodule to latest make update # Clean build artifacts make clean # Check repository and submodule status make status ``` -------------------------------- ### Conventional Commit Examples Source: https://github.com/deepgram-starters/go-text-intelligence/blob/main/AGENTS.md Standardized commit message formats for project version control. ```text feat(go-text-intelligence): add diarization support fix(go-text-intelligence): resolve WebSocket close handling refactor(go-text-intelligence): simplify session endpoint chore(deps): update frontend submodule ``` -------------------------------- ### Get Application Metadata Source: https://context7.com/deepgram-starters/go-text-intelligence/llms.txt Retrieves application metadata, including use case and framework information, from the configuration file. ```bash # Get metadata curl -X GET http://localhost:8081/api/metadata # Response: # { # "title": "Go Text Intelligence", # "description": "Get started using Deepgram's Text Intelligence with this Go demo app", # "author": "Deepgram DX Team (https://developers.deepgram.com)", # "repository": "https://github.com/deepgram-starters/go-text-intelligence", # } ``` -------------------------------- ### Get Application Metadata Source: https://context7.com/deepgram-starters/go-text-intelligence/llms.txt Returns application metadata from the `deepgram.toml` configuration file including use case, framework, and tags. ```APIDOC ## Get Application Metadata ### Description Returns application metadata from the `deepgram.toml` configuration file including use case, framework, and tags. ### Method GET ### Endpoint /api/metadata ### Request Example ```bash curl -X GET http://localhost:8081/api/metadata ``` ### Response #### Success Response (200) - **title** (string) - The title of the application. - **description** (string) - A description of the application. - **author** (string) - The author of the application. - **repository** (string) - The URL of the application's repository. #### Response Example ```json { "title": "Go Text Intelligence", "description": "Get started using Deepgram's Text Intelligence with this Go demo app", "author": "Deepgram DX Team (https://developers.deepgram.com)", "repository": "https://github.com/deepgram-starters/go-text-intelligence" } ``` ``` -------------------------------- ### Get Session Token Source: https://context7.com/deepgram-starters/go-text-intelligence/llms.txt Retrieves a signed HS256 JWT session token valid for one hour, required for subsequent API requests. ```bash # Get a session token curl -X GET http://localhost:8081/api/session # Response: # {"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."} # Store token for use in subsequent requests TOKEN=$(curl -s http://localhost:8081/api/session | jq -r '.token') echo "Session token: $TOKEN" ``` -------------------------------- ### Get Session Token Source: https://context7.com/deepgram-starters/go-text-intelligence/llms.txt Issues a signed JWT session token required for authenticating subsequent API requests. Tokens expire after 1 hour and use HS256 signing. ```APIDOC ## Get Session Token ### Description Issues a signed JWT session token required for authenticating subsequent API requests. Tokens expire after 1 hour and use HS256 signing. ### Method GET ### Endpoint /api/session ### Request Example ```bash curl -X GET http://localhost:8081/api/session ``` ### Response #### Success Response (200) - **token** (string) - The JWT session token. #### Response Example ```json { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." } ``` ``` -------------------------------- ### Environment Configuration Source: https://context7.com/deepgram-starters/go-text-intelligence/llms.txt Configure the server by copying the sample template and setting required environment variables. ```bash # sample.env - Copy to .env and configure DEEPGRAM_API_KEY=your_api_key_here # Required - get from https://console.deepgram.com PORT=8081 # Optional - backend server port HOST=0.0.0.0 # Optional - server bind address SESSION_SECRET=your_secret_here # Optional - JWT signing secret for production # Quick setup cp sample.env .env # Edit .env to add your DEEPGRAM_API_KEY ``` -------------------------------- ### Project Testing Commands Source: https://github.com/deepgram-starters/go-text-intelligence/blob/main/AGENTS.md Commands for running automated conformance tests and verifying 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 ``` -------------------------------- ### Analyze Text from URL Source: https://context7.com/deepgram-starters/go-text-intelligence/llms.txt Fetches and analyzes text content from a provided URL. This field is mutually exclusive with the text field. ```bash # Analyze content from a URL curl -X POST "http://localhost:8081/api/text-intelligence?summarize=true&topics=true&language=en" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "url": "https://example.com/article.txt" }' # Error response for invalid URL: # { # "error": { # "type": "validation_error", # "code": "INVALID_URL", # "message": "Failed to fetch URL: connection refused", # "details": {} # } # } ``` -------------------------------- ### Health Check Endpoint Source: https://context7.com/deepgram-starters/go-text-intelligence/llms.txt Use this endpoint to verify service availability for monitoring and orchestration. ```bash # Health check curl -X GET http://localhost:8081/health # Response: # {"status":"ok","service":"text-intelligence"} ``` -------------------------------- ### API Error Response Format Source: https://context7.com/deepgram-starters/go-text-intelligence/llms.txt Reference for the standardized error response structure returned by the API. ```bash # Missing authentication curl -X POST "http://localhost:8081/api/text-intelligence" \ -H "Content-Type: application/json" \ -d '{"text": "Hello"}' # Response (401): # { # "error": { # "type": "AuthenticationError", # "code": "MISSING_TOKEN", # "message": "Authorization header with Bearer token is required" # } # } # Invalid/expired token response (401): # { # "error": { # "type": "AuthenticationError", # "code": "INVALID_TOKEN", # "message": "Session expired, please refresh the page" # } # } # Missing text/url field (400): # { # "error": { # "type": "validation_error", # "code": "INVALID_TEXT", # "message": "Request must contain either 'text' or 'url' field", # "details": {} # } # } # Both text and url provided (400): # { # "error": { # "type": "validation_error", # "code": "INVALID_TEXT", # "message": "Request must contain either 'text' or 'url', not both", # "details": {} # } # } ``` -------------------------------- ### Selective Feature Analysis Source: https://context7.com/deepgram-starters/go-text-intelligence/llms.txt Enables specific analysis features independently via query parameters and supports language specification. ```bash # Summarization only (v2) curl -X POST "http://localhost:8081/api/text-intelligence?summarize=v2" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"text": "Your long text content here for summarization..."}' # Sentiment analysis only curl -X POST "http://localhost:8081/api/text-intelligence?sentiment=true" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"text": "This product exceeded my expectations. Highly satisfied!"}' # Topics and intents detection curl -X POST "http://localhost:8081/api/text-intelligence?topics=true&intents=true" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"text": "I want to book a flight to Paris next week for a business meeting."}' # Specify language (default: en) curl -X POST "http://localhost:8081/api/text-intelligence?summarize=true&language=es" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"text": "Tu texto en español aquí..."}' ``` -------------------------------- ### Analyze Text with Text Intelligence Source: https://context7.com/deepgram-starters/go-text-intelligence/llms.txt Performs comprehensive text analysis including summarization, topics, sentiment, and intent detection using the Read API. ```bash # Basic text analysis 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 absolutely love this new phone! The camera quality is amazing and the battery lasts all day. The only downside is the price, but I think it is worth every penny. I would definitely recommend this to anyone looking for a premium smartphone experience." }' # Response structure: # { # "results": { # "summary": { # "text": "The reviewer loves their new phone, praising the camera and battery life..." # }, # "topics": { # "segments": [{"topics": [{"topic": "smartphone", "confidence_score": 0.95}]}] # }, # "sentiments": { # "average": {"sentiment": "positive", "sentiment_score": 0.87}, # "segments": [...] # }, # "intents": { # "segments": [{"intents": [{"intent": "recommend", "confidence_score": 0.92}]}] # } # } # } ``` -------------------------------- ### Analyze Text with Text Intelligence Source: https://context7.com/deepgram-starters/go-text-intelligence/llms.txt Analyzes text content using Deepgram's Read API. Supports summarization, topic detection, sentiment analysis, and intent detection via query parameters. Requires JWT authentication. ```APIDOC ## Analyze Text with Text Intelligence ### Description Analyzes text content using Deepgram's Read API. Supports summarization, topic detection, sentiment analysis, and intent detection via query parameters. Requires JWT authentication. ### Method POST ### Endpoint /api/text-intelligence ### Query Parameters - **summarize** (boolean or string) - Required/Optional - Enable summarization. Can be `true` or `v2` for specific version. - **topics** (boolean) - Required/Optional - Enable topic detection. - **sentiment** (boolean) - Required/Optional - Enable sentiment analysis. - **intents** (boolean) - Required/Optional - Enable intent detection. - **language** (string) - Optional - Specify the language of the text (default: 'en'). ### Request Body - **text** (string) - Required - The text content to analyze. Mutually exclusive with `url`. - **url** (string) - Required - The URL of the content to analyze. Mutually exclusive with `text`. ### Request Example ```json { "text": "I absolutely love this new phone! The camera quality is amazing and the battery lasts all day. The only downside is the price, but I think it is worth every penny. I would definitely recommend this to anyone looking for a premium smartphone experience." } ``` ### Response #### Success Response (200) - **results** (object) - Contains the analysis results. - **summary** (object) - Summary of the text. - **text** (string) - The summarized text. - **topics** (object) - Detected topics. - **segments** (array) - Array of topic segments. - **topics** (array) - Array of detected topics within a segment. - **topic** (string) - The detected topic. - **confidence_score** (number) - The confidence score for the topic. - **sentiments** (object) - Sentiment analysis results. - **average** (object) - Overall sentiment. - **sentiment** (string) - The overall sentiment (e.g., 'positive', 'negative', 'neutral'). - **sentiment_score** (number) - The sentiment score. - **segments** (array) - Sentiment analysis for text segments. - **intents** (object) - Detected intents. - **segments** (array) - Array of intent segments. - **intents** (array) - Array of detected intents within a segment. - **intent** (string) - The detected intent. - **confidence_score** (number) - The confidence score for the intent. #### Response Example ```json { "results": { "summary": { "text": "The reviewer loves their new phone, praising the camera and battery life..." }, "topics": { "segments": [{"topics": [{"topic": "smartphone", "confidence_score": 0.95}]}] }, "sentiments": { "average": {"sentiment": "positive", "sentiment_score": 0.87}, "segments": [...] }, "intents": { "segments": [{"intents": [{"intent": "recommend", "confidence_score": 0.92}]}] } } } ``` #### Error Response (4xx/5xx) - **error** (object) - Contains error details. - **type** (string) - The type of error. - **code** (string) - The error code. - **message** (string) - A description of the error. - **details** (object) - Additional error details. #### Error Response Example ```json { "error": { "type": "validation_error", "code": "INVALID_URL", "message": "Failed to fetch URL: connection refused", "details": {} } } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.