Skip to content

About

Use AI to automate your initial research phase.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

BlockQuote Persona Service

Backend scaffolding for generating civic personas, simulating reactions to housing plans, and producing scenario summaries.

Quickstart

  1. Install dependencies:
    pip install -r requirements.txt
  2. Provide your OpenAI credentials (optional for mock mode):
    # .env
    BLOCKQUOTE_OPENAI_API_KEY=sk-...
    BLOCKQUOTE_OPENAI_MODEL=gpt-4.1-mini  # override if desired
  3. Launch the API:
    uvicorn backend.app:app --reload
  4. Test the persona pipeline:
    curl -X POST http://127.0.0.1:8000/api/personas/generate \
      -H "Content-Type: application/json" \
      -d @./example_payload.json

If an API key is not supplied, the service falls back to deterministic mock personas/responses backed by the Jacksonville census CSV in data/jacksonville.csv. SQLite persistence writes to blockquote.db in the project root.

Endpoint

  • POST /api/personas/generate
    • Body:
      {
        "city": "Jacksonville",
        "census_tracts": ["12031000100"],
        "persona_count": 8,
        "housing_plan": "Build 120 mixed-income apartments...",
        "seed": 42
      }
    • Response:
      {
        "session_id": "474ce8d3-0b46-43ac-8342-f96752ff371b",
        "personas": [ ... ],
        "responses": [ ... ],
        "summary": { ... } // may be null if no personas
      }

Mock generation supports reproducible seeds; OpenAI mode ignores the seed.

  • GET /api/sessions
    Returns recent sessions with metadata (city, tract list, timestamps).

  • GET /api/sessions/{session_id}
    Loads a full session pack (personas, responses, summary) from the database.

  • POST /api/sessions/{session_id}/personas
    Adds a persona (accepts the full persona payload) and immediately generates a new reaction + refreshed summary.

  • PATCH /api/sessions/{session_id}/personas/{persona_id}
    Updates specific persona fields, regenerating that persona's reaction and the session summary.

  • DELETE /api/sessions/{session_id}/personas/{persona_id}
    Removes a persona and returns the updated session snapshot.

  • POST /api/sessions/{session_id}/responses/regenerate
    Re-runs persona reactions for the whole session or a supplied subset. Optionally skip summary regeneration by setting refresh_summary to false.

  • GET /api/sessions/{session_id}/messages
    Fetches the summary-agent thread (default) or a specific persona thread by supplying persona_id.

  • POST /api/sessions/{session_id}/messages
    Sends a user message to the summary agent (omit persona_id) or to a specific persona (include persona_id); both user and AI messages are persisted.

The API auto-creates tables on startup. Delete blockquote.db to reset state during development.

Frontend Workflow

  1. Sessions – landing page lists prior scenarios and offers a “New Session” button.
  2. Create – form collects city, housing plan, persona count, and optional census tracts before triggering persona generation.
  3. Curate – review, edit, add, or remove personas before locking the scenario.
  4. Dashboard – explore persona decisions, chat with the summary agent, and message individual personas.

Configure the frontend with VITE_API_BASE_URL (defaults to http://localhost:8000) and run npm run dev.

About

Use AI to automate your initial research phase.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages