Giter VIP home page Giter VIP logo

Comments (5)

lei-rs avatar lei-rs commented on July 21, 2024 1

Is this still needed? I'm interested in contributing.

from guardrails.

irgolic avatar irgolic commented on July 21, 2024

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.

mrdrprofuroboros avatar mrdrprofuroboros commented on July 21, 2024

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.

lei-rs avatar lei-rs commented on July 21, 2024

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.

smohiuddin avatar smohiuddin commented on July 21, 2024

Resolving as this is now available via https://www.guardrailsai.com/docs/defining_guards/strings

from guardrails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.