Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,23 @@ Feedback reactions produce: `feedback.receive_reaction` → `feedback.analyze`
| `reddit_digest.feedback.reactions` | Counter | | Reactions received (`reaction_type`: `like`/`dislike`) |
| `reddit_digest.feedback.preference_updates` | Counter | | Preference updates from feedback |

### Local observability stack

A full Docker Compose stack (OTel Collector, Tempo, Prometheus, Grafana, Phoenix) is available for local development. See [`docker-compose/observability-stack/`](docker-compose/observability-stack/) for setup instructions.

## Deploy with Docker
## Deploy agent with Docker

```bash
docker build -t reddit-digest-agent .
docker run -d --env-file .env --name reddit-digest reddit-digest-agent
```

## Deploy agent with Docker Compose

### Local LocalAI stack

A Docker Compose stack that runs the agent against a self-hosted [LocalAI](https://localai.io/) server preloading `google/gemma-3-4b-it`, so the digest can be produced without any external LLM provider. See [`docker-compose/localai-stack/`](docker-compose/localai-stack/) for setup instructions.

### Local observability stack

A full Docker Compose stack (OTel Collector, Tempo, Prometheus, Grafana, Phoenix) is available for local development. See [`docker-compose/observability-stack/`](docker-compose/observability-stack/) for setup instructions.

## Development

```bash
Expand Down
62 changes: 62 additions & 0 deletions docker-compose/localai-stack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# LocalAI Stack

Local Docker Compose stack that runs the reddit-digest-agent against a self-hosted [LocalAI](https://localai.io/) inference server serving `google/gemma-3-4b-it`.

Copilot AI Apr 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README mentions serving google/gemma-3-4b-it, but the rest of this stack (compose MODELS/LLM_MODEL and the example /v1/chat/completions payload) uses gemma-3-4b-it. Please align the model identifier in the docs with the actual model name that LocalAI exposes (either update this line to gemma-3-4b-it or update the compose/examples accordingly).

Suggested change
Local Docker Compose stack that runs the reddit-digest-agent against a self-hosted [LocalAI](https://localai.io/) inference server serving `google/gemma-3-4b-it`.
Local Docker Compose stack that runs the reddit-digest-agent against a self-hosted [LocalAI](https://localai.io/) inference server serving `gemma-3-4b-it`.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +3

Copilot AI Apr 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description says documentation was added to the repository root README.md, but this PR adds docs under docker-compose/localai-stack/README.md only. Please either update the PR description or add a short pointer in the root README so users can discover this stack.

Copilot uses AI. Check for mistakes.

## Architecture

```
Agent --OpenAI API--> LocalAI (gemma-3-4b-it)
```

The agent talks to LocalAI over its OpenAI-compatible endpoint, so no external LLM provider is required.

## Prerequisites

- Docker and Docker Compose
- A configured `.env` file at the repository root (see `.env.example`). `OPENAI_BASE_URL` and `LLM_MODEL` from the file are overridden by this stack.
- ~3 GB of free disk space for the gemma-3-4b-it model weights (downloaded on first start and cached in the `localai-models` volume).

## Quick Start

```bash
# From this directory
docker compose up --build

# Or from the repository root
docker compose -f docker-compose/localai-stack/docker-compose.yml up --build
```

On the first run LocalAI downloads the `gemma-3-4b-it` weights from its gallery — expect a few minutes before the healthcheck turns green. The agent is blocked on `localai: service_healthy` and will only start once the model is ready.

The agent runs a single digest iteration (`--once`) and exits. LocalAI keeps running so you can query it directly or trigger another digest.

## Services

| Service | URL | Description |
|---------|-----|-------------|
| LocalAI | http://localhost:8080 | OpenAI-compatible inference API (`/v1/chat/completions`, `/v1/models`, …) |
Comment on lines +35 to +37

Copilot AI Apr 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The markdown table under “Services” has an extra leading | on each row (|| ...), which breaks table rendering in most Markdown parsers. Change those lines to start with a single |.

Copilot uses AI. Check for mistakes.

## Re-run the Agent

```bash
docker compose run --rm agent
```

## Probe LocalAI directly

```bash
curl http://localhost:8080/v1/models
curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model":"gemma-3-4b-it","messages":[{"role":"user","content":"Hello"}]}'
```

## Tear Down

```bash
# Stop the stack (keeps the model cache)
docker compose down

# Stop and also remove the model cache volume
docker compose down -v
```
34 changes: 34 additions & 0 deletions docker-compose/localai-stack/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
services:
localai:
image: localai/localai:latest
ports:
- "8080:8080"
environment:
- MODELS=gemma-3-4b-it
- THREADS=4
volumes:
- localai-models:/build/models
healthcheck:
test: ["CMD-SHELL", "curl -sf http://localhost:8080/readyz || exit 1"]
interval: 30s
timeout: 10s
retries: 40
start_period: 300s

agent:
build:
context: ../..
dockerfile: Dockerfile
env_file:
- ../../.env
environment:
- OPENAI_API_KEY=localai
- OPENAI_BASE_URL=http://localai:8080/v1
- LLM_MODEL=gemma-3-4b-it
command: ["python", "-m", "reddit_digest.main", "--once"]
depends_on:
localai:
condition: service_healthy

volumes:
localai-models: