Skip to main content

No project description provided

Reason this release was yanked:

temp package

Project description

Setup

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_API_KEY=""
AZURE_OPENAI_ENDPOINT=""
AZURE_OPENAI_DEPLOYMENT_NAME=""

Using Poetry

First, navigate to the directory containing this README using your chosen shell. You will need to have Python 3.10 installed.

Install the Poetry package manager and create a project virtual environment. (Note: we require at least Poetry 1.2.0 and Python 3.10.)

# Install poetry package
pip3 install poetry
# Use poetry to install project deps
poetry install
# Use poetry to activate project venv
poetry shell

Get Started with Semantic Kernel ⚡

Example: Running a simple prompt.

import semantic_kernel as sk
from semantic_kernel.ai.open_ai import OpenAITextCompletion

kernel = sk.create_kernel()

# Prepare OpenAI backend using credentials stored in the `.env` file
api_key, org_id = sk.openai_settings_from_dot_env()
kernel.config.add_text_backend("dv", OpenAITextCompletion("text-davinci-003", api_key, org_id))

# 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.

Example: Turn prompts into reusable functions 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.

How does this compare to the C# version of Semantic Kernel?

Refer to the FEATURE_PARITY.md doc to see where things stand in matching the features and functionality of the main SK branch.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

semantic_kernel-0.2.0.dev0.tar.gz (40.9 kB view details)

Uploaded Source

Built Distribution

semantic_kernel-0.2.0.dev0-py3-none-any.whl (77.1 kB view details)

Uploaded Python 3

File details

Details for the file semantic_kernel-0.2.0.dev0.tar.gz.

File metadata

  • Download URL: semantic_kernel-0.2.0.dev0.tar.gz
  • Upload date:
  • Size: 40.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for semantic_kernel-0.2.0.dev0.tar.gz
Algorithm Hash digest
SHA256 89db79c20c3c309f5f94a8244d3ec0a0fe558fa4a342bbaedf391081cf596485
MD5 3d601882a73c1c43880f91eb830baa86
BLAKE2b-256 ed2cca5adada901e517e854064c4c7ef541fcb50f70ca7c4d31a85927aa0e333

See more details on using hashes here.

File details

Details for the file semantic_kernel-0.2.0.dev0-py3-none-any.whl.

File metadata

File hashes

Hashes for semantic_kernel-0.2.0.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ebeaea042dcc0476aeb78e6a300fc7ab96171c2ed285d4ce1e7ce05b3a4a309
MD5 68d179d416eb20e58a5c36648e3ed051
BLAKE2b-256 87df1d0966c90185e581f266eba0b91dd4da33f4e389b34494009cb5a03ecb1e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page