Skip to content

Commit 0874c8b

Browse files
authored
Merge branch '0.3.0' into feature/claude
2 parents 9cae16f + a1349e3 commit 0874c8b

File tree

137 files changed

+10074
-5402
lines changed

Some content is hidden

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

137 files changed

+10074
-5402
lines changed

.github/workflows/ci.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
branches:
1010
- main
1111
- dev
12+
- '0.3.0'
1213

1314
# Allows you to run this workflow manually from the Actions tab
1415
workflow_dispatch:
@@ -139,3 +140,48 @@ jobs:
139140
flags: unittests
140141
name: codecov-umbrella
141142
fail_ci_if_error: true
143+
144+
Notebooks:
145+
runs-on: ubuntu-latest
146+
if: ${{ always() && contains(join(needs.*.result, ','), 'success') }}
147+
needs: [Linting, Typing, Pytests]
148+
149+
env:
150+
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
151+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
152+
153+
154+
steps:
155+
- name: Checkout repository
156+
uses: actions/checkout@v2
157+
158+
- name: Set up Python
159+
uses: actions/setup-python@v2
160+
with:
161+
python-version: 3.11.x
162+
163+
- name: Poetry cache
164+
uses: actions/cache@v3
165+
with:
166+
path: ~/.cache/pypoetry
167+
key: poetry-cache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ env.POETRY_VERSION }}
168+
169+
- name: Install Poetry
170+
uses: snok/install-poetry@v1
171+
with:
172+
virtualenvs-create: true
173+
virtualenvs-in-project: true
174+
installer-parallel: true
175+
176+
- name: Install dependencies
177+
run: |
178+
make full;
179+
poetry add openai==0.28.1 jupyter nbconvert cohere;
180+
# pip install openai==0.28.1 jupyter nbconvert;
181+
# pip install .;
182+
183+
- name: Check for pypdfium2
184+
run: poetry run pip show pypdfium2
185+
186+
- name: Execute notebooks and check for errors
187+
run: ./.github/workflows/scripts/run_notebooks.sh

.github/workflows/examples_check.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,21 @@ jobs:
3131

3232
- name: Install Poetry
3333
uses: snok/install-poetry@v1
34+
with:
35+
virtualenvs-create: true
36+
virtualenvs-in-project: true
37+
installer-parallel: true
3438

3539
- name: Install dependencies
36-
run: make full; pip install jupyter nbconvert; pip install .
40+
run: |
41+
make full;
42+
poetry add openai==0.28.1 jupyter nbconvert cohere;
43+
# pip install openai==0.28.1 jupyter nbconvert;
44+
# pip install .;
45+
46+
- name: Check for pypdfium2
47+
run: poetry run pip show pypdfium2
3748

3849
- name: Execute notebooks and check for errors
39-
run: |
40-
cd docs/examples
41-
for notebook in $(ls *.ipynb); do
42-
jupyter nbconvert --to notebook --execute "$notebook"
43-
if [ $? -ne 0 ]; then
44-
echo "Error found in $notebook"
45-
exit 1
46-
fi
47-
done
50+
run: ./.github/workflows/scripts/run_notebooks.sh
51+

.github/workflows/release_version.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Manual Release
1+
name: Release PyPi Version
22

33
on:
44
workflow_dispatch: # This event allows manual triggering
@@ -31,4 +31,4 @@ jobs:
3131
- name: Upload to PyPI
3232
env:
3333
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
34-
run: poetry publish --build -u __token__ -p $PYPI_PASSWORD
34+
run: poetry publish --build -u shreyar -p $PYPI_PASSWORD
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
mkdir /tmp/nltk_data;
4+
poetry run python -m nltk.downloader -d /tmp/nltk_data punkt;
5+
export NLTK_DATA=/tmp/nltk_data;
6+
7+
cd docs/examples
8+
9+
# Function to process a notebook
10+
process_notebook() {
11+
notebook="$1"
12+
invalid_notebooks=("valid_chess_moves.ipynb" "translation_with_quality_check.ipynb" "llamaindex-output-parsing.ipynb")
13+
if [[ ! " ${invalid_notebooks[@]} " =~ " ${notebook} " ]]; then
14+
echo "Processing $notebook..."
15+
poetry run jupyter nbconvert --to notebook --execute "$notebook"
16+
if [ $? -ne 0 ]; then
17+
echo "Error found in $notebook"
18+
echo "Error in $notebook. See logs for details." >> errors.txt
19+
fi
20+
fi
21+
}
22+
23+
export -f process_notebook # Export the function for parallel execution
24+
25+
# Create a file to collect errors
26+
> errors.txt
27+
28+
# Run in parallel
29+
ls *.ipynb | parallel process_notebook
30+
31+
# Check if there were any errors
32+
if [ -s errors.txt ]; then
33+
echo "Some notebooks had errors"
34+
cat errors.txt
35+
exit 1
36+
else
37+
echo "All notebooks ran successfully."
38+
fi

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ dev:
5959
full:
6060
poetry install --all-extras
6161

62+
self-install:
63+
pip install -e .
64+
6265
all: autoformat type lint docs test
6366

6467
precommit:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ Call the `Guard` object with the LLM API call as the first argument and add any
154154
import openai
155155

156156
# Wrap the OpenAI API call with the `guard` object
157-
raw_llm_output, validated_output = guard(
157+
raw_llm_output, validated_output, *rest = guard(
158158
openai.Completion.create,
159159
engine="text-davinci-003",
160160
max_tokens=1024,
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
::: guardrails.classes.generic
2+
options:
3+
members:
4+
- "Stack"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
::: guardrails.classes.history
2+
options:
3+
members:
4+
- "Call"
5+
- "CallInputs"
6+
- "Inputs"
7+
- "Iteration"
8+
- "Outputs"

docs/concepts/guard.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ from guardrails import Guard
1919

2020
guard = Guard.from_rail(...)
2121

22-
raw_output, validated_output = guard(
22+
raw_output, validated_output, *rest = guard(
2323
openai.Completion.create,
2424
engine="text-davinci-003",
2525
max_tokens=1024,

0 commit comments

Comments
 (0)