Files
semantic-kernel/python
dependabot[bot] 620e412c70 Python: Bump werkzeug from 3.1.1 to 3.1.6 in /python (#13605)
Bumps [werkzeug](https://github.com/pallets/werkzeug) from 3.1.1 to
3.1.6.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/pallets/werkzeug/releases">werkzeug's
releases</a>.</em></p>
<blockquote>
<h2>3.1.6</h2>
<p>This is the Werkzeug 3.1.6 security fix release, which fixes a
security issue but does not otherwise change behavior and should not
result in breaking changes compared to the latest feature release.</p>
<p>PyPI: <a
href="https://pypi.org/project/Werkzeug/3.1.6/">https://pypi.org/project/Werkzeug/3.1.6/</a>
Changes: <a
href="https://werkzeug.palletsprojects.com/page/changes/#version-3-1-6">https://werkzeug.palletsprojects.com/page/changes/#version-3-1-6</a></p>
<ul>
<li><code>safe_join</code> on Windows does not allow special devices
names in multi-segment paths. <a
href="https://github.com/pallets/werkzeug/security/advisories/GHSA-29vq-49wr-vm6x">GHSA-29vq-49wr-vm6x</a></li>
</ul>
<h2>3.1.5</h2>
<p>This is the Werkzeug 3.1.5 security fix release, which fixes security
issues and bugs but does not otherwise change behavior and should not
result in breaking changes compared to the latest feature release.</p>
<p>PyPI: <a
href="https://pypi.org/project/Werkzeug/3.1.5/">https://pypi.org/project/Werkzeug/3.1.5/</a>
Changes: <a
href="https://werkzeug.palletsprojects.com/page/changes/#version-3-1-5">https://werkzeug.palletsprojects.com/page/changes/#version-3-1-5</a>
Milestone: <a
href="https://github.com/pallets/werkzeug/milestone/43?closed=1">https://github.com/pallets/werkzeug/milestone/43?closed=1</a></p>
<ul>
<li><code>safe_join</code> on Windows does not allow more special device
names, regardless of extension or surrounding spaces. <a
href="https://github.com/pallets/werkzeug/security/advisories/GHSA-87hc-h4r5-73f7">GHSA-87hc-h4r5-73f7</a></li>
<li>The multipart form parser handles a <code>\r\n</code> sequence at a
chunk boundary. This fixes the previous attempt, which caused incorrect
content lengths. <a
href="https://redirect.github.com/pallets/werkzeug/issues/3065">#3065</a>
<a
href="https://redirect.github.com/pallets/werkzeug/issues/3077">#3077</a></li>
<li>Fix <code>AttributeError</code> when initializing
<code>DebuggedApplication</code> with <code>pin_security=False</code>.
<a
href="https://redirect.github.com/pallets/werkzeug/issues/3075">#3075</a></li>
</ul>
<h2>3.1.4</h2>
<p>This is the Werkzeug 3.1.4 fix release, which fixes bugs but does not
otherwise change behavior and should not result in breaking changes
compared to the latest feature release.</p>
<p>PyPI: <a
href="https://pypi.org/project/Werkzeug/3.1.4/">https://pypi.org/project/Werkzeug/3.1.4/</a>
Changes: <a
href="https://werkzeug.palletsprojects.com/page/changes/#version-3-1-4">https://werkzeug.palletsprojects.com/page/changes/#version-3-1-4</a>
Milestone: <a
href="https://github.com/pallets/werkzeug/milestone/42?closed=1">https://github.com/pallets/werkzeug/milestone/42?closed=1</a></p>
<ul>
<li><code>safe_join</code> on Windows does not allow special device
names. This prevents reading from these when using
<code>send_from_directory</code>. <code>secure_filename</code> already
prevented writing to these. <a
href="https://github.com/pallets/werkzeug/security/advisories/GHSA-hgf8-39gv-g3f2">ghsa-hgf8-39gv-g3f2</a></li>
<li>The debugger pin fails after 10 attempts instead of 11. <a
href="https://redirect.github.com/pallets/werkzeug/issues/3020">#3020</a></li>
<li>The multipart form parser handles a <code>\r\n</code> sequence at a
chunk boundary. <a
href="https://redirect.github.com/pallets/werkzeug/issues/3065">#3065</a></li>
<li>Improve CPU usage during Watchdog reloader. <a
href="https://redirect.github.com/pallets/werkzeug/issues/3054">#3054</a></li>
<li><code>Request.json</code> annotation is more accurate. <a
href="https://redirect.github.com/pallets/werkzeug/issues/3067">#3067</a></li>
<li>Traceback rendering handles when the line number is beyond the
available source lines. <a
href="https://redirect.github.com/pallets/werkzeug/issues/3044">#3044</a></li>
<li><code>HTTPException.get_response</code> annotation and doc better
conveys the distinction between WSGI and sans-IO responses. <a
href="https://redirect.github.com/pallets/werkzeug/issues/3056">#3056</a></li>
</ul>
<h2>3.1.3</h2>
<p>This is the Werkzeug 3.1.3 fix release, which fixes bugs but does not
otherwise change behavior and should not result in breaking changes vs
3.1.0.</p>
<p>PyPI: <a
href="https://pypi.org/project/Werkzeug/3.1.3/">https://pypi.org/project/Werkzeug/3.1.3/</a>
Changes: <a
href="https://werkzeug.palletsprojects.com/en/stable/changes/#version-3-1-3">https://werkzeug.palletsprojects.com/en/stable/changes/#version-3-1-3</a>
Milestone: <a
href="https://github.com/pallets/werkzeug/milestone/41?closed=1">https://github.com/pallets/werkzeug/milestone/41?closed=1</a></p>
<ul>
<li>Initial data passed to <code>MultiDict</code> and similar interfaces
only accepts <code>list</code>, <code>tuple</code>, or <code>set</code>
when passing multiple values. It had been changed to accept any
<code>Collection</code>, but this matched types that should be treated
as single values, such as <code>bytes</code>. <a
href="https://redirect.github.com/pallets/werkzeug/issues/2994">#2994</a></li>
<li>When the <code>Host</code> header is not set and
<code>Request.host</code> falls back to the WSGI
<code>SERVER_NAME</code> value, if that value is an IPv6 address it is
wrapped in <code>[]</code> to match the <code>Host</code> header. <a
href="https://redirect.github.com/pallets/werkzeug/issues/2993">#2993</a></li>
</ul>
<h2>3.1.2</h2>
<p>This is the Werkzeug 3.1.2 fix release, which fixes bugs but does not
otherwise change behavior and should not result in breaking changes vs
3.1.0.</p>
<p>PyPI: <a
href="https://pypi.org/project/Werkzeug/3.1.2/">https://pypi.org/project/Werkzeug/3.1.2/</a>
Changes: <a
href="https://werkzeug.palletsprojects.com/en/stable/changes/#version-3-1-2">https://werkzeug.palletsprojects.com/en/stable/changes/#version-3-1-2</a></p>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/pallets/werkzeug/blob/main/CHANGES.rst">werkzeug's
changelog</a>.</em></p>
<blockquote>
<h2>Version 3.1.6</h2>
<p>Released 2026-02-19</p>
<ul>
<li><code>safe_join</code> on Windows does not allow special devices
names in
multi-segment paths. :ghsa:<code>29vq-49wr-vm6x</code></li>
</ul>
<h2>Version 3.1.5</h2>
<p>Released 2026-01-08</p>
<ul>
<li><code>safe_join</code> on Windows does not allow more special device
names, regardless
of extension or surrounding spaces.
:ghsa:<code>87hc-h4r5-73f7</code></li>
<li>The multipart form parser handles a <code>\r\n</code> sequence at a
chunk boundary.
This fixes the previous attempt, which caused incorrect content lengths.
:issue:<code>3065</code> :issue:<code>3077</code></li>
<li>Fix <code>AttributeError</code> when initializing
<code>DebuggedApplication</code> with
<code>pin_security=False</code>. :issue:<code>3075</code></li>
</ul>
<h2>Version 3.1.4</h2>
<p>Released 2025-11-28</p>
<ul>
<li><code>safe_join</code> on Windows does not allow special device
names. This prevents
reading from these when using <code>send_from_directory</code>.
<code>secure_filename</code>
already prevented writing to these.
:ghsa:<code>hgf8-39gv-g3f2</code></li>
<li>The debugger pin fails after 10 attempts instead of 11.
:pr:<code>3020</code></li>
<li>The multipart form parser handles a <code>\r\n</code> sequence at a
chunk boundary.
:issue:<code>3065</code></li>
<li>Improve CPU usage during Watchdog reloader.
:issue:<code>3054</code></li>
<li><code>Request.json</code> annotation is more accurate.
:issue:<code>3067</code></li>
<li>Traceback rendering handles when the line number is beyond the
available
source lines. :issue:<code>3044</code></li>
<li><code>HTTPException.get_response</code> annotation and doc better
conveys the
distinction between WSGI and sans-IO responses.
:issue:<code>3056</code></li>
</ul>
<h2>Version 3.1.3</h2>
<p>Released 2024-11-08</p>
<ul>
<li>Initial data passed to <code>MultiDict</code> and similar interfaces
only accepts
<code>list</code>, <code>tuple</code>, or <code>set</code> when passing
multiple values. It had been
changed to accept any <code>Collection</code>, but this matched types
that should be</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/pallets/werkzeug/commit/04da1b5221b7a7b57e82246e4b5741d37a6b2e56"><code>04da1b5</code></a>
release version 3.1.6</li>
<li><a
href="https://github.com/pallets/werkzeug/commit/f407712fdc60a09c2b3f4fe7db557703e5d9338d"><code>f407712</code></a>
Merge commit from fork</li>
<li><a
href="https://github.com/pallets/werkzeug/commit/f54fe98026253e70fbbcd35a6b52fb67cfff1c03"><code>f54fe98</code></a>
safe_join prevents Windows special device names in multi-segment
paths</li>
<li><a
href="https://github.com/pallets/werkzeug/commit/d005985ef69ffe3275eda8fb6fb25e074dbe871b"><code>d005985</code></a>
start version 3.1.6</li>
<li><a
href="https://github.com/pallets/werkzeug/commit/8565c2cbd6681ae8463e77d4fc0795324a7fdae7"><code>8565c2c</code></a>
document rule priority (<a
href="https://redirect.github.com/pallets/werkzeug/issues/3102">#3102</a>)</li>
<li><a
href="https://github.com/pallets/werkzeug/commit/3febc7e90072bffe04c27e6b7478dfc4f88930df"><code>3febc7e</code></a>
document rule priority</li>
<li><a
href="https://github.com/pallets/werkzeug/commit/2525b827646c10ab7adb334664e6a4af1b769181"><code>2525b82</code></a>
remove state machine docs</li>
<li><a
href="https://github.com/pallets/werkzeug/commit/4abfbd553cdeb6d4e6fa693340d52b13c884079f"><code>4abfbd5</code></a>
rewrite build docstring (<a
href="https://redirect.github.com/pallets/werkzeug/issues/3097">#3097</a>)</li>
<li><a
href="https://github.com/pallets/werkzeug/commit/161c18b2a8800ae6ef377fb3cbdb933a878fea67"><code>161c18b</code></a>
rewrite build docstring</li>
<li><a
href="https://github.com/pallets/werkzeug/commit/86e11c29e44726dae524cd9db11549b3b1ad681d"><code>86e11c2</code></a>
release version 3.1.5 (<a
href="https://redirect.github.com/pallets/werkzeug/issues/3085">#3085</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/pallets/werkzeug/compare/3.1.1...3.1.6">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=werkzeug&package-manager=uv&previous-version=3.1.1&new-version=3.1.6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/microsoft/semantic-kernel/network/alerts).

</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-19 11:20:39 +00:00
..
2023-04-13 16:12:36 -07:00
2024-08-27 16:45:09 +00:00

Get Started with Semantic Kernel Python

Highlights

  • Flexible Agent Framework: build, orchestrate, and deploy AI agents and multi-agent systems
  • Multi-Agent Systems: Model workflows and collaboration between AI specialists
  • Plugin Ecosystem: Extend with Python, OpenAPI, Model Context Protocol (MCP), and more
  • LLM Support: OpenAI, Azure OpenAI, Hugging Face, Mistral, Google AI, ONNX, Ollama, NVIDIA NIM, and others
  • Vector DB Support: Azure AI Search, Elasticsearch, Chroma, and more
  • Process Framework: Build structured business processes with workflow modeling
  • Multimodal: Text, vision, audio

Quick Install

pip install --upgrade semantic-kernel
# Optional: Add integrations
pip install --upgrade semantic-kernel[hugging_face]
pip install --upgrade semantic-kernel[all]

Supported Platforms:

  • Python: 3.10+
  • OS: Windows, macOS, Linux

1. Setup API Keys

Set as environment variables, or create a .env file at your project root:

OPENAI_API_KEY=sk-...
OPENAI_CHAT_MODEL_ID=...
...
AZURE_OPENAI_API_KEY=...
AZURE_OPENAI_ENDPOINT=...
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME=...
...

You can also override environment variables by explicitly passing configuration parameters to the AI service constructor:

chat_service = AzureChatCompletion(
    api_key=...,
    endpoint=...,
    deployment_name=...,
    api_version=...,
)

See the following setup guide for more information.

2. Use the Kernel for Prompt Engineering

Create prompt functions and invoke them via the Kernel:

import asyncio
from semantic_kernel import Kernel
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion
from semantic_kernel.functions import KernelArguments

kernel = Kernel()
kernel.add_service(OpenAIChatCompletion())

prompt = """
1) A robot may not injure a human being...
2) A robot must obey orders given it by human beings...
3) A robot must protect its own existence...

Give me the TLDR in exactly {{$num_words}} words."""


async def main():
    result = await kernel.invoke_prompt(prompt, arguments=KernelArguments(num_words=5))
    print(result)


asyncio.run(main())
# Output: Protect humans, obey, self-preserve, prioritized.

3. Directly Use AI Services (No Kernel Required)

You can use the AI service classes directly for advanced workflows:

import asyncio
import asyncio

from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion, OpenAIChatPromptExecutionSettings
from semantic_kernel.contents import ChatHistory


async def main():
    service = OpenAIChatCompletion()
    settings = OpenAIChatPromptExecutionSettings()

    chat_history = ChatHistory(system_message="You are a helpful assistant.")
    chat_history.add_user_message("Write a haiku about Semantic Kernel.")
    response = await service.get_chat_message_content(chat_history=chat_history, settings=settings)
    print(response.content)

    """
    Output:

    Thoughts weave through context,  
    Semantic threads interlace—  
    Kernel sparks meaning.
    """


asyncio.run(main())

4. Build an Agent with Plugins and Tools

Add Python functions as plugins or Pydantic models as structured outputs;

Enhance your agent with custom tools (plugins) and structured output:

import asyncio
from typing import Annotated
from pydantic import BaseModel
from semantic_kernel.agents import ChatCompletionAgent
from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion, OpenAIChatPromptExecutionSettings
from semantic_kernel.functions import kernel_function, KernelArguments

class MenuPlugin:
    @kernel_function(description="Provides a list of specials from the menu.")
    def get_specials(self) -> Annotated[str, "Returns the specials from the menu."]:
        return """
        Special Soup: Clam Chowder
        Special Salad: Cobb Salad
        Special Drink: Chai Tea
        """

    @kernel_function(description="Provides the price of the requested menu item.")
    def get_item_price(
        self, menu_item: Annotated[str, "The name of the menu item."]
    ) -> Annotated[str, "Returns the price of the menu item."]:
        return "$9.99"

class MenuItem(BaseModel):
    # Used for structured outputs
    price: float
    name: str

async def main():
    # Configure structured outputs format
    settings = OpenAIChatPromptExecutionSettings()
    settings.response_format = MenuItem

    # Create agent with plugin and settings
    agent = ChatCompletionAgent(
        service=AzureChatCompletion(),
        name="SK-Assistant",
        instructions="You are a helpful assistant.",
        plugins=[MenuPlugin()],
        arguments=KernelArguments(settings)
    )

    response = await agent.get_response("What is the price of the soup special?")
    print(response.content)

    # Output:
    # The price of the Clam Chowder, which is the soup special, is $9.99.

asyncio.run(main()) 

You can explore additional getting started agent samples here.

5. Multi-Agent Orchestration

Coordinate a group of agents to iteratively solve a problem or refine content together:

import asyncio
from semantic_kernel.agents import ChatCompletionAgent, GroupChatOrchestration, RoundRobinGroupChatManager
from semantic_kernel.agents.runtime import InProcessRuntime
from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion

def get_agents():
    return [
        ChatCompletionAgent(
            name="Writer",
            instructions="You are a creative content writer. Generate and refine slogans based on feedback.",
            service=AzureChatCompletion(),
        ),
        ChatCompletionAgent(
            name="Reviewer",
            instructions="You are a critical reviewer. Provide detailed feedback on proposed slogans.",
            service=AzureChatCompletion(),
        ),
    ]

async def main():
    agents = get_agents()
    group_chat = GroupChatOrchestration(
        members=agents,
        manager=RoundRobinGroupChatManager(max_rounds=5),
    )
    runtime = InProcessRuntime()
    runtime.start()
    result = await group_chat.invoke(
        task="Create a slogan for a new electric SUV that is affordable and fun to drive.",
        runtime=runtime,
    )
    value = await result.get()
    print(f"Final Slogan: {value}")

    # Example Output:
    # Final Slogan: "Feel the Charge: Adventure Meets Affordability in Your New Electric SUV!"

    await runtime.stop_when_idle()

if __name__ == "__main__":
    asyncio.run(main())

For orchestration-focused examples, see these orchestration samples.

More Examples & Notebooks

Semantic Kernel Documentation