semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

Use Pydantic for configuration

Open AdityaGudimella opened this issue 2 years ago • 4 comments

We have a few configuration classes in the python version like BackendConfig, OpenAIConfig, AzureOpenAIConfig etc. We perform operations like loading these configs from .env files using helper methods like utils.settings::openai_settings_from_dot_env etc. We also have a class named Verify that verifies config values like checking that a value is not None etc. Pydantic is a popular open-source library that is particularly used in such cases. All the above mentioned functionality is built into Pydantic. I propose that we use pydantic for our configuration and replace the Verify class and the helper functions like utils.settings::openai_settings_from_dot_env with pydantic functions.

What are your thoughts on this?

AdityaGudimella avatar Mar 21 '23 00:03 AdityaGudimella

I want to chime in here and say that, based on other open source projects in the LLM space I've seen, using something like pydantic would align us more closely with community standards. When I wrote the initial Python port I tried to make minimal changes from the C# version, but the config classes and the Verify class (and the helpers I've written) are very un-pythonic.

In my opinion, it'd be great to move toward pydantic! (And, related, it may be nice to simplify configuration at some point... I feel like there are so many classes that hold so many of the same values, something like making a PromptTemplate has a lot of "ceremony" around it.)

jjhenkel avatar Mar 21 '23 01:03 jjhenkel

thanks for the great feedback. Sharing a few notes for the sake of optimizing the port to python: we're redesigning the support for backend and we expect to be a substantial change. The goal is allowing any backend, removing the current first implementation that is very OpenAI centric. The work is still in progress and most probably it will involve how configuration is managed. So it might be worth waiting a couple of weeks until that's sorted out, in case there are reusable ideas, conf files, etc.

dluc avatar Mar 21 '23 04:03 dluc

@awharrison-28 @mkarle FYI

dluc avatar Apr 28 '23 08:04 dluc

quick update: work in progress

dluc avatar May 12 '23 21:05 dluc

@dluc can you please update this issue on the latest status?

nacharya1 avatar Aug 01 '23 17:08 nacharya1

@awharrison-28 - can you please update target dates/close this issue as needed.

nacharya1 avatar Sep 06 '23 05:09 nacharya1

Completed.

evchaki avatar Jan 03 '24 21:01 evchaki