mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 02:19:06 +00:00
Bumps [pycryptodome](https://github.com/Legrandin/pycryptodome) from 3.19.0 to 3.19.1. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/Legrandin/pycryptodome/releases">pycryptodome's releases</a>.</em></p> <blockquote> <h2>v3.19.1 - Zeil</h2> <h2>Resolved issues</h2> <ul> <li>Fixed a side-channel leakage with OAEP decryption that could be exploited to carry out a Manger attack. Thanks to Hubert Kario.</li> </ul> <h2>v3.19.1 - Zeil (pycryptodomex)</h2> <h2>Resolved issues</h2> <ul> <li>Fixed a side-channel leakage with OAEP decryption that could be exploited to carry out a Manger attack. Thanks to Hubert Kario.</li> </ul> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/Legrandin/pycryptodome/blob/master/Changelog.rst">pycryptodome's changelog</a>.</em></p> <blockquote> <p>3.19.1 (28 December 2023) ++++++++++++++++++++++++++</p> <h2>Resolved issues</h2> <ul> <li>Fixed a side-channel leakage with OAEP decryption that could be exploited to carry out a Manger attack. Thanks to Hubert Kario.</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/Legrandin/pycryptodome/commit/ef270ab436bddb437f8de122085bcf26dc9ad904"><code>ef270ab</code></a> Update wheels action</li> <li><a href="https://github.com/Legrandin/pycryptodome/commit/3278edd0e99d1a45231de4b4b2a77b50963431e9"><code>3278edd</code></a> Update changelog and version</li> <li><a href="https://github.com/Legrandin/pycryptodome/commit/10e8216079e6965eddac4bf293c3049a8b76b5d7"><code>10e8216</code></a> Update PSS verify signature code example.</li> <li><a href="https://github.com/Legrandin/pycryptodome/commit/4ec4b85c65210a2809974b2fd1e6677cf2b0fc57"><code>4ec4b85</code></a> Bump version</li> <li><a href="https://github.com/Legrandin/pycryptodome/commit/0deea1bfe1489e8c80d2053bbb06a1aa0b181ebd"><code>0deea1b</code></a> Use constant-time (faster) padding decoding also for OAEP</li> <li><a href="https://github.com/Legrandin/pycryptodome/commit/519e7aea6de4e8f03b62c6e1dba724aca738882e"><code>519e7ae</code></a> Avoid changing signature of RSA._decrypt() method if possible</li> <li><a href="https://github.com/Legrandin/pycryptodome/commit/1aa9dca20cd9485c8bcef2ecfdd05d407ae9edb7"><code>1aa9dca</code></a> Update changelog and bump version</li> <li><a href="https://github.com/Legrandin/pycryptodome/commit/afb5e27a15efe59e33c2825d40ef44995c13b8bc"><code>afb5e27</code></a> Fix side-channel leakage in RSA decryption</li> <li><a href="https://github.com/Legrandin/pycryptodome/commit/ee91c677a0862914aa7c0bf5829dc59306a93630"><code>ee91c67</code></a> Update CMAC.py</li> <li><a href="https://github.com/Legrandin/pycryptodome/commit/43a466d170a5e28187732b90b2a7594ab06b6c6d"><code>43a466d</code></a> Fix small "passes" typo.</li> <li>Additional commits viewable in <a href="https://github.com/Legrandin/pycryptodome/compare/v3.19.0...v3.19.1">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) You can trigger a rebase of this PR 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) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/microsoft/semantic-kernel/network/alerts). </details> > **Note** > Automatic rebases have been disabled on this pull request as it has been open for over 30 days. Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Evan Mattson <[email protected]>
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 OpenAI API Key or Azure OpenAI 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 asyncio
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
# Note: functions are run asynchronously
async def main():
print(await prompt()) # => Robots must not harm humans.
if __name__ == "__main__":
asyncio.run(main())
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(await 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(await 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(await 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 Plugins
- 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.