Skip to content

Commit 132c3cc

Browse files
committed
Merge branch 'guardrails' of https://github.com/invariantlabs-ai/docs into guardrails
2 parents b97ed33 + 209b51d commit 132c3cc

File tree

14 files changed

+505
-151
lines changed

14 files changed

+505
-151
lines changed

docs/assets/invariant.css

Lines changed: 68 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
/* define primary blue */
1414
:root {
1515
--primary-blue: #3d3affac;
16+
--primary-red: #ff6678;
1617
}
1718

1819

@@ -407,6 +408,21 @@ span.detector-badge::before {
407408
border-radius: 4pt;
408409
}
409410

411+
span.high-latency::before {
412+
content: "High-Latency";
413+
color: #eef2ff;
414+
font-size: 10pt;
415+
position: relative;
416+
top: -3pt;
417+
margin-left: 3pt;
418+
background-color: var(--primary-red);
419+
display: inline-block;
420+
height: 18pt;
421+
422+
padding: 2pt 4pt;
423+
border-radius: 4pt;
424+
}
425+
410426
span.parser-badge::before {
411427
content: "Parser";
412428
color: #eef2ff;
@@ -460,7 +476,15 @@ span.parser-badge::before {
460476
}
461477

462478
.detector-badge:hover::after {
463-
content: 'DETECTOR DESCRIPTION';
479+
content: 'Detectors allow you to detect the presence of certain patterns and types of data in an input.';
480+
}
481+
482+
.high-latency {
483+
position: relative;
484+
}
485+
486+
.high-latency:hover::after {
487+
content: 'High-Latency checks may significantly increase the time it takes to process a request. Non-blocking checks are recommended.';
464488
}
465489

466490
.parser-badge {
@@ -479,7 +503,7 @@ span.parser-badge::before {
479503
content: 'BUILTIN DESCRIPTION';
480504
}
481505

482-
.parser-badge:hover::after, .detector-badge:hover::after, .llm-badge:hover::after, .builtin-badge:hover::after {
506+
.parser-badge:hover::after, .detector-badge:hover::after, .llm-badge:hover::after, .builtin-badge:hover::after, .high-latency:hover::after {
483507
position: absolute;
484508
left: 50%;
485509
transform: translateX(-50%);
@@ -798,7 +822,7 @@ ul.md-nav__list {
798822

799823
.risks blockquote {
800824
background-color: rgb(254, 243, 243);
801-
border: 2pt solid #ff6678 !important;
825+
border: 2pt solid var(--primary-red) !important;
802826
}
803827

804828
.risks blockquote>p>strong:first-child {
@@ -812,20 +836,46 @@ ul.md-nav__list {
812836
margin-top: -5pt;
813837
}
814838

815-
.info blockquote {
816-
background-color: rgb(243, 245, 254);
817-
border: 2pt solid #8766ff !important;
839+
.admonition {
840+
background-color: rgb(254, 243, 243) !important;
841+
border: 2pt solid var(--primary-red) !important;
842+
font-size: 12pt;
818843
}
819844

820-
.info blockquote>p>strong:first-child {
821-
margin-bottom: 10pt;
822-
display: inline-block;
823-
padding-left: 25pt;
845+
.admonition p {
846+
font-size: 12pt !important;
847+
}
848+
849+
.admonition .admonition-title {
850+
background-color: transparent !important;
851+
margin: 0pt;
852+
margin-top: 2pt;
853+
padding: 0pt;
854+
padding-top: 10pt;
855+
padding-left: 27.5pt !important;
856+
background: url("../assets/warning.svg") no-repeat 3pt 1pt;
857+
background-position: 4pt 12pt;
858+
background-size: 1.2em;
859+
font-size: 12pt !important;
860+
font-weight: 500 !important;
861+
}
824862

863+
.admonition .admonition-title:before {
864+
mask: none;
865+
-webkit-mask: none;
866+
display: none;
867+
}
868+
869+
.admonition.info {
870+
background-color: rgb(243, 245, 254) !important;
871+
border: 2pt solid #8766ff !important;
872+
}
873+
874+
.admonition.info .admonition-title {
875+
background-color: transparent !important;
825876
background: url("../assets/info.svg") no-repeat 3pt 1pt;
877+
background-position: 4pt 12pt;
826878
background-size: 1.2em;
827-
padding-top: -1pt;
828-
margin-top: -5pt;
829879
}
830880

831881
.md-typeset__table {
@@ -903,6 +953,12 @@ ul.md-nav__list {
903953
margin-top: 30pt;
904954
}
905955

956+
@media (max-width: 600px) {
957+
.language-guardrail {
958+
margin-top: 30pt !important;
959+
}
960+
}
961+
906962
.language-guardrail .action-links {
907963
display: inline-block;
908964
position: absolute;

docs/assets/js/highlight.js

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// if we are on localhost or 127.0.0.1, use the local explorer
2-
BASE_URL = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" ? "http://localhost/" : "https://explorer.invariantlabs.ai/";
2+
BASE_URL =
3+
window.location.hostname === "localhost" ||
4+
window.location.hostname === "127.0.0.1"
5+
? "http://localhost/"
6+
: "https://explorer.invariantlabs.ai/";
37

48
function encodeGuardrailURIComponent(content) {
59
/**
@@ -41,10 +45,10 @@ function findSnippetTitle(codeElement) {
4145
return "New Guardrail";
4246
}
4347

44-
function changeElements(codeElements, endpoint) {
48+
function changeElements(codeElements, endpoint, embed = false) {
4549
// Add a button to each pre element
4650
codeElements.forEach(function (codeElement) {
47-
// replace the code element with an iframe
51+
// augment the code element
4852
let textContent = codeElement.textContent || codeElement.innerText;
4953

5054
// parse and split contents
@@ -60,28 +64,42 @@ function changeElements(codeElements, endpoint) {
6064
);
6165
}
6266

63-
// add links for the ${BASE_URL}/playground?policy=...&input=... (Call it Open In Playground)
64-
const container = document.createElement("div");
65-
container.className = "action-links";
67+
if (!embed) {
68+
// add links for the ${BASE_URL}/playground?policy=...&input=... (Call it Open In Playground)
69+
const container = document.createElement("div");
70+
container.className = "action-links";
6671

67-
const playgroundLink = document.createElement("a");
68-
playgroundLink.className = "link open-in-playground";
69-
playgroundLink.href = `${BASE_URL}${endpoint}=${encodedContent}${exampleTraceURIComponent}`;
70-
playgroundLink.target = "_blank";
71-
playgroundLink.innerText = "⏵ Open In Playground";
72+
const playgroundLink = document.createElement("a");
73+
playgroundLink.className = "link open-in-playground";
74+
playgroundLink.href = `${BASE_URL}${endpoint}=${encodedContent}${exampleTraceURIComponent}`;
75+
playgroundLink.target = "_blank";
76+
playgroundLink.innerText = "⏵ Open In Playground";
7277

73-
const agentLink = document.createElement("a");
74-
agentLink.className = "link add-to-agent";
75-
agentLink.href = `${BASE_URL}deploy-guardrail#policy-code=${encodeURIComponent(
76-
textContent
77-
)}&name=${encodeURIComponent(findSnippetTitle(codeElement))}`;
78-
agentLink.target = "_blank";
79-
agentLink.innerText = "+ Add to Agent";
78+
const agentLink = document.createElement("a");
79+
agentLink.className = "link add-to-agent";
80+
agentLink.href = `${BASE_URL}deploy-guardrail#policy-code=${encodeURIComponent(
81+
textContent
82+
)}&name=${encodeURIComponent(findSnippetTitle(codeElement))}`;
83+
agentLink.target = "_blank";
84+
agentLink.innerText = "+ Add to Agent";
8085

81-
container.appendChild(agentLink);
82-
container.appendChild(playgroundLink);
86+
container.appendChild(agentLink);
87+
container.appendChild(playgroundLink);
8388

84-
codeElement.appendChild(container);
89+
codeElement.appendChild(container);
90+
} else {
91+
const id = crypto.randomUUID().toString();
92+
const iframe = document.createElement("iframe", { id: id });
93+
iframe.src = `${BASE_URL}embed/${endpoint}=${encodedContent}&id=${id}`;
94+
codeElement.replaceWith(iframe);
95+
96+
window.addEventListener("message", function (event) {
97+
//check which element the message is coming from
98+
if (event.data.type === "resize" && event.data.id === id) {
99+
iframe.style.height = event.data.height + "px";
100+
}
101+
});
102+
}
85103
});
86104
}
87105

@@ -100,7 +118,8 @@ document.addEventListener("DOMContentLoaded", function () {
100118
// currently disabled as the traceview endpoint is not yet enabled on explorer
101119
changeElements(
102120
document.querySelectorAll("div.language-trace"),
103-
"traceview?trace"
121+
"traceview?trace",
122+
true
104123
);
105124
changeElements(
106125
document.querySelectorAll("div.language-guardrail"),

docs/explorer/api/uploading-traces/push-api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Additional keyword arguments to pass to the requests method. Default is `None`.
104104

105105
The response object from the Invariant API.
106106

107-
> Client Example
107+
> **Client Example**
108108
```python
109109
from invariant_sdk.client import Client
110110
from invariant_sdk.types.push_traces import PushTracesRequest
@@ -164,7 +164,7 @@ Additional keyword arguments to pass to the requests method. Default is `None`.
164164

165165
The response object from the Invariant API.
166166

167-
> Client Example
167+
> **Client Example**
168168
```python
169169
from invariant_sdk.client import Client
170170

0 commit comments

Comments
 (0)