Skip to main content

Purpose

Samples prompts for daily visibility checking, prioritizing prompts that have never been tested.

Architecture

Query Parameters

ParameterTypeDefaultDescription
org_slugstringrequiredOrganization identifier
sample_sizeint10Number of prompts to sample

Sampling Algorithm

  1. Get all prompts for the organization
  2. Separate into untested (last_tested_at IS NULL) and tested
  3. Prioritize untested - take as many as possible up to sample_size
  4. Fill remaining with random tested prompts
This ensures all prompts eventually get tested while prioritizing new ones.

Response Format

{
  "status": "success",
  "org_slug": "org-slug-123",
  "total_prompts": 50,
  "untested_count": 15,
  "sample_size": 10,
  "prompts": [
    {
      "id": 123,
      "prompt": "best payment gateway for startups",
      "entity_id": "uuid-...",
      "entity_name": "Acme Corp",
      "entity_type": "business"
    }
  ]
}

Code Location

src/app/apis/cron/sample_prompts/routes.py

Used By

Daily cron job that:
  1. Samples prompts with this endpoint
  2. Runs visibility analysis on each
  3. Updates last_tested_at timestamp