Skip to content
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
docs/api_reference_markdown/
openai_api_key.txt
*__pycache__*
data/*
Expand All @@ -14,7 +13,9 @@ settings.json
site/*
guardrails.log
guardrails_ai.egg-info/
build/*
*/build/*
docs/build
!docs/dist/*
dist/*
*.rail_output*
.idea/*
Expand All @@ -27,9 +28,8 @@ test.index
htmlcov
node_modules
.docusaurus
docs-build
.vercel
docusaurus/examples-toc.json
!docs/examples-toc.json
.python-version
static/docs
docusaurus/static/docs
Expand All @@ -41,4 +41,4 @@ docusaurus/static/docs
*/share/*
pyvenv.cfg
mlruns
mlartifacts
mlartifacts
10 changes: 5 additions & 5 deletions DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ npm run start
## How the build process works

1. pydocs is used to create python docs in the 'docs/' directory
1. a new folder called 'docs-build' is created
1. docs are copied from 'docs/' to 'docs-build/'
1. nbdocs is used on all notebooks in the 'docs-build' directory. This creates md files parallel to the notebooks in the dir structure.
1. a new folder called 'docs/build' is created
1. docs are copied from 'docs/src' to 'docs/build'
1. nbdocs is used on all notebooks in the 'docs/build' directory. This creates md files parallel to the notebooks in the dir structure.
1. md files are iterated and converted to mdx files. We import some custom components at the top of each mdx file.

## Troubleshooting/common problems

1. On first run, the docs build does not complete and the site is not served
- This is usually an intermittent failure with nb-docs. Try running `npm run start` again
- If this doesn't work, try running `rm -rf docs-build; npm run start`
- If this doesn't work, try running `rm -rf docs/build; npm run start`
- If even that doesn't work, please file an issue. Something may be wrong with docs builds on the branch
1. I updated a notebook and it didn't update in the docs
- This is likely because the notebook wasn't converted to markdown, or files were not overwritten
- To fix this, run `rm -rf docs-build; npm run start`
- To fix this, run `rm -rf docs/build; npm run start`
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ full:

docs-gen:
poetry run python ./docs/pydocs/generate_pydocs.py
cp -r docs docs-build
poetry run nbdoc_build --force_all True --srcdir ./docs-build
cp -r docs/src/* docs/dist
poetry run nbdoc_build --force_all True --srcdir ./docs/dist

self-install:
pip install -e .
Expand Down
3,092 changes: 3,092 additions & 0 deletions docs/bun.lock

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
81 changes: 81 additions & 0 deletions docs/dist/api_reference_markdown/actions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Actions

## ReAsk

```python
class ReAsk(IReask)
```

Base class for ReAsk objects.

**Attributes**:

- `incorrect_value` _Any_ - The value that failed validation.
- `fail_results` _List[FailResult]_ - The results of the failed validations.

## FieldReAsk

```python
class FieldReAsk(ReAsk)
```

An implementation of ReAsk that is used to reask for a specific field.
Inherits from ReAsk.

**Attributes**:

- `path` _Optional[List[Any]]_ - a list of keys that
designated the path to the field that failed validation.

## SkeletonReAsk

```python
class SkeletonReAsk(ReAsk)
```

An implementation of ReAsk that is used to reask for structured data
when the response does not match the expected schema.

Inherits from ReAsk.

## NonParseableReAsk

```python
class NonParseableReAsk(ReAsk)
```

An implementation of ReAsk that is used to reask for structured data
when the response is not parseable as JSON.

Inherits from ReAsk.

## Filter

```python
class Filter()
```

#### apply\_filters

```python
def apply_filters(value: Any) -> Any
```

Recursively filter out any values that are instances of Filter.

## Refrain

```python
class Refrain()
```

#### apply\_refrain

```python
def apply_refrain(value: Any, output_type: OutputTypes) -> Any
```

Recursively check for any values that are instances of Refrain.

If found, return an empty value of the appropriate type.

15 changes: 15 additions & 0 deletions docs/dist/api_reference_markdown/errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Errors

## ValidationError

```python
class ValidationError(Exception)
```

Top level validation error.

This is thrown from the validation engine when a Validator has
on_fail=OnFailActions.EXCEPTION set and validation fails.

Inherits from Exception.

23 changes: 23 additions & 0 deletions docs/dist/api_reference_markdown/formatters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Formatters

## BaseFormatter

```python
class BaseFormatter(ABC)
```

A Formatter takes an LLM Callable and wraps the method into an abstract
callable.

Used to perform manipulations of the input or the output, like JSON
constrained- decoding.

## JsonFormatter

```python
class JsonFormatter(BaseFormatter)
```

A formatter that uses Jsonformer to ensure the shape of structured data
for Hugging Face models.

137 changes: 137 additions & 0 deletions docs/dist/api_reference_markdown/generics_and_base_classes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Generics And Base Classes

## ArbitraryModel

```python
class ArbitraryModel(BaseModel)
```

Empty Pydantic model with a config that allows arbitrary types.

## Stack

```python
class Stack(List[T])
```

#### empty

```python
def empty() -> bool
```

Tests if this stack is empty.

#### peek

```python
def peek() -> Optional[T]
```

Looks at the object at the top (last/most recently added) of this
stack without removing it from the stack.

#### pop

```python
def pop() -> Optional[T]
```

Removes the object at the top of this stack and returns that object
as the value of this function.

#### push

```python
def push(item: T) -> None
```

Pushes an item onto the top of this stack.

Proxy of List.append

#### search

```python
def search(x: T) -> Optional[int]
```

Returns the 0-based position of the last item whose value is equal
to x on this stack.

We deviate from the typical 1-based position used by Stack
classes (i.e. Java) because most python users (and developers in
general) are accustomed to 0-based indexing.

#### at

```python
def at(index: int, default: Optional[T] = None) -> Optional[T]
```

Returns the item located at the index.

If the index does not exist in the stack (Overflow or
Underflow), None is returned instead.

#### copy

```python
def copy() -> "Stack[T]"
```

Returns a copy of the current Stack.

#### first

```python
@property
def first() -> Optional[T]
```

Returns the first item of the stack without removing it.

Same as Stack.bottom.

#### last

```python
@property
def last() -> Optional[T]
```

Returns the last item of the stack without removing it.

Same as Stack.top.

#### bottom

```python
@property
def bottom() -> Optional[T]
```

Returns the item on the bottom of the stack without removing it.

Same as Stack.first.

#### top

```python
@property
def top() -> Optional[T]
```

Returns the item on the top of the stack without removing it.

Same as Stack.last.

#### length

```python
@property
def length() -> int
```

Returns the number of items in the Stack.

Loading