Skip to content
Draft
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
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ service keys.
| [A Stripe Link checkout with an SIE fraud-risk gate](./stripe-link-fraud) | Wiring all three SIE primitives into a pre-authorization fraud-risk gate that runs in the same round-trip as the Stripe PaymentIntent | `extract`, `encode`, `score` | Docker Compose plus Node UI; Stripe test-mode keys optional (runs in mock mode without them) | Runnable demo |
| [Vision-first document RAG](./vision-doc-rag) | Retrieving and answering questions over a multi-tenant page corpus by looking at page images — including scanned drawings — with OCR kept out of the score path | `encode`, `chat/completions`, `score` (optional) | GPU SIE deployment required: ColQwen2.5 retriever + Qwen3.5-4B answer model (runs on the generation bundle) | Runnable demo |
| [Multi-model contract review with the OpenAI Agents SDK](./contract-review-agent) | Running an OpenAI Agents SDK agent whose every model call — triage, orchestration, vision, OCR, embeddings, rerank, entity extraction, text-to-SQL, reasoning, and a safety guardrail — is served by one SIE cluster, each step on the right catalog model, with per-model observability | `chat/completions`, `encode`, `score`, `extract` | GPU SIE deployment required; standalone `uv` project; real contracts fetched from CUAD (CC BY 4.0) | Runnable demo |
| [AI Patronus browser memory](./ai-patronus-browser-memory) | Building a browser companion that saves pages on request and recalls them semantically | OpenAI-compatible `/v1/embeddings` | Local SIE Docker image plus Chrome extension and FastAPI bridge | Runnable demo |

For docs publishing, lead with the quickest runnable demos, then use the
benchmark and evaluation examples for deeper technical users.
Expand Down
7 changes: 7 additions & 0 deletions examples/ai-patronus-browser-memory/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.env
.venv/
__pycache__/
memory_server/data/
memory_server/.env
memory_server/.venv/
extension/config.local.js
147 changes: 147 additions & 0 deletions examples/ai-patronus-browser-memory/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# AI Patronus browser memory

AI Patronus is a Chrome extension that lets a small browser companion remember
pages on request and recall them semantically through SIE embeddings.

This example focuses on a privacy-preserving memory loop:

1. The user asks Patronus to `remember this page`.
2. The extension sends the current page title, URL, and readable text to a local
memory bridge.
3. The bridge calls SIE's OpenAI-compatible `/v1/embeddings` endpoint and stores
the vector locally.
4. The user asks `what did I save about browser memory?` and Patronus returns the
closest saved pages.

No browser history is uploaded automatically. The save action is manual, and the
default setup runs against a local SIE server with local JSON storage.

## SIE primitives

| Flow | Endpoint | Model |
|---|---|---|
| Page memory | `/v1/embeddings` | `sentence-transformers/all-MiniLM-L6-v2` |
| Semantic recall | `/v1/embeddings` + local cosine similarity | `sentence-transformers/all-MiniLM-L6-v2` |

The Chrome extension also contains optional hooks for chat, voice, and web
research providers from the original hackathon prototype, but the SIE memory
flow works without those keys.

## Run it locally

You need Docker, Python 3.12, and Chrome.

Start SIE:

```bash
docker run -p 8080:8080 -v sie-hf-cache:/app/.cache/huggingface ghcr.io/superlinked/sie-server:latest-cpu-default
```

Start the memory bridge:

```bash
cd examples/ai-patronus-browser-memory/memory_server
python -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
uvicorn app:app --reload --port 8800
```

Load the extension:

1. Open `chrome://extensions`.
2. Enable Developer mode.
3. Choose **Load unpacked**.
4. Select `examples/ai-patronus-browser-memory/extension`.
5. Open the Patronus popup and set `Superlinked URL` to `http://localhost:8800`.

Try it on any normal website:

```text
remember this page
what did I save about browser memory?
```

You can also seed sample memories after the memory bridge is running:

```bash
cd examples/ai-patronus-browser-memory/memory_server
python seed_sample.py
```

Then ask:

```text
what did I save about privacy?
```

## Configuration

The memory bridge reads `memory_server/.env`:

| Variable | Default | Purpose |
|---|---|---|
| `SIE_URL` | `http://localhost:8080` | SIE endpoint |
| `SIE_API_KEY` | empty | Optional bearer token for auth-enabled SIE clusters |
| `SIE_EMBED_MODEL` | `sentence-transformers/all-MiniLM-L6-v2` | Embedding model |
| `PATRONUS_MEMORY_PATH` | `data/memory.json` | Local memory store |
| `PATRONUS_MAX_TEXT_CHARS` | `12000` | Per-page text cap |

The extension popup can store optional provider keys in Chrome local storage.
For a hosted/auth-enabled SIE memory endpoint, add that endpoint's origin to
`extension/manifest.json` `host_permissions` before loading the extension.

## API

The local bridge exposes:

### `POST /ingest`

```json
{
"title": "Example page",
"url": "https://example.com",
"text": "Page text to remember"
}
```

### `POST /query`

```json
{
"query": "browser memory",
"limit": 5
}
```

Response:

```json
{
"results": [
{
"title": "Example page",
"url": "https://example.com",
"text": "Short excerpt...",
"score": 0.82
}
]
}
```

## Project layout

```text
ai-patronus-browser-memory/
├── extension/ # Manifest V3 Chrome extension
└── memory_server/ # FastAPI bridge from extension to SIE embeddings
```

## Privacy notes

- The extension sends page text only when the user explicitly asks it to
remember the page.
- The bridge stores memories locally by default in `memory_server/data/`.
- Do not enable automatic history ingestion without explicit consent, filtering,
and deletion controls.
Loading