### Start Backend Server Source: https://github.com/deepgram-starters/ruby-text-intelligence/blob/main/AGENTS.md Manually start the Ruby Sinatra backend server in a dedicated terminal. ```bash bundle exec ruby app.rb ``` -------------------------------- ### Initialize and Start Project Source: https://github.com/deepgram-starters/ruby-text-intelligence/blob/main/AGENTS.md Use these commands to set up the project dependencies and start both the backend and frontend servers. ```bash make init test -f .env || cp sample.env .env make start ``` -------------------------------- ### Initialize and Start the Application Source: https://github.com/deepgram-starters/ruby-text-intelligence/blob/main/README.md Use the Makefile to initialize the environment, configure the API key, and start the local server. ```bash make init cp sample.env .env # Add your DEEPGRAM_API_KEY make start ``` -------------------------------- ### Install Backend Dependencies Source: https://github.com/deepgram-starters/ruby-text-intelligence/blob/main/AGENTS.md Install Ruby backend dependencies using Bundler as defined in the Gemfile. ```bash bundle install ``` -------------------------------- ### Install Frontend Dependencies Source: https://github.com/deepgram-starters/ruby-text-intelligence/blob/main/AGENTS.md Install Node.js frontend dependencies using pnpm within the frontend directory. ```bash cd frontend && corepack pnpm install ``` -------------------------------- ### Environment Configuration Example Source: https://context7.com/deepgram-starters/ruby-text-intelligence/llms.txt Configure the application using environment variables in a `.env` file. Ensure you set your `DEEPGRAM_API_KEY`. ```bash # Create .env file from sample cp sample.env .env # Required: Deepgram API key (get from https://console.deepgram.com) DEEPGRAM_API_KEY=your_api_key_here # Optional: Backend server port (default: 8081) PORT=8081 # Optional: Server bind address (default: 0.0.0.0) HOST=0.0.0.0 # Optional: JWT signing secret for production (auto-generated if not set) SESSION_SECRET=your_secure_secret_here ``` -------------------------------- ### Start Frontend Server Source: https://github.com/deepgram-starters/ruby-text-intelligence/blob/main/AGENTS.md Manually start the Vite development server for the frontend in a separate terminal. Ensure you navigate to the frontend directory first. ```bash cd frontend && corepack pnpm run dev -- --port 8080 --no-open ``` -------------------------------- ### Conventional Commit Examples Source: https://github.com/deepgram-starters/ruby-text-intelligence/blob/main/AGENTS.md Standardized commit message formats for the project. Do not include Co-Authored-By lines. ```text feat(ruby-text-intelligence): add diarization support fix(ruby-text-intelligence): resolve WebSocket close handling refactor(ruby-text-intelligence): simplify session endpoint chore(deps): update frontend submodule ``` -------------------------------- ### Clean Rebuild Project Source: https://github.com/deepgram-starters/ruby-text-intelligence/blob/main/AGENTS.md Remove generated build artifacts and node modules, then re-initialize the project. Useful for a fresh start. ```bash rm -rf vendor frontend/node_modules frontend/.vite make init ``` -------------------------------- ### Get Application Metadata with cURL Source: https://context7.com/deepgram-starters/ruby-text-intelligence/llms.txt Retrieve application metadata, such as title, description, and author, by making a GET request to the `/api/metadata` endpoint. ```bash # Get application metadata curl -X GET http://localhost:8081/api/metadata ``` -------------------------------- ### Check Server Health with cURL Source: https://context7.com/deepgram-starters/ruby-text-intelligence/llms.txt Perform a health check on the server by sending a GET request to the `/health` endpoint. This is useful for monitoring and load balancer integration. ```bash # Check server health curl -X GET http://localhost:8081/health ``` -------------------------------- ### Makefile Commands for Project Management Source: https://context7.com/deepgram-starters/ruby-text-intelligence/llms.txt Utilize Makefile commands for initializing, building, and running the application. Remember to configure your `.env` file with your Deepgram API key. ```bash # Check prerequisites (git, ruby, bundler, pnpm) make check-prereqs # Initialize project: clone submodules and install all dependencies make init # Configure environment cp sample.env .env # Edit .env to add your DEEPGRAM_API_KEY # Start both backend and frontend servers make start # Backend runs at: http://localhost:8081 # Frontend runs at: http://localhost:8080 # Start servers separately make start-backend # Start only the backend API server make start-frontend # Start only the frontend dev server # Other useful commands make build # Build frontend for production make test # Run contract conformance tests make update # Update git submodules to latest make clean # Remove build artifacts make status # Show git and submodule status ``` -------------------------------- ### Project Testing Commands Source: https://github.com/deepgram-starters/ruby-text-intelligence/blob/main/AGENTS.md Commands for running conformance tests and verifying API endpoints. ```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 ``` -------------------------------- ### Docker Deployment Commands Source: https://context7.com/deepgram-starters/ruby-text-intelligence/llms.txt Commands to build and run the text intelligence application using Docker. Remember to replace placeholder API keys and secrets with your actual credentials. ```bash # Build the Docker image docker build -f deploy/Dockerfile -t text-intelligence . # Run the container docker run -d \ -p 8080:8080 \ -e DEEPGRAM_API_KEY=your_api_key_here \ -e SESSION_SECRET=your_secure_secret \ --name text-intelligence \ text-intelligence # Access the application at http://localhost:8080 # View logs docker logs -f text-intelligence # Stop and remove container docker stop text-intelligence && docker rm text-intelligence ``` -------------------------------- ### Update Frontend Submodule Source: https://github.com/deepgram-starters/ruby-text-intelligence/blob/main/AGENTS.md Commit changes made to the frontend code within the starter project and then update the git submodule reference. ```bash cd frontend && git add . && git commit -m "feat: description" cd .. && git add frontend && git commit -m "chore(deps): update frontend submodule" ``` -------------------------------- ### Summarize Text Source: https://context7.com/deepgram-starters/ruby-text-intelligence/llms.txt Generates a summary of provided text. Use 'v2' for the latest summarization model. ```bash # Generate a summary using the v2 model curl -X POST "http://localhost:8081/api/text-intelligence?summarize=v2" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "text": "Artificial intelligence has transformed numerous industries over the past decade. Machine learning algorithms now power recommendation systems, autonomous vehicles, and medical diagnostics. The rapid advancement of large language models has opened new possibilities for natural language processing and human-computer interaction. Companies worldwide are investing heavily in AI research and development." }' # Response: # { # "results": { # "summary": { # "text": "AI has revolutionized industries through machine learning applications in recommendations, autonomous vehicles, and healthcare, with significant investment in large language models and NLP." # } # } # } ``` -------------------------------- ### Detect Topics Source: https://context7.com/deepgram-starters/ruby-text-intelligence/llms.txt Identifies main subjects within the provided text content. ```bash # Detect topics in text curl -X POST "http://localhost:8081/api/text-intelligence?topics=true" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "text": "The new electric vehicle from Tesla features a 400-mile range battery and advanced autopilot capabilities. The Model S Plaid can accelerate from 0-60 mph in under 2 seconds, making it one of the fastest production cars ever made." }' # Response: # { # "results": { # "topics": { # "segments": [{ # "text": "The new electric vehicle from Tesla...", # "topics": [ # {"topic": "electric vehicles", "confidence": 0.97}, # {"topic": "Tesla", "confidence": 0.95}, ``` -------------------------------- ### Detect Intents with cURL Source: https://context7.com/deepgram-starters/ruby-text-intelligence/llms.txt Use this cURL command to detect user intents within customer messages. Enable intent detection by setting the `intents` parameter to `true` in the API request. ```bash # Detect intents in customer messages curl -X POST "http://localhost:8081/api/text-intelligence?intents=true" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "text": "I would like to cancel my subscription and get a refund for the unused portion. Can you also delete my account and all associated data?" }' ``` -------------------------------- ### Analyze Sentiment with cURL Source: https://context7.com/deepgram-starters/ruby-text-intelligence/llms.txt Use this cURL command to analyze the sentiment of provided text. Enable sentiment analysis by setting the `sentiment` parameter to `true` in the API request. ```bash # Analyze sentiment in customer feedback curl -X POST "http://localhost:8081/api/text-intelligence?sentiment=true" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "text": "The initial setup was frustrating and took much longer than expected. However, once everything was configured, the software performed beautifully. The support team was incredibly helpful when I reached out with questions." }' ``` -------------------------------- ### Generate Session Token Source: https://context7.com/deepgram-starters/ruby-text-intelligence/llms.txt Retrieves a JWT token for authenticating API requests. The token is valid for one hour. ```bash # Get a session token for authentication curl -X GET http://localhost:8081/api/session # Response: # {"token":"eyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3MDk4MjM0NTYsImV4cCI6MTcwOTgyNzA1Nn0.xxx"} # Store token for use in subsequent requests TOKEN=$(curl -s http://localhost:8081/api/session | jq -r '.token') echo "Session token: $TOKEN" ``` -------------------------------- ### Stop All Servers Source: https://github.com/deepgram-starters/ruby-text-intelligence/blob/main/AGENTS.md Terminate any running backend or frontend processes listening on ports 8080 and 8081. ```bash lsof -ti:8080,8081 | xargs kill -9 2>/dev/null ``` -------------------------------- ### Ruby Text Intelligence Client Source: https://context7.com/deepgram-starters/ruby-text-intelligence/llms.txt Use this client to analyze text with various Deepgram features. Ensure you have your Deepgram API key set as an environment variable. ```ruby require 'net/http' require 'json' require 'uri' class TextIntelligenceClient DEEPGRAM_READ_URL = 'https://api.deepgram.com/v1/read' def initialize(api_key) @api_key = api_key end def analyze(text:, summarize: false, topics: false, sentiment: false, intents: false, language: 'en') uri = URI.parse(DEEPGRAM_READ_URL) # Build query parameters params = { 'language' => language } params['summarize'] = 'true' if summarize params['topics'] = 'true' if topics params['sentiment'] = 'true' if sentiment params['intents'] = 'true' if intents uri.query = URI.encode_www_form(params) # Make request http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri) request['Authorization'] = "Token #{@api_key}" request['Content-Type'] = 'application/json' request.body = JSON.generate({ 'text' => text }) response = http.request(request) raise "API Error: #{response.code}" unless response.is_a?(Net::HTTPSuccess) JSON.parse(response.body) end end # Usage example client = TextIntelligenceClient.new(ENV['DEEPGRAM_API_KEY']) result = client.analyze( text: "This product exceeded my expectations. Great quality and fast shipping!", summarize: true, sentiment: true, intents: true ) puts "Summary: #{result.dig('results', 'summary', 'text')}" puts "Sentiment: #{result.dig('results', 'sentiments', 'average', 'sentiment')}" ``` -------------------------------- ### Analyze Text Content Source: https://context7.com/deepgram-starters/ruby-text-intelligence/llms.txt Performs text intelligence analysis on raw text or URLs. Requires a valid JWT token in the Authorization header. ```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 absolutely love this product! The customer service was exceptional and the delivery was fast. I would highly recommend this to anyone looking for quality."}' # Response: # { # "results": { # "summary": {"text": "The customer expresses strong satisfaction with the product, praising customer service and delivery speed."}, # "topics": {"segments": [{"topics": [{"topic": "product review", "confidence": 0.95}]}]}, # "sentiments": {"average": {"sentiment": "positive", "sentiment_score": 0.92}}, # "intents": {"segments": [{"intents": [{"intent": "recommend", "confidence": 0.88}]}]} # } # } # Analyze content from a URL curl -X POST "http://localhost:8081/api/text-intelligence?summarize=v2&sentiment=true" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"url": "https://example.com/article.html"}' # Analyze with specific language (default is English) curl -X POST "http://localhost:8081/api/text-intelligence?summarize=true&language=es" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"text": "Este producto es increĆ­ble. Lo recomiendo totalmente a todos."}' ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.