2024-05-21 18:33:08 +02:00
|
|
|
# Copyright (c) Microsoft. All rights reserved.
|
2023-08-03 10:53:01 -07:00
|
|
|
|
2024-05-21 18:33:08 +02:00
|
|
|
|
Python: allow settings to be created directly (#11468)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
I've always hated having to add the .create to a settings object, this
removes that, you can just use the regular init, added benefit is that
it has the proper fields in the docstrings for each implemented settings
object!
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Adds a __new__ method to the base settings class, which takes the prefix
and if supplied the env_file and encoding, then calls model_rebuild and
then the init.
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone :smile:
2025-04-11 08:26:22 +02:00
|
|
|
import logging
|
Python: Pydantic settings config (#6392)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
The initial implementation of Pydantic Settings was not optimal yet,
more optimized now.
### Description
Added a KernelBaseSettings class in kernel_pydantic
Rebased all settings off that
Added single create method to KernelBaseSettings:
- sets model_config.env_prefix to cls.end_prefix allowing us to set the
env_prefix as a classvar on each subclass and it works
- if env_file_path is set, set that in model_config
- strip all None values out of inputted values, then instantiate
This also allows us to pass the settings that are supplied to the
settings class, for overriding env settings.
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone :smile:
2024-05-30 11:38:28 +02:00
|
|
|
from typing import Annotated, Any, ClassVar, TypeVar
|
2023-08-03 10:53:01 -07:00
|
|
|
|
Python: Feature new memory stores and collections (#7614)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
This PR adds new vector store and vector store record collections as
well as implementations for:
- Azure AI Search
- Redis
- Qdrant
- Volatile (in-memory)
It also adds samples, tests, and unit-tests for these.
Next it adds the vector store record fields, definition and decorator,
with tests and samples.
All marked experimental. Existing Redis, Azure AI Search, Qdrant and
Volatile will be marked as deprecated in the future, once the new
collections are feature complete.
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone :smile:
2024-08-06 22:30:26 +02:00
|
|
|
from pydantic import BaseModel, ConfigDict, Field, UrlConstraints
|
2024-12-12 22:08:46 +01:00
|
|
|
from pydantic.networks import AnyUrl
|
Python: Pydantic settings config (#6392)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
The initial implementation of Pydantic Settings was not optimal yet,
more optimized now.
### Description
Added a KernelBaseSettings class in kernel_pydantic
Rebased all settings off that
Added single create method to KernelBaseSettings:
- sets model_config.env_prefix to cls.end_prefix allowing us to set the
env_prefix as a classvar on each subclass and it works
- if env_file_path is set, set that in model_config
- strip all None values out of inputted values, then instantiate
This also allows us to pass the settings that are supplied to the
settings class, for overriding env settings.
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone :smile:
2024-05-30 11:38:28 +02:00
|
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
2023-08-03 10:53:01 -07:00
|
|
|
|
2024-12-12 22:08:46 +01:00
|
|
|
HttpsUrl = Annotated[AnyUrl, UrlConstraints(max_length=2083, allowed_schemes=["https"])]
|
2023-11-28 22:44:10 -08:00
|
|
|
|
Python: allow settings to be created directly (#11468)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
I've always hated having to add the .create to a settings object, this
removes that, you can just use the regular init, added benefit is that
it has the proper fields in the docstrings for each implemented settings
object!
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Adds a __new__ method to the base settings class, which takes the prefix
and if supplied the env_file and encoding, then calls model_rebuild and
then the init.
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone :smile:
2025-04-11 08:26:22 +02:00
|
|
|
logger = logging.getLogger("semantic_kernel")
|
|
|
|
|
|
2023-11-28 22:44:10 -08:00
|
|
|
|
2024-01-24 08:51:56 -07:00
|
|
|
class KernelBaseModel(BaseModel):
|
2023-08-03 10:53:01 -07:00
|
|
|
"""Base class for all pydantic models in the SK."""
|
|
|
|
|
|
Python: set line-length for black in sync with Ruff, run black. (#4396)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
As we are tightening the formatting and linting setups, this was
missing, now the line-length for black and ruff are the same, thereby no
longer running into black issues as often.
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone :smile:
2024-01-04 15:28:20 +01:00
|
|
|
model_config = ConfigDict(populate_by_name=True, arbitrary_types_allowed=True, validate_assignment=True)
|
Python: Pydantic settings config (#6392)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
The initial implementation of Pydantic Settings was not optimal yet,
more optimized now.
### Description
Added a KernelBaseSettings class in kernel_pydantic
Rebased all settings off that
Added single create method to KernelBaseSettings:
- sets model_config.env_prefix to cls.end_prefix allowing us to set the
env_prefix as a classvar on each subclass and it works
- if env_file_path is set, set that in model_config
- strip all None values out of inputted values, then instantiate
This also allows us to pass the settings that are supplied to the
settings class, for overriding env settings.
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone :smile:
2024-05-30 11:38:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
T = TypeVar("T", bound="KernelBaseSettings")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class KernelBaseSettings(BaseSettings):
|
|
|
|
|
"""Base class for all settings classes in the SK.
|
|
|
|
|
|
|
|
|
|
A subclass creates it's fields and overrides the env_prefix class variable
|
|
|
|
|
with the prefix for the environment variables.
|
|
|
|
|
|
|
|
|
|
In the case where a value is specified for the same Settings field in multiple ways,
|
|
|
|
|
the selected value is determined as follows (in descending order of priority):
|
2024-05-31 15:06:41 +02:00
|
|
|
- Arguments passed to the Settings class initializer.
|
Python: Pydantic settings config (#6392)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
The initial implementation of Pydantic Settings was not optimal yet,
more optimized now.
### Description
Added a KernelBaseSettings class in kernel_pydantic
Rebased all settings off that
Added single create method to KernelBaseSettings:
- sets model_config.env_prefix to cls.end_prefix allowing us to set the
env_prefix as a classvar on each subclass and it works
- if env_file_path is set, set that in model_config
- strip all None values out of inputted values, then instantiate
This also allows us to pass the settings that are supplied to the
settings class, for overriding env settings.
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone :smile:
2024-05-30 11:38:28 +02:00
|
|
|
- Environment variables, e.g. my_prefix_special_function as described above.
|
|
|
|
|
- Variables loaded from a dotenv (.env) file.
|
|
|
|
|
- Variables loaded from the secrets directory.
|
|
|
|
|
- The default field values for the Settings model.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
env_prefix: ClassVar[str] = ""
|
Python: improved content inits, added ndarray support for binary content and small fixes to defaults (#10469)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
This PR adds support for ndarray's as the content carrier for all binary
content types (binary, image, audio) as that is more optimized for
larger content.
It also does some fixes to the initialization of those content types and
the underlying data uri type.
Also some fixes for unspecified default param in pydantic Field,
language servers do not recognize `Field("default value")` as having a
default, so changed those occurances to `Field(default="default value")`
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone :smile:
2025-02-12 17:59:08 +01:00
|
|
|
env_file_path: str | None = Field(default=None, exclude=True)
|
Python: allow settings to be created directly (#11468)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
I've always hated having to add the .create to a settings object, this
removes that, you can just use the regular init, added benefit is that
it has the proper fields in the docstrings for each implemented settings
object!
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Adds a __new__ method to the base settings class, which takes the prefix
and if supplied the env_file and encoding, then calls model_rebuild and
then the init.
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone :smile:
2025-04-11 08:26:22 +02:00
|
|
|
env_file_encoding: str | None = Field(default="utf-8", exclude=True)
|
Python: Pydantic settings config (#6392)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
The initial implementation of Pydantic Settings was not optimal yet,
more optimized now.
### Description
Added a KernelBaseSettings class in kernel_pydantic
Rebased all settings off that
Added single create method to KernelBaseSettings:
- sets model_config.env_prefix to cls.end_prefix allowing us to set the
env_prefix as a classvar on each subclass and it works
- if env_file_path is set, set that in model_config
- strip all None values out of inputted values, then instantiate
This also allows us to pass the settings that are supplied to the
settings class, for overriding env settings.
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone :smile:
2024-05-30 11:38:28 +02:00
|
|
|
|
|
|
|
|
model_config = SettingsConfigDict(
|
|
|
|
|
extra="ignore",
|
|
|
|
|
case_sensitive=False,
|
|
|
|
|
)
|
|
|
|
|
|
Python: allow settings to be created directly (#11468)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
I've always hated having to add the .create to a settings object, this
removes that, you can just use the regular init, added benefit is that
it has the proper fields in the docstrings for each implemented settings
object!
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Adds a __new__ method to the base settings class, which takes the prefix
and if supplied the env_file and encoding, then calls model_rebuild and
then the init.
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone :smile:
2025-04-11 08:26:22 +02:00
|
|
|
def __init__(
|
|
|
|
|
self,
|
|
|
|
|
**kwargs: Any,
|
|
|
|
|
) -> None:
|
|
|
|
|
"""Initialize the settings class."""
|
|
|
|
|
# Remove any None values from the kwargs so that defaults are used.
|
|
|
|
|
kwargs = {k: v for k, v in kwargs.items() if v is not None}
|
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
|
|
|
|
|
|
def __new__(cls: type["T"], *args: Any, **kwargs: Any) -> "T":
|
|
|
|
|
"""Override the __new__ method to set the env_prefix."""
|
|
|
|
|
# for both, if supplied but None, set to default
|
|
|
|
|
if "env_file_encoding" in kwargs and kwargs["env_file_encoding"] is not None:
|
|
|
|
|
env_file_encoding = kwargs["env_file_encoding"]
|
|
|
|
|
else:
|
|
|
|
|
env_file_encoding = "utf-8"
|
|
|
|
|
if "env_file_path" in kwargs and kwargs["env_file_path"] is not None:
|
|
|
|
|
env_file_path = kwargs["env_file_path"]
|
|
|
|
|
else:
|
|
|
|
|
env_file_path = ".env"
|
|
|
|
|
cls.model_config.update( # type: ignore
|
|
|
|
|
env_prefix=cls.env_prefix,
|
|
|
|
|
env_file=env_file_path,
|
|
|
|
|
env_file_encoding=env_file_encoding,
|
|
|
|
|
)
|
|
|
|
|
cls.model_rebuild()
|
|
|
|
|
return super().__new__(cls)
|
|
|
|
|
|
Python: Pydantic settings config (#6392)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
The initial implementation of Pydantic Settings was not optimal yet,
more optimized now.
### Description
Added a KernelBaseSettings class in kernel_pydantic
Rebased all settings off that
Added single create method to KernelBaseSettings:
- sets model_config.env_prefix to cls.end_prefix allowing us to set the
env_prefix as a classvar on each subclass and it works
- if env_file_path is set, set that in model_config
- strip all None values out of inputted values, then instantiate
This also allows us to pass the settings that are supplied to the
settings class, for overriding env settings.
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone :smile:
2024-05-30 11:38:28 +02:00
|
|
|
@classmethod
|
|
|
|
|
def create(cls: type["T"], **data: Any) -> "T":
|
|
|
|
|
"""Update the model_config with the prefix."""
|
Python: allow settings to be created directly (#11468)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
I've always hated having to add the .create to a settings object, this
removes that, you can just use the regular init, added benefit is that
it has the proper fields in the docstrings for each implemented settings
object!
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Adds a __new__ method to the base settings class, which takes the prefix
and if supplied the env_file and encoding, then calls model_rebuild and
then the init.
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone :smile:
2025-04-11 08:26:22 +02:00
|
|
|
logger.warning(
|
|
|
|
|
"The create method is deprecated. Use the __new__ method instead.",
|
|
|
|
|
)
|
Python: Pydantic settings config (#6392)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
The initial implementation of Pydantic Settings was not optimal yet,
more optimized now.
### Description
Added a KernelBaseSettings class in kernel_pydantic
Rebased all settings off that
Added single create method to KernelBaseSettings:
- sets model_config.env_prefix to cls.end_prefix allowing us to set the
env_prefix as a classvar on each subclass and it works
- if env_file_path is set, set that in model_config
- strip all None values out of inputted values, then instantiate
This also allows us to pass the settings that are supplied to the
settings class, for overriding env settings.
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone :smile:
2024-05-30 11:38:28 +02:00
|
|
|
return cls(**data)
|