Comments (5)
Is this still needed? I'm interested in contributing.
from guardrails.
Hi @leifu1128, I talked about this with @ShreyaR, and we realized that an Enum
type is unnecessary given the Choice
datatype and valid-choices
validator.
But one similar thing we would like is to support Literal
types in guards created from pydantic models.
Here's a minimal code sample that throws an "Unsupported type" error:
from typing import Literal
from guardrails import Guard
from pydantic import BaseModel
class Model(BaseModel):
type_: Literal["a", "b"]
Guard.from_pydantic(Model, prompt=...)
Let me know if this is something you're interested in picking up :)
from guardrails.
Is it possible currently to add a Enum or Literal -like validated field when creating a guard from pydantic model? I can use an explicit validator, but is there a nicer way to do it?
from guardrails.
Hey @irgolic. Sorry for the late response, just got back from vacation. Should I make it so create_xml_element_for_field
converts Literal
to string
+ valid-choices
?
from guardrails.
Resolving as this is now available via https://www.guardrailsai.com/docs/defining_guards/strings
from guardrails.
Related Issues (20)
- Dead link to docs page HOT 2
- [bug] Importing guardrails raises a deprecation warning for old validators HOT 1
- [bug] JSON validation converts null values to True:bool HOT 1
- No capability to disable telemetry via env var [bug] HOT 2
- [bug] Message: guardrails-cli[6204] , ERROR Failed to inspect HOT 8
- Guardrails Langchain integration with streamable AgentExecutor HOT 7
- Automatically open `hub.guardrailsai.com/tokens` url when running guardrails configure HOT 1
- [feat] Support for image inputs in prompts HOT 1
- [bug] Endpoint is reachable Validator "Zero-click" Vulnerability HOT 5
- [bug]: Guardrails hub token not getting generated HOT 7
- Import Error - Cannot import name 'SensitiveTopic' from 'guardrails.hub' HOT 5
- How to Deploy Guardrails with Hub via Docker image HOT 4
- [bug] detect-prompt-injetion validator fails to install from hub HOT 2
- [feat] Support defaults
- [feat] add a `quiet` option to `guardrails hub install`
- [feat] Update validator imports in notebooks to hub
- [bug] llm_api function triggering twice HOT 6
- [bug] OpenAI v1.x AsyncClient Does Not Work in Guardrails as Expected
- [bug] Guardrails prohibits OpenAI from utilizing env-var based API key HOT 6
- [bug] DetectPII validator with `on_fail=fix` results in a `TypeError` when validation fails HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from guardrails.