Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
5a6aa57
address update
Viehzeug Mar 24, 2025
f55632c
guardrails structure
Viehzeug Mar 24, 2025
5bdb911
trace button
Viehzeug Mar 25, 2025
c151ee9
guardrail docs WIP
Viehzeug Mar 31, 2025
f7edda8
Merge branch 'main' into guardrails
Viehzeug Mar 31, 2025
cbffc55
scaffolding
lbeurerkellner Apr 1, 2025
82d89f1
more style
lbeurerkellner Apr 3, 2025
575b4f8
build images for guardrails docs
lbeurerkellner Apr 3, 2025
01c6f8b
ls
lbeurerkellner Apr 3, 2025
dc7be2b
relative image path
lbeurerkellner Apr 3, 2025
ad0de3a
landing page
lbeurerkellner Apr 3, 2025
8e6c723
button fixes
Viehzeug Apr 3, 2025
0b9b145
tool calls documentation
lbeurerkellner Apr 3, 2025
3bbbe5d
dataflow figure
lbeurerkellner Apr 3, 2025
dc53446
more content
lbeurerkellner Apr 3, 2025
0aa52c2
fix arrow operator
lbeurerkellner Apr 3, 2025
cbe856c
fix parameter names
lbeurerkellner Apr 3, 2025
93d12d2
Merge branch 'guardrails' of github.com:invariantlabs-ai/docs into gu…
Viehzeug Apr 7, 2025
1036f0c
highlighting enabled
Viehzeug Apr 7, 2025
8786f53
style + content
lbeurerkellner Apr 7, 2025
2198d4c
Merge branch 'guardrails' of github.com:invariantlabs-ai/docs into gu…
lbeurerkellner Apr 7, 2025
b908eaa
loops, improved playgrounds
lbeurerkellner Apr 10, 2025
6f8183d
dynamic base url
lbeurerkellner Apr 10, 2025
dc85818
fix urls
lbeurerkellner Apr 10, 2025
17813dc
fix relative paths
lbeurerkellner Apr 10, 2025
bc3dd93
add site_url
lbeurerkellner Apr 10, 2025
e1c0023
code validation chapter
lbeurerkellner Apr 11, 2025
503e3a5
add consistent '.' for examples.
knielsen404 Apr 4, 2025
ae9c0bb
add initial pii doc
knielsen404 Apr 8, 2025
8da5fdb
wip images
knielsen404 Apr 8, 2025
0c6a795
add templates
knielsen404 Apr 11, 2025
111a25f
code validation refactoring
lbeurerkellner Apr 14, 2025
c8ca54c
docs: dataflow
lbeurerkellner Apr 14, 2025
209b51d
image updates
lbeurerkellner Apr 14, 2025
b97ed33
add examples
knielsen404 Apr 14, 2025
132c3cc
Merge branch 'guardrails' of https://github.com/invariantlabs-ai/docs…
knielsen404 Apr 14, 2025
268fa4d
add more fields
knielsen404 Apr 14, 2025
d5b9581
docs: guardrails in explorer
lbeurerkellner Apr 14, 2025
912d72c
Merge branch 'guardrails' of github.com:invariantlabs-ai/docs into gu…
lbeurerkellner Apr 14, 2025
9a69c05
styles
lbeurerkellner Apr 14, 2025
c2d38e6
include frontmatter
lbeurerkellner Apr 14, 2025
7a0b35a
figure style
lbeurerkellner Apr 14, 2025
106160e
icons
lbeurerkellner Apr 15, 2025
fabc50d
more icons + some rule reference
lbeurerkellner Apr 15, 2025
1522c83
rule writing reference of many examples
lbeurerkellner Apr 15, 2025
e4cdd30
improved reference
lbeurerkellner Apr 15, 2025
48ad5af
agent basics
lbeurerkellner Apr 15, 2025
36a5e46
add text to moderation
knielsen404 Apr 15, 2025
6efb32f
update copyright
knielsen404 Apr 15, 2025
f63d7d5
update secrets
knielsen404 Apr 15, 2025
c6a0ce1
correct typos
knielsen404 Apr 15, 2025
f42be36
update parser badge text
knielsen404 Apr 15, 2025
1623520
update prompt injection
knielsen404 Apr 15, 2025
394a515
regex chapter
lbeurerkellner Apr 15, 2025
2eb36c5
Merge branch 'guardrails' of github.com:invariantlabs-ai/docs into gu…
lbeurerkellner Apr 15, 2025
0b8c14e
correctness pass - agent guardrails, intro, basics
knielsen404 Apr 16, 2025
a7f69aa
minor tweaks
lbeurerkellner Apr 16, 2025
effa3d3
Merge branch 'guardrails' of github.com:invariantlabs-ai/docs into gu…
lbeurerkellner Apr 16, 2025
3d91814
tweaks
lbeurerkellner Apr 16, 2025
a679b57
typos
knielsen404 Apr 16, 2025
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
Binary file modified .DS_Store
Binary file not shown.
26 changes: 26 additions & 0 deletions .github/workflows/docs-guardrails.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Documentation Docker Image

on:
push:
branches: ["guardrails"]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Build Docs
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
tags: ghcr.io/${{ github.repository }}/docs:guardrails
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
__pycache__/mkdocs_config.cpython-312.pyc
__pycache__
visited.log
contents.txt
broken-links.txt
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ RUN mkdocs build --clean

# serve the documentation if DEV_MODE is set, otherwise, serve built documentation
# for prod serving, we copy everything to root/docs/, as this is where the docs are actually served from in the container
CMD if [ "$DEV_MODE" = "true" ]; then mkdocs serve -a 0.0.0.0:8000; else mkdocs build; mkdir -p root; mv site root/docs; cd root; python -m http.server 8000 --bind 0.0.0.0; fi
CMD if [ "$DEV_MODE" = "true" ]; then mkdocs serve -a 0.0.0.0:8000; else mkdocs build; mkdir -p root; mv site root/docs-guardrails; cd root; python -m http.server 8000 --bind 0.0.0.0; fi
96 changes: 96 additions & 0 deletions check-links.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import asyncio
from playwright.async_api import async_playwright
from urllib.parse import urljoin, urldefrag
from collections import deque
import aiofiles

BASE_URL = "http://localhost:8000"
LOG_FILE = "visited.log"
BROKEN_FILE = "broken-links.txt"
CONTENTS_FILE = "contents.txt"


async def check_page(page, source_url):
url = page.url
html = await page.content()

# Save page content
async with aiofiles.open(CONTENTS_FILE, "a") as f:
await f.write(html)

# Check for 404
if "<h1>404 - Not found</h1>" in html:
async with aiofiles.open(BROKEN_FILE, "a") as f:
await f.write(f"[404] {url} (linked from {source_url})\n")

# Broken image sources
bad_imgs = await page.eval_on_selector_all(
"img[src]",
"""els => els
.map(e => ({ src: e.src, complete: e.complete, naturalWidth: e.naturalWidth }))
.filter(e => !e.complete || e.naturalWidth === 0)
.map(e => e.src)""",
)
if bad_imgs:
async with aiofiles.open(BROKEN_FILE, "a") as f:
for img in bad_imgs:
await f.write(f"[Broken IMG] {img} on {url}\n")

# Check anchor hrefs
anchors = await page.eval_on_selector_all("a[href]", "els => els.map(e => e.href)")
for link in anchors:
link_url, _ = urldefrag(urljoin(url, link))
if not link_url.startswith(BASE_URL):
continue
try:
res = await page.context.request.get(link_url)
if res.status >= 400:
async with aiofiles.open(BROKEN_FILE, "a") as f:
await f.write(
f"[Broken LINK] {link_url} on {url} (status {res.status})\n"
)
except Exception as e:
async with aiofiles.open(BROKEN_FILE, "a") as f:
await f.write(f"[Broken LINK] {link_url} on {url} (error {e})\n")


async def crawl(base_url):
visited = set()
queue = deque([(base_url, "(start)")])

async with async_playwright() as p:
browser = await p.chromium.launch()
context = await browser.new_context()
page = await context.new_page()

async with aiofiles.open(LOG_FILE, "w") as log_file:
while queue:
raw_url, source_url = queue.popleft()
url, _ = urldefrag(raw_url)

if url in visited or not url.startswith(base_url):
continue
visited.add(url)

try:
await page.goto(url)
await check_page(page, source_url)
await log_file.write(url + "\n")
await log_file.flush()

links = await page.eval_on_selector_all(
"a[href]", "els => els.map(e => e.href)"
)
for link in links:
abs_link, _ = urldefrag(urljoin(url, link))
if abs_link.startswith(base_url) and abs_link not in visited:
queue.append((abs_link, url))

except Exception as e:
print(f"Error visiting {url}: {e}")

await browser.close()


if __name__ == "__main__":
asyncio.run(crawl(BASE_URL))
41 changes: 41 additions & 0 deletions collect-frontmatter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import os
import re
import yaml
from pathlib import Path
import json

FRONTMATTER_PATTERN = re.compile(r"^---\n(.*?)\n---\n", re.DOTALL)


def parse_frontmatter(filepath):
with open(filepath, "r", encoding="utf-8") as f:
content = f.read()

match = FRONTMATTER_PATTERN.match(content)
if not match:
return None

try:
frontmatter = yaml.safe_load(match.group(1))
return {
"title": frontmatter.get("title", ""),
"description": frontmatter.get("description", ""),
}
except yaml.YAMLError:
print(f"Failed to parse YAML in {filepath}")
return None


def collect_frontmatter_data():
data = {}
docs_path = Path("./docs")
for md_file in docs_path.rglob("*.md"):
parsed = parse_frontmatter(md_file)
if parsed:
data[str(md_file)] = parsed
return data


if __name__ == "__main__":
result = collect_frontmatter_data()
print(json.dumps(result, indent=2))
3 changes: 3 additions & 0 deletions docs/assets/code-slash.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
266 changes: 266 additions & 0 deletions docs/assets/guardrails/dataflow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading