Skip to content

Commit 1285192

Browse files
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 😄
1 parent 07c09e6 commit 1285192

File tree

131 files changed

+634
-570
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+634
-570
lines changed

python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ usearch = [
124124
"pyarrow >= 12.0,< 20.0"
125125
]
126126
weaviate = [
127-
"weaviate-client>=4.10,<4.13",
127+
"weaviate-client>=4.10,<5.0",
128128
]
129129
pandas = [
130130
"pandas ~= 2.2"

python/samples/concepts/agents/azure_ai_agent/azure_ai_agent_as_kernel_function.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ async def main() -> None:
6767
# The filter is used for demonstration purposes to show the function invocation.
6868
kernel.add_filter("function_invocation", function_invocation_filter)
6969

70-
ai_agent_settings = AzureAIAgentSettings.create()
70+
ai_agent_settings = AzureAIAgentSettings()
7171

7272
async with (
7373
DefaultAzureCredential() as creds,

python/samples/concepts/agents/azure_ai_agent/azure_ai_agent_azure_ai_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636

3737
async def main() -> None:
38-
ai_agent_settings = AzureAIAgentSettings.create()
38+
ai_agent_settings = AzureAIAgentSettings()
3939

4040
async with (
4141
DefaultAzureCredential() as creds,

python/samples/concepts/agents/azure_ai_agent/azure_ai_agent_file_manipulation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
async def main() -> None:
21-
ai_agent_settings = AzureAIAgentSettings.create()
21+
ai_agent_settings = AzureAIAgentSettings()
2222

2323
async with (
2424
DefaultAzureCredential() as creds,

python/samples/concepts/agents/azure_ai_agent/azure_ai_agent_message_callback.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async def handle_intermediate_steps(message: ChatMessageContent) -> None:
4949

5050

5151
async def main() -> None:
52-
ai_agent_settings = AzureAIAgentSettings.create()
52+
ai_agent_settings = AzureAIAgentSettings()
5353

5454
async with (
5555
DefaultAzureCredential() as creds,

python/samples/concepts/agents/azure_ai_agent/azure_ai_agent_message_callback_streaming.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ async def handle_streaming_intermediate_steps(message: ChatMessageContent) -> No
4747

4848

4949
async def main() -> None:
50-
ai_agent_settings = AzureAIAgentSettings.create()
50+
ai_agent_settings = AzureAIAgentSettings()
5151

5252
async with (
5353
DefaultAzureCredential() as creds,

python/samples/concepts/agents/azure_ai_agent/azure_ai_agent_prompt_templating.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async def invoke_agent_with_template(template_str: str, template_format: str, de
5252
# Configure the prompt template
5353
prompt_config = PromptTemplateConfig(template=template_str, template_format=template_format)
5454

55-
ai_agent_settings = AzureAIAgentSettings.create()
55+
ai_agent_settings = AzureAIAgentSettings()
5656

5757
async with (
5858
DefaultAzureCredential() as creds,

python/samples/concepts/agents/azure_ai_agent/azure_ai_agent_streaming.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def get_item_price(
3636

3737

3838
async def main() -> None:
39-
ai_agent_settings = AzureAIAgentSettings.create()
39+
ai_agent_settings = AzureAIAgentSettings()
4040

4141
async with (
4242
DefaultAzureCredential() as creds,

python/samples/concepts/agents/azure_ai_agent/azure_ai_agent_structured_outputs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Planet(BaseModel):
3535

3636

3737
async def main():
38-
ai_agent_settings = AzureAIAgentSettings.create()
38+
ai_agent_settings = AzureAIAgentSettings()
3939
async with (
4040
DefaultAzureCredential() as creds,
4141
AzureAIAgent.create_client(

python/samples/concepts/on_your_data/azure_chat_gpt_with_data_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
# }
3636

3737
# Create the data source settings
38-
azure_ai_search_settings = AzureAISearchSettings.create()
38+
azure_ai_search_settings = AzureAISearchSettings()
3939

4040
az_source = AzureAISearchDataSource.from_azure_ai_search_settings(azure_ai_search_settings=azure_ai_search_settings)
4141
extra = ExtraBody(data_sources=[az_source])

0 commit comments

Comments
 (0)