-
Notifications
You must be signed in to change notification settings - Fork 398
[bug] Type annotated objects in pydantic guards incorrectly transpile to XML #319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
bug
Something isn't working
Comments
irgolic
added a commit
to irgolic/guardrails
that referenced
this issue
Nov 3, 2023
thekaranacharya
pushed a commit
that referenced
this issue
Nov 17, 2023
zsimjee
added a commit
that referenced
this issue
Nov 17, 2023
* Add PII filter: v0 * Update PII filter * Update class docstring, add more entities to filter, bugfix and update some comments * Move logic to helper function, update DEV_REQUIREMENTS, add integration tests * Fix linting * Write code according to Python 3.9 * Add mocks for AnalyzerEngine and AnonymizerEngine * Change | to Union * Add notebook example demo for PIIFilter * Add package imports * Init pydantic_utils v2 * Adjust tests for pydantic2 * pydantic: Allow Dict/List field types (fix #319) * test_validators: Fix SimilarToList validator test * CI: handle pydantic v1 and v2 separately * list => List * parsing_utils: Type ignore * pydantic_utils/v2: safe BareModel * fix Makefile for poetry * fix ci cache for pydantic versions * Remove setup.py * Update pyproject and poetry * Linting fixes * Remove types remain intact changes * Strong type results to covaraiant Sequence, as suggested by Pyright * Fix linting issues * Change casting * Add else condition for pii_entities to avoid unbound errors for entities_to_filter --------- Co-authored-by: zsimjee <[email protected]> Co-authored-by: Rafael Irgolic <[email protected]>
CalebCourier
pushed a commit
to guardrails-ai/guardrails-internal
that referenced
this issue
Nov 22, 2023
author zsimjee <[email protected]> 1699036706 -0700 committer Caleb Courier <[email protected]> 1700668933 -0600 Setup passed password (guardrails-ai#429) * use pypi pass from env * upgrade pip before installing deps * pass pypi pass explicitly * use environ competently Cron nb (guardrails-ai#425) * install deps + pkg for nb runs * lock nb runner to 3.11.x * use cohere api key from environ * ref env vars for cohere + openai fix bad merge in code originally from validators.py (guardrails-ai#427) * fix bad merge in code originally from validators.py * lint fixes bump version (guardrails-ai#428) Setup passed password (guardrails-ai#429) * use pypi pass from env * upgrade pip before installing deps * pass pypi pass explicitly * use environ competently list -> List Lock openai version (guardrails-ai#435) * temporarily lock openai version * bump version to be ready for release Poetry for dependency management (guardrails-ai#436) * Replace setup.py/requirements.txt/version.py with pyproject.toml/poetry.lock * add dateutil to core dependencies * convert dependency groups to extras * Makefile/CI: Change to poetry * poetry run * replace make dev with make full * poetry: include guardrails console script * release_version: Set pypi token in poetry pyproject.toml: version 0.2.7 => 0.2.8 from_element => from_xml rail: load_schema => load_schema_from_xml pydantic_utils.attach_validators_to_element: Fix typehint Pass validator arguments through for string guard Remove XML from pydantic guard instantiation python_rail.compiled_prompt_1: Fix test (wrongly not annotated as optional) Remove conversion-to-XML code Move integration test to where it belongs schema: Remove commented out method load_string_schema_from_pydantic -> load_json_schema_from_pydantic datatypes: Fix datatype deprecation Remove deprecated datatypes from pydantic test_run: Fix `from_element` => `from_xml` call datatypes: Raise deprecation warning on datatype init Move pydantic_utils to split package logs_utils: Move ArbitraryModel to pydantic_utils Move DataType.from_pydantic_field to pydantic_utils add --build option to poetry build release_version: specify token differently fix project name (guardrails => guardrails-ai) Fix reask prompt/instructions (guardrails-ai#432) * schema: Always use reask prompt/instructions setter * guard/run: Remove reask prompt/instructions plumbing * guard: Allow passing reask prompt/instructions to pydantic constructor * guard: Link reask prompt/instructions properties to schema * format index similarToList notebook (guardrails-ai#426) Fix custom onfail handler (guardrails-ai#421) * formatattr: Pass through custom on_fail methods * validator_service: Pass all FailResults to custom fail handler instead of only first * test_validators: Add custom on_fail handler test Init pydantic_utils v2 Adjust tests for pydantic2 pydantic: Allow Dict/List field types (fix guardrails-ai#319) test_validators: Fix SimilarToList validator test CI: handle pydantic v1 and v2 separately list => List parsing_utils: Type ignore pydantic_utils/v2: safe BareModel fix Makefile for poetry fix ci cache for pydantic versions lint and test fixes autoformat Create PII Filter validator (guardrails-ai#395) * Add PII filter: v0 * Update PII filter * Update class docstring, add more entities to filter, bugfix and update some comments * Move logic to helper function, update DEV_REQUIREMENTS, add integration tests * Fix linting * Write code according to Python 3.9 * Add mocks for AnalyzerEngine and AnonymizerEngine * Change | to Union * Add notebook example demo for PIIFilter * Add package imports * Init pydantic_utils v2 * Adjust tests for pydantic2 * pydantic: Allow Dict/List field types (fix guardrails-ai#319) * test_validators: Fix SimilarToList validator test * CI: handle pydantic v1 and v2 separately * list => List * parsing_utils: Type ignore * pydantic_utils/v2: safe BareModel * fix Makefile for poetry * fix ci cache for pydantic versions * Remove setup.py * Update pyproject and poetry * Linting fixes * Remove types remain intact changes * Strong type results to covaraiant Sequence, as suggested by Pyright * Fix linting issues * Change casting * Add else condition for pii_entities to avoid unbound errors for entities_to_filter --------- Co-authored-by: zsimjee <[email protected]> Co-authored-by: Rafael Irgolic <[email protected]> OpenAI v1 support (guardrails-ai#441) * Support both openai v0 and v1 * Adjust CI for openai v0/v1 * Move LLMResponse object to its own file * Add usage to provenance test mock * Comment out ArbitraryCallable test suite for openai errors * Adjust tests for openai v0/v1 * remove unused imports * OpenAIv1: Don't instantiate openai.completions.create if key isn't present in environ lint and type fix fix test ' -> " Rail XML: Rename "format" attr to "validators" (guardrails-ai#439) * Rail XML: Rename "format" attr to "validators" * added note that `format` will be removed in 0.4.x * test_rail: Check format deprecation resolves properly Allow OpenAI v1 pyproject.toml: Clamp pydantic to ">=1.10.9, <2.5" pyproject.toml: Clamp pyright to 1.1.334 update poetry.lock
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
When making a guard from a pydantic model, if a Dict has type arguments on it, it transpiles into XML in a way that doesn't work.
Relevant Discord thread:
https://discord.com/channels/1085077079697150023/1149032565844475965/1149296871517470810
To Reproduce
Expected behavior
XML guards don't support specifying types in objects with arbitrary elements, so it should probably just act like this:
Library version:
0.2.0
Additional context
This bug will probably be fixed when we migrate to XML-invariant internals.
The text was updated successfully, but these errors were encountered: