Bumps [ruff](https://github.com/astral-sh/ruff) from 0.0.285 to 0.0.289. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/astral-sh/ruff/releases">ruff's releases</a>.</em></p> <blockquote> <h2>v0.0.289</h2> <!-- raw HTML omitted --> <h2>What's Changed</h2> <h3>Bug Fixes</h3> <ul> <li>Invert condition for < and <= in outdated version block by <a href="https://github.com/charliermarsh"><code>@charliermarsh</code></a> in <a href="https://redirect.github.com/astral-sh/ruff/pull/7284">astral-sh/ruff#7284</a></li> <li>Ignore <code>@override</code> method when enforcing <code>bad-dunder-name</code> rule by <a href="https://github.com/brendonh8"><code>@brendonh8</code></a> in <a href="https://redirect.github.com/astral-sh/ruff/pull/7224">astral-sh/ruff#7224</a></li> <li>Add <code>NotebookIndex</code> to the cache by <a href="https://github.com/dhruvmanila"><code>@dhruvmanila</code></a> in <a href="https://redirect.github.com/astral-sh/ruff/pull/6863">astral-sh/ruff#6863</a></li> </ul> <h3>Preview</h3> <p>This release includes a new preview mode which can be used to opt-in to unstable rules and features.</p> <ul> <li>Update rule selection to respect preview mode by <a href="https://github.com/zanieb"><code>@zanieb</code></a> in <a href="https://redirect.github.com/astral-sh/ruff/pull/7195">astral-sh/ruff#7195</a></li> <li>Display the <code>--preview</code> option in the CLI help menu by <a href="https://github.com/zanieb"><code>@zanieb</code></a> in <a href="https://redirect.github.com/astral-sh/ruff/pull/7274">astral-sh/ruff#7274</a></li> </ul> <p>See the <a href="https://beta.ruff.rs/docs/preview/">documentation</a> and <a href="https://github.com/astral-sh/ruff/discussions/6998">versioning discussion</a> for more details.</p> <h2>New Contributors</h2> <ul> <li><a href="https://github.com/brendonh8"><code>@brendonh8</code></a> made their first contribution in <a href="https://redirect.github.com/astral-sh/ruff/pull/7224">astral-sh/ruff#7224</a></li> </ul> <p><strong>Full Changelog</strong>: <a href="https://github.com/astral-sh/ruff/compare/v0.0.288...v0.0.289">https://github.com/astral-sh/ruff/compare/v0.0.288...v0.0.289</a></p> <h2>v0.0.288</h2> <h2>What's Changed</h2> <h3>Breaking Changes</h3> <ul> <li>Remove emoji identifier support by <a href="https://github.com/MichaReiser"><code>@MichaReiser</code></a> in <a href="https://redirect.github.com/astral-sh/ruff/pull/7212">astral-sh/ruff#7212</a></li> <li>Location agnostic GitLab fingerprints by <a href="https://github.com/gregersn"><code>@gregersn</code></a> in <a href="https://redirect.github.com/astral-sh/ruff/pull/7203">astral-sh/ruff#7203</a></li> </ul> <h3>Rules</h3> <ul> <li>[<code>ruff</code>] <ul> <li><code>RUF001</code>: Remove autofix for ambiguous unicode rule by <a href="https://github.com/charliermarsh"><code>@charliermarsh</code></a> in <a href="https://redirect.github.com/astral-sh/ruff/pull/7168">astral-sh/ruff#7168</a></li> </ul> </li> </ul> <h3>Settings</h3> <ul> <li>[<code>flake8-self</code>] <ul> <li><code>SLF001</code>: Add <code>extend-ignore-names</code> option by <a href="https://github.com/jaap3"><code>@jaap3</code></a> in <a href="https://redirect.github.com/astral-sh/ruff/pull/7194">astral-sh/ruff#7194</a></li> </ul> </li> </ul> <h3>Bug Fixes</h3> <ul> <li>[<code>flake8-bugbear</code>] <ul> <li><code>B006</code>: Add newline if fix is at end-of-file by <a href="https://github.com/charliermarsh"><code>@charliermarsh</code></a> in <a href="https://redirect.github.com/astral-sh/ruff/pull/7090">astral-sh/ruff#7090</a></li> <li><code>B006</code>: Fix function docstring followed by whitespace but no newline by <a href="https://github.com/zanieb"><code>@zanieb</code></a> in <a href="https://redirect.github.com/astral-sh/ruff/pull/7160">astral-sh/ruff#7160</a></li> <li><code>B009</code>: Parenthesize expressions when converting to attribute access by <a href="https://github.com/charliermarsh"><code>@charliermarsh</code></a> in <a href="https://redirect.github.com/astral-sh/ruff/pull/7091">astral-sh/ruff#7091</a></li> <li><code>B009</code>, <code>B010</code>: Fix <code>getattr</code> calls on <code>int</code> literals by <a href="https://github.com/density"><code>@density</code></a> in <a href="https://redirect.github.com/astral-sh/ruff/pull/7057">astral-sh/ruff#7057</a></li> <li><code>B013</code>: Supported starred exceptions in length-one tuple detection by <a href="https://github.com/charliermarsh"><code>@charliermarsh</code></a> in <a href="https://redirect.github.com/astral-sh/ruff/pull/7080">astral-sh/ruff#7080</a></li> <li><code>B013</code>: Insert required space when fixing by <a href="https://github.com/charliermarsh"><code>@charliermarsh</code></a> in <a href="https://redirect.github.com/astral-sh/ruff/pull/7148">astral-sh/ruff#7148</a></li> </ul> </li> <li>[<code>flake8-comprehensions</code>]</li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/astral-sh/ruff/blob/main/BREAKING_CHANGES.md">ruff's changelog</a>.</em></p> <blockquote> <h1>Breaking Changes</h1> <h2>0.0.288</h2> <h3>Remove support for emoji identifiers (<a href="https://redirect.github.com/astral-sh/ruff/pull/7212">#7212</a>)</h3> <p>Previously, Ruff supported the non-standard compliant emoji identifiers e.g. <code>📦 = 1</code>. We decided to remove this non-standard language extension, and Ruff now reports syntax errors for emoji identifiers in your code, the same as CPython.</p> <h3>Improved GitLab fingerprints (<a href="https://redirect.github.com/astral-sh/ruff/pull/7203">#7203</a>)</h3> <p>GitLab uses fingerprints to identify new, existing, or fixed violations. Previously, Ruff included the violation's position in the fingerprint. Using the location has the downside that changing any code before the violation causes the fingerprint to change, resulting in GitLab reporting one fixed and one new violation even though it is a pre-existing violation.</p> <p>Ruff now uses a more stable location-agnostic fingerprint to minimize that existing violations incorrectly get marked as fixed and re-reported as new violations.</p> <p>Expect GitLab to report each pre-existing violation in your project as fixed and a new violation in your Ruff upgrade PR.</p> <h2>0.0.283 / 0.284</h2> <h3>The target Python version now defaults to 3.8 instead of 3.10 (<a href="https://redirect.github.com/astral-sh/ruff/pull/6397">#6397</a>)</h3> <p>Previously, when a target Python version was not specified, Ruff would use a default of Python 3.10. However, it is safer to default to an <em>older</em> Python version to avoid assuming the availability of new features. We now default to the oldest supported Python version which is currently Python 3.8.</p> <p>(We still support Python 3.7 but since <a href="https://devguide.python.org/versions/#unsupported-versions">it has reached EOL</a> we've decided not to make it the default here.)</p> <p>Note this change was announced in 0.0.283 but not active until 0.0.284.</p> <h2>0.0.277</h2> <h3><code>.ipynb_checkpoints</code>, <code>.pyenv</code>, <code>.pytest_cache</code>, and <code>.vscode</code> are now excluded by default (<a href="https://redirect.github.com/astral-sh/ruff/pull/5513">#5513</a>)</h3> <p>Ruff maintains a list of default exclusions, which now consists of the following patterns:</p> <ul> <li><code>.bzr</code></li> <li><code>.direnv</code></li> <li><code>.eggs</code></li> <li><code>.git</code></li> <li><code>.git-rewrite</code></li> <li><code>.hg</code></li> <li><code>.ipynb_checkpoints</code></li> <li><code>.mypy_cache</code></li> <li><code>.nox</code></li> <li><code>.pants.d</code></li> <li><code>.pyenv</code></li> <li><code>.pytest_cache</code></li> <li><code>.pytype</code></li> <li><code>.ruff_cache</code></li> <li><code>.svn</code></li> <li><code>.tox</code></li> <li><code>.venv</code></li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/astral-sh/ruff/commit/e7a27794022e18b05136ce8e4fc121f14713ed02"><code>e7a2779</code></a> Bump version to v0.0.289 (<a href="https://redirect.github.com/astral-sh/ruff/issues/7308">#7308</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/008da95b29d2b1ccc20e8b5e86bac51296d2df05"><code>008da95</code></a> Add preview documentation section (<a href="https://redirect.github.com/astral-sh/ruff/issues/7281">#7281</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/5d4dd3e38e624dffe850853fcc9fb5de38a36d58"><code>5d4dd3e</code></a> Set the target deployment to <code>main</code> during dispatched documentation deploymen...</li> <li><a href="https://github.com/astral-sh/ruff/commit/e561f5783b30eb318c0fa1f7d7d24ad8d89c6e05"><code>e561f57</code></a> Fix(vscode): Respect line length ruff.toml configuration (<a href="https://redirect.github.com/astral-sh/ruff/issues/7306">#7306</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/ee0f1270cf8cf816754dbc471e8fb855ca40ca9c"><code>ee0f127</code></a> Add <code>NotebookIndex</code> to the cache (<a href="https://redirect.github.com/astral-sh/ruff/issues/6863">#6863</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/e7b7e4a18d881893132dc5e6b2209ebdcedfb253"><code>e7b7e4a</code></a> Add documentation to <code>duplicate-union-member</code> (<a href="https://redirect.github.com/astral-sh/ruff/issues/7225">#7225</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/b4419c34ea8f820157cf428e2bf5f7f2d415c894"><code>b4419c3</code></a> Ignore <code>@override</code> method when enforcing <code>bad-dunder-name</code> rule (<a href="https://redirect.github.com/astral-sh/ruff/issues/7224">#7224</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/08f19226b9571fb87cec16231bb26b21249e2a92"><code>08f1922</code></a> Fix panic when formatting binary expression with two implicit concatenated st...</li> <li><a href="https://github.com/astral-sh/ruff/commit/1e6df19a351170ded4b1e1a4e068993107bd1047"><code>1e6df19</code></a> Bool expression comment placement (<a href="https://redirect.github.com/astral-sh/ruff/issues/7269">#7269</a>)</li> <li><a href="https://github.com/astral-sh/ruff/commit/c21b960fc7ac8b60a3d2e5cc753ed4a9ecfde356"><code>c21b960</code></a> Display the <code>--preview</code> option in the CLI help menu (<a href="https://redirect.github.com/astral-sh/ruff/issues/7274">#7274</a>)</li> <li>Additional commits viewable in <a href="https://github.com/astral-sh/ruff/compare/v0.0.285...v0.0.289">compare view</a></li> </ul> </details> <br /> [](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 merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@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) </details> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Get Started with Semantic Kernel ⚡
Install the latest package:
python -m pip install --upgrade semantic-kernel
AI Services
OpenAI / Azure OpenAI API keys
Make sure you have an Open AI API Key or Azure Open AI service key
Copy those keys into a .env file (see the .env.example file):
OPENAI_API_KEY=""
OPENAI_ORG_ID=""
AZURE_OPENAI_DEPLOYMENT_NAME=""
AZURE_OPENAI_ENDPOINT=""
AZURE_OPENAI_API_KEY=""
Running a prompt
import semantic_kernel as sk
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion, AzureChatCompletion
kernel = sk.Kernel()
# Prepare OpenAI service using credentials stored in the `.env` file
api_key, org_id = sk.openai_settings_from_dot_env()
kernel.add_chat_service("chat-gpt", OpenAIChatCompletion("gpt-3.5-turbo", api_key, org_id))
# Alternative using Azure:
# deployment, api_key, endpoint = sk.azure_openai_settings_from_dot_env()
# kernel.add_chat_service("dv", AzureChatCompletion(deployment, endpoint, api_key))
# Wrap your prompt in a function
prompt = kernel.create_semantic_function("""
1) A robot may not injure a human being or, through inaction,
allow a human being to come to harm.
2) A robot must obey orders given it by human beings except where
such orders would conflict with the First Law.
3) A robot must protect its own existence as long as such protection
does not conflict with the First or Second Law.
Give me the TLDR in exactly 5 words.""")
# Run your prompt
print(prompt()) # => Robots must not harm humans.
Semantic functions are Prompts with input parameters
# Create a reusable function with one input parameter
summarize = kernel.create_semantic_function("{{$input}}\n\nOne line TLDR with the fewest words.")
# Summarize the laws of thermodynamics
print(summarize("""
1st Law of Thermodynamics - Energy cannot be created or destroyed.
2nd Law of Thermodynamics - For a spontaneous process, the entropy of the universe increases.
3rd Law of Thermodynamics - A perfect crystal at zero Kelvin has zero entropy."""))
# Summarize the laws of motion
print(summarize("""
1. An object at rest remains at rest, and an object in motion remains in motion at constant speed and in a straight line unless acted on by an unbalanced force.
2. The acceleration of an object depends on the mass of the object and the amount of force applied.
3. Whenever one object exerts a force on another object, the second object exerts an equal and opposite on the first."""))
# Summarize the law of universal gravitation
print(summarize("""
Every point mass attracts every single other point mass by a force acting along the line intersecting both points.
The force is proportional to the product of the two masses and inversely proportional to the square of the distance between them."""))
# Output:
# > Energy conserved, entropy increases, zero entropy at 0K.
# > Objects move in response to forces.
# > Gravitational force between two point masses is inversely proportional to the square of the distance between them.
Semantic Kernel Notebooks
The repository contains a few Python and C# notebooks that demonstrates how to get started with the Semantic Kernel.
Python notebooks:
- Getting started with Semantic Kernel
- Loading and configuring Semantic Kernel
- Running AI prompts from file
- Creating Semantic Functions at runtime (i.e. inline functions)
- Using Context Variables to Build a Chat Experience
- Introduction to planners
- Building Memory with Embeddings
- Using Hugging Face for Skills
- Combining native functions and semantic functions
- Groundedness Checking with Semantic Kernel
- Returning multiple results per prompt
- Streaming completions with Semantic Kernel
SK Frequently Asked Questions
How does Python SK compare to the C# version of Semantic Kernel?
The two SDKs are compatible and at the core they follow the same design principles. Some features are still available only in the C# version, and being ported Refer to the FEATURE MATRIX doc to see where things stand in matching the features and functionality of the main SK branch. Over time there will be some features available only in the Python version, and others only in the C# version, for example adapters to external services, scientific libraries, etc.