CoolFace
Apppublic

LiberoSports/FPLAIManager

sourceHugging Faceupdated 1mo agoView on Hugging Face
0likes
App README

FPL AI Manager

FPL AI Manager is a Gradio application for season-long Fantasy Premier League decision support. It retrieves and validates current public data from the official Fantasy Premier League API, then keeps facts, analytics, optimisation, simulations, decision memory, and conversational explanation in deliberately separate layers. [1]

Data principle: official FPL facts and deterministic model outputs are shown separately. The chat assistant receives only a structured evidence bundle and is not permitted to invent statistics, fixtures, injuries, prices, or set-piece assignments.

Product capabilities

AreaImplemented behaviourData-confidence treatment
Official dataValidated bootstrap-static, fixtures, player summary, live event, entry history, transfer, and entry-picks client methods with retries and an atomic TTL cacheReports network, cache, or stale-cache source; fails visibly without usable data
Player analysisExpected minutes, fixture windows, expected-point MVP projection, value, underlying-stat, threat, defensive, differential, rotation, hidden-gem, and attacking-defender metricsEvery scorecard carries visible component fields and a confidence level
Initial squadMixed-integer 15-player optimiser using budget, 2/5/5/3 position counts, and a three-per-club cap from the current FPL game settingsPre-season proposal; not a connected user entry
Weekly selectionLegal formation, bench ordering, captain, vice-captain, alternative captain, roll, and single-transfer recommendationsShows projection horizon, transfer cost, minutes, and fixture drivers
Chips and scenariosConservative chip save/use logic plus 1/3/5/8-gameweek transfer/captain/chip comparisonsWildcard and Free Hit require a user-supplied rebuilt squad to simulate their full effect
MemorySQLite-backed manager preferences, squad snapshots, and immutable decision rationaleDurable only when FPL_STATE_DB points to persistent storage
ChatOptional OpenAI-compatible explainer using the current verified gpt-5-mini default, overridable through LLM_MODELSafe structured fallback when no LLM secret is configured
InterfaceAll requested management tabs: My Team, Ask the FPL AI, Transfers, Captain, Chips, Hidden Gems, Set Pieces, Attacking Defenders, Fixtures, Time Machine, Compare Players, and Player RankingsDisplays current data freshness and pre-season limitations

Run locally

Use Python 3.11 or later. The commands below create an isolated environment, install all declared requirements, and run the Space launch command.

bash
cd fpl-ai-manager
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python app.py

Gradio normally serves the interface at http://127.0.0.1:7860. Select Refresh official FPL data to bypass the 15-minute cache. The first dashboard load builds a legal modelled squad from the current official snapshot.

Configuration

Copy the template only for local work. Never commit actual secrets.

bash
cp .env.example .env
VariablePurposeRequired
FPL_API_BASE_URLOfficial FPL API root; defaults to the public official endpointNo
FPL_CACHE_TTL_SECONDSRaw-data cache duration, default 900 secondsNo
FPL_STATE_DBSQLite database path for preferences, snapshots, and decisionsNo locally; yes for durable deployment
OPENAI_API_KEYOpenAI-compatible API key for optional chat narrationNo
LLM_MODELConversational model ID; defaults to verified gpt-5-miniNo

Validate before deployment

The offline tests do not depend on FPL network availability. The diagnostic and dashboard smoke test then exercise the current public API contract and full analytical bundle.

bash
pytest -q
python scripts/validate_fpl_api.py --refresh
python scripts/smoke_dashboard.py

To inspect entry-specific endpoint availability for a public FPL team, pass an explicit team ID. Pre-season picks can legitimately be unavailable before the official game exposes them; the client reports that condition rather than producing a fabricated squad.

bash
python scripts/validate_fpl_api.py --refresh --entry-id YOUR_FPL_TEAM_ID

Deploy to Hugging Face Spaces

Create a new Gradio Space on Hugging Face, clone its repository, and copy this project's files into the cloned repository root.

bash
git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
cp -R fpl-ai-manager/. YOUR_SPACE_NAME/
cd YOUR_SPACE_NAME
git add .
git commit -m "Deploy FPL AI Manager"
git push

Hugging Face reads the YAML metadata at the top of this README, installs requirements.txt, and starts app.py. The official FPL API is public and therefore needs no secret. To enable chat, add OPENAI_API_KEY and optionally LLM_MODEL through Space Settings → Variables and secrets; do not put them in the repository.

Choose season-memory storage before production

A long-running manager needs a durable state location. Choose one of the following paths before relying on preferences or decision history; then set FPL_STATE_DB accordingly.

ApproachTrade-offsCostSetup complexity
Persistent Space storage with the SQLite implementationSimplest for a single private manager; requires the Space’s persistent disk to be enabled and mountedDepends on the Space storage planLow
External managed database with a future repository adapterMore suitable for multiple users and independent backups; needs provider credentials and a database migrationProvider-dependentMedium

The default repository-local .data directory is suitable for development only. It must not be treated as production season memory on non-persistent Space disk.

Current product boundaries

The application intentionally does not claim information it cannot verify. As of the current pre-season FPL response, the underlying performance model is low confidence until official current-season minutes accumulate. The Set Pieces tab remains source-gated until an explicitly sourced provider is configured. The transfer dashboard analyses the modelled initial squad; connecting a user’s official entry requires entering a public entry ID once the FPL picks endpoint is available for the gameweek. These boundaries are explicit rather than silently filled with speculation.

Detailed data contracts, scoring methodology, optimisation rules, scenario design, memory design, and source-provenance rules are in `docs/architecture.md`.

References

[1] Official Fantasy Premier League API — current bootstrap data