GitHub

LLM Helpers

AI-assisted functions for extracting version numbers and download URLs from unstructured sources. These helpers use a local LLM to parse complex web pages.

Overview

LLM helpers are useful when version numbers or download URLs aren't available via a clean API (like GitHub releases). They fetch a web page and use AI to extract the information. Requires a local LLM configured via RECIPE_LLM_ENDPOINT.

llm_extract

Extract arbitrary information from a web page using a natural language prompt.

let result = llm_extract(
    "https://example.com/downloads",
    "Find the SHA256 checksum for the Linux x86_64 download"
);

llm_find_latest_version

Find the latest version number from a download page. The LLM parses the page and returns just the version string.

fn check_update() {
    // For software without GitHub releases
    let latest = llm_find_latest_version("https://example.com/downloads/");
    if latest != ctx.version {
        latest
    } else {
        ()
    }
}

llm_find_download_url

Find the download URL for a specific version and platform. Useful for complex download pages.

fn acquire(ctx) {
    let url = llm_find_download_url(
        "https://example.com/downloads/",
        ctx.version,
        "Linux x86_64 tarball"
    );
    let archive = download(url, join_path(BUILD_DIR, ctx.name + ".tar.gz"));
    // ...
}

When to Use

Prefer structured APIs when available:

Source Use
GitHub releases github_latest_release(), github_download_release()
GitHub tags github_latest_tag()
Direct URLs download()
Unstructured pages llm_* helpers

LLM helpers are slower and require a local LLM, so only use them when no structured alternative exists.

Configuration

Set the RECIPE_LLM_ENDPOINT environment variable to your local LLM server:

export RECIPE_LLM_ENDPOINT="http://localhost:11434/v1"