Skip to content
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

Support python Literal types when defining JSON or FunctionCalling schemas. #577

Open
MarkDaoust opened this issue Sep 30, 2024 · 2 comments
Labels
type:feature request New feature request/enhancement

Comments

@MarkDaoust
Copy link
Collaborator

Description of the feature request:

String literal types should create Enums in the generated schema.

What problem are you trying to solve with this feature?

No response

Any other information you'd like to share?

No response

@MarkDaoust MarkDaoust added the type:feature request New feature request/enhancement label Sep 30, 2024
@MarkDaoust MarkDaoust changed the title Support python Literal types when defining JSON of FunctionCalling schemas. Support python Literal types when defining JSON or FunctionCalling schemas. Oct 3, 2024
@yan-hic
Copy link

yan-hic commented Oct 4, 2024

@MarkDaoust you mention "generated" - is there a private method that generates protos.Schema somewhere ?

I was about to write a feature request for a from_object() like in node.js to convert a pydantic object to Schema.

@MarkDaoust
Copy link
Collaborator Author

Hi @yan-hic,

The code is here:

def _schema_for_class(cls: TypedDict) -> dict[str, Any]:
schema = _build_schema("dummy", {"dummy": (cls, pydantic.Field())})
return schema["properties"]["dummy"]
def _schema_for_function(

It uses pydantic to do the conversion already, but I haven't tested actually passing pydantic objects.
Similarly, I haven't tried this with types like Literal['a', 'b'].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature request New feature request/enhancement
Projects
None yet
Development

No branches or pull requests

2 participants