Skip to content

Commit 46dc05b

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/validation-summary
2 parents 9f5790a + c7967db commit 46dc05b

File tree

105 files changed

+4420
-3314
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+4420
-3314
lines changed

.dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
__pycache__
2+
*.pyc
3+
*.pyo

.github/workflows/install_from_hub.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
jobs:
1010
install_from_hub:
1111
runs-on: ubuntu-latest
12+
env:
13+
GUARDRAILS_API_KEY: ${{ secrets.GUARDRAILS_API_KEY }}
1214
steps:
1315
- name: Set up Python
1416
uses: actions/setup-python@v5
@@ -17,6 +19,8 @@ jobs:
1719
- name: pip install from main
1820
run: pip install git+https://github.com/guardrails-ai/guardrails.git@main
1921
- name: Install PII validator
20-
run: guardrails hub install hub://guardrails/detect_pii
22+
run: |
23+
guardrails configure --token $GUARDRAILS_API_KEY --disable-metrics --enable-remote-inferencing;
24+
guardrails hub install hub://guardrails/detect_pii;
2125
- name: Verify PII validator is addressable
2226
run: echo 'from guardrails.hub import DetectPII' | python

.github/workflows/server_ci.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Server CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
jobs:
10+
build-test-server:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check out head
14+
uses: actions/checkout@v3
15+
with:
16+
persist-credentials: false
17+
18+
- name: Set up QEMU
19+
uses: docker/setup-qemu-action@master
20+
with:
21+
platforms: linux/amd64
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@master
25+
with:
26+
platforms: linux/amd64
27+
28+
- name: Build Docker image
29+
uses: docker/build-push-action@v6
30+
with:
31+
context: .
32+
file: server_ci/Dockerfile
33+
platforms: linux/amd64
34+
push: false
35+
tags: guardrails:${{ github.sha }}
36+
load: true
37+
build-args: |
38+
GUARDRAILS_TOKEN=${{ secrets.GUARDRAILS_API_KEY }}
39+
40+
- name: Start Docker container
41+
run: |
42+
docker run -d --name guardrails-container -p 8000:8000 -e OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} guardrails:${{ github.sha }}
43+
44+
- name: Wait for Docker container to be ready
45+
run: |
46+
for i in {1..30}; do
47+
if docker exec guardrails-container curl -s http://localhost:8000/; then
48+
echo "Server is up!"
49+
break
50+
fi
51+
echo "Waiting for server..."
52+
sleep 5
53+
done
54+
55+
- name: Run Pytest
56+
run: |
57+
pip install pytest openai guardrails-ai
58+
pytest server_ci/tests
59+
docker stop guardrails-container
60+
docker rm guardrails-container

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ prompt = """
147147
148148
${gr.complete_json_suffix_v2}
149149
"""
150-
guard = Guard.from_pydantic(output_class=Pet, prompt=prompt)
150+
guard = Guard.for_pydantic(output_class=Pet, prompt=prompt)
151151
152152
raw_output, validated_output, *rest = guard(
153153
llm_api=openai.completions.create,

docs/api_reference/async_guard.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
options:
66
members:
77
- "__init__"
8-
- "from_rail"
9-
- "from_rail_string"
10-
- "from_pydantic"
11-
- "from_string"
8+
- "for_rail"
9+
- "for_rail_string"
10+
- "for_pydantic"
11+
- "for_string"
1212
- "configure"
1313
- "use"
1414
- "use_many"

docs/api_reference/guard.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
options:
66
members:
77
- "__init__"
8-
- "from_rail"
9-
- "from_rail_string"
10-
- "from_pydantic"
11-
- "from_string"
8+
- "for_rail"
9+
- "for_rail_string"
10+
- "for_pydantic"
11+
- "for_string"
1212
- "configure"
1313
- "use"
1414
- "use_many"

docs/concepts/error_remediation.md

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ Guardrails provides a number of `OnFailActions` for when a validator fails. The
3737
| `OnFailAction.FIX_REASK` | First, fix the generated output deterministically, and then rerun validation with the deterministically fixed output. If validation fails, then perform reasking. | No |
3838

3939

40+
Custom OnFailActions can also be implemented, see the `custom` section in the [how to use on fail actions guide](../how_to_guides/use_on_fail_actions).
41+
4042
## Guidance on dealing with Validator errors
4143

4244
When a validator fails, Guardrails does two things

docs/concepts/logs.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Calls can be further decomposed into a stack of `Iteration` objects. These are s
99
## General Access
1010
Given:
1111
```py
12-
my_guard = Guard.from_pydantic(...)
12+
my_guard = Guard.for_pydantic(...)
1313

1414
response_1 = my_guard(...)
1515

0 commit comments

Comments
 (0)