Pydantic models should include discriminated tags to make defining configs easier #29514
illeatmyhat
announced in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked
Feature request
LangChain uses Pydantic models for practically every aspect. This is actually great. It makes it really easy to write configs.
But for example, what if you don't know which source of embeddings you want to use for a vector db ahead of time?
Pydantic doesn't know how to deserialize a field without knowing ahead of time which class to use.
To do this, it needs a field to discriminate between different options. This is often called a tag, and the technique is called Discriminated Unions.
Motivation
Currently we have to do something like this, and use a bunch of validation to ensure we actually selected correctly.
And it takes up a lot of vertical space.
Proposal (If applicable)
For example,
HuggingFaceEmbeddings
should include aembeddings_type
fieldThat way, in our config models, we can simply do
Beta Was this translation helpful? Give feedback.
All reactions