Golly League Dashboard

The Golly League Dashboard is a Streamlit-based interface designed to facilitate conversations with the "assimilated collective consciousness" of a fictional sports league.

It utilizes Google Gemini's Context Caching to load massive amounts of historical data (100 seasons of game outcomes) and narrative lore once, creating a low-latency, high-context conversational agent that can adopt specific personas (e.g., "The Archivist" or "The Collective").

Key Features

  • Neural Link (Context Caching): Upload large datasets (CSV outcomes + TXT lore) to Google Gemini once and reference them via a Cache ID for the duration of a session, avoiding repetitive token costs.
  • Persona Configuration: Create and manage distinct "Chat Managers" with unique system prompts. Switch between an objective historian and an emotional, biased fan collective.
  • Session Management: Create, store, and revisit chat sessions. History is saved locally as JSON.
  • Telemetry & Logging: All API interactions (requests, configurations, and responses) are logged to api_logs.jsonl for offline analysis and debugging.

Tech Stack

  • Frontend: Streamlit
  • AI Engine: Google Gen AI SDK (Gemini 2.5 Flash)
  • Data Storage: Local JSON (Configs/Chat History) & CSV/TXT (Ingestion)

Project Structure

/golly-league-dashboard
├── app.py                  # Main entry point (Landing Page)
├── utils.py                # Core logic: API wrappers, Caching, Logging, JSON handling
├── requirements.txt        # Python dependencies
├── manager_config.json     # (Auto-generated) Stores persona configurations
├── api_logs.jsonl          # (Auto-generated) Raw API telemetry logs
├── chat_history/           # (Auto-generated) Directory for saved chat sessions
└── pages/
    ├── 1_Data_Upload.py    # Interface to upload files & create Context Cache
    ├── 2_Configuration.py  # Interface to create/edit Chat Managers
    └── 3_Chat.py           # The main conversational interface

Setup & Installation

1. Prerequisites

  • Python 3.10+
  • A Google Cloud Project with the Gemini API enabled.
  • An API Key from Google AI Studio.

2. Installation

Clone the repository (or create the folder) and install the dependencies:

pip install -r requirements.txt

3. Environment Configuration

Set your API key as an environment variable.

Mac/Linux:

export GEMINI_API_KEY="your_api_key_here"

Windows (PowerShell):

$env:GEMINI_API_KEY="your_api_key_here"

Note: You can also enter the key manually in the UI if not set in the environment.

Usage Guide

Start the dashboard:

streamlit run app.py

Workflow

  1. Step 1: Data Upload (Page 1)

    • Navigate to Data Upload.
    • Upload your outcomes.csv (Game Data) and lore.txt (Team Histories).
    • Click Process & Cache. Copy the generated Context Cache ID (or let the app auto-store it in the session).
  2. Step 2: Configure Managers (Page 2)

    • Navigate to Configuration.
    • Create a new Manager (e.g., "The Archivist").
    • Paste the Context Cache ID you generated in Step 1.
    • Write a System Prompt defining their personality (or use the provided templates).
    • Save the Manager.
  3. Step 3: Chat (Page 3)

    • Navigate to Chat.
    • Select your Manager from the dropdown.
    • Start asking questions about the league's history ("Who won Season 43?") or culture ("What do the fans think of the rival team?").

Logging

All interactions with the Gemini API are logged to api_logs.jsonl in the root directory. Each entry contains:

  • Timestamp
  • Model configuration
  • Full input context (content sent to API)
  • Raw response text
  • Error messages (if any)
Description
No description provided
Readme 34 KiB
Languages
Python 100%