Skip to content

Commit

Permalink
Python: Fix pydantic alias issue (#10027)
Browse files Browse the repository at this point in the history
### Motivation and Context
fix #10026

### Description

This PR removes the alias as pydantic requires the usage of the alias
when initializing the class not the original name which prevents this
code from working.

```py
cosmosdb_settings = AzureCosmosDBSettings.create(
                env_file_path=env_file_path,
                connection_string=cosmos_connstr,
            )
```

### 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 😄
  • Loading branch information
john0isaac authored Jan 5, 2025
1 parent 2601e32 commit 6200d81
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import ClassVar

from pydantic import Field, SecretStr
from pydantic import ConfigDict, Field, SecretStr

from semantic_kernel.kernel_pydantic import KernelBaseSettings
from semantic_kernel.utils.experimental_decorator import experimental_class
Expand All @@ -22,3 +22,7 @@ class AzureCosmosDBSettings(KernelBaseSettings):

api: str | None = None
connection_string: SecretStr | None = Field(None, alias="AZCOSMOS_CONNSTR")

model_config = ConfigDict(
populate_by_name=True,
)

0 comments on commit 6200d81

Please sign in to comment.