From 32eaa24143143ade95a519a8d9720ae582288d3b Mon Sep 17 00:00:00 2001 From: John Aziz Date: Sun, 22 Dec 2024 19:44:40 +0200 Subject: [PATCH 1/4] Fix pydantic alias issue 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, ) ``` --- .../connectors/memory/azure_cosmosdb/azure_cosmosdb_settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/semantic_kernel/connectors/memory/azure_cosmosdb/azure_cosmosdb_settings.py b/python/semantic_kernel/connectors/memory/azure_cosmosdb/azure_cosmosdb_settings.py index 6cbd1ae049f2..68d047780725 100644 --- a/python/semantic_kernel/connectors/memory/azure_cosmosdb/azure_cosmosdb_settings.py +++ b/python/semantic_kernel/connectors/memory/azure_cosmosdb/azure_cosmosdb_settings.py @@ -21,4 +21,4 @@ class AzureCosmosDBSettings(KernelBaseSettings): env_prefix: ClassVar[str] = "COSMOSDB_" api: str | None = None - connection_string: SecretStr | None = Field(None, alias="AZCOSMOS_CONNSTR") + connection_string: SecretStr | None = None From d1b35f030ba98abd1d86af47a078fbf40b752759 Mon Sep 17 00:00:00 2001 From: John Aziz Date: Mon, 30 Dec 2024 20:00:38 +0200 Subject: [PATCH 2/4] Allow for using both alias and attribute name forr pydantic 2.0 --- .../memory/azure_cosmosdb/azure_cosmosdb_settings.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/python/semantic_kernel/connectors/memory/azure_cosmosdb/azure_cosmosdb_settings.py b/python/semantic_kernel/connectors/memory/azure_cosmosdb/azure_cosmosdb_settings.py index 68d047780725..b18ce02ce74b 100644 --- a/python/semantic_kernel/connectors/memory/azure_cosmosdb/azure_cosmosdb_settings.py +++ b/python/semantic_kernel/connectors/memory/azure_cosmosdb/azure_cosmosdb_settings.py @@ -21,4 +21,8 @@ class AzureCosmosDBSettings(KernelBaseSettings): env_prefix: ClassVar[str] = "COSMOSDB_" api: str | None = None - connection_string: SecretStr | None = None + connection_string: SecretStr | None = Field(None, alias="AZCOSMOS_CONNSTR") + + model_config = ConfigDict( + populate_by_name=True, + ) From 7e82c3f3e1e69a23b6cedfb653f8006a2dccaa1c Mon Sep 17 00:00:00 2001 From: John Aziz Date: Fri, 3 Jan 2025 15:34:13 +0200 Subject: [PATCH 3/4] add missing import --- .../connectors/memory/azure_cosmosdb/azure_cosmosdb_settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/semantic_kernel/connectors/memory/azure_cosmosdb/azure_cosmosdb_settings.py b/python/semantic_kernel/connectors/memory/azure_cosmosdb/azure_cosmosdb_settings.py index b18ce02ce74b..cf2fecb6725d 100644 --- a/python/semantic_kernel/connectors/memory/azure_cosmosdb/azure_cosmosdb_settings.py +++ b/python/semantic_kernel/connectors/memory/azure_cosmosdb/azure_cosmosdb_settings.py @@ -2,7 +2,7 @@ from typing import ClassVar -from pydantic import Field, SecretStr +from pydantic import Field, SecretStr, ConfigDict from semantic_kernel.kernel_pydantic import KernelBaseSettings from semantic_kernel.utils.experimental_decorator import experimental_class From 278b5d7fade33745d423afadf9fd09c17d40f30e Mon Sep 17 00:00:00 2001 From: John Aziz Date: Sat, 4 Jan 2025 14:25:57 +0000 Subject: [PATCH 4/4] fix import order --- .../connectors/memory/azure_cosmosdb/azure_cosmosdb_settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/semantic_kernel/connectors/memory/azure_cosmosdb/azure_cosmosdb_settings.py b/python/semantic_kernel/connectors/memory/azure_cosmosdb/azure_cosmosdb_settings.py index cf2fecb6725d..212d45788ec7 100644 --- a/python/semantic_kernel/connectors/memory/azure_cosmosdb/azure_cosmosdb_settings.py +++ b/python/semantic_kernel/connectors/memory/azure_cosmosdb/azure_cosmosdb_settings.py @@ -2,7 +2,7 @@ from typing import ClassVar -from pydantic import Field, SecretStr, ConfigDict +from pydantic import ConfigDict, Field, SecretStr from semantic_kernel.kernel_pydantic import KernelBaseSettings from semantic_kernel.utils.experimental_decorator import experimental_class