Files
semantic-kernel/python/notebooks/01-basic-loading-the-kernel.ipynb
T
Evan Mattson 37edd5fb7e Python: Bump versions to 0.9.5b1 for release. (#5713)
### Motivation and Context

Bump versions to 0.9.5b1 for release.

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

### Description

Bump versions to 0.9.5b1 for release.

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

### 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 😄
2024-04-01 15:40:29 +00:00

3.4 KiB

Basic Loading of the Kernel

To run the notebooks we recommend using Poetry and starting a shell with a virtual environment prepared to use SK.

See DEV_SETUP.md for more information.

In [ ]:
!python -m pip install semantic-kernel==0.9.5b1
In [1]:
import semantic_kernel as sk

When using the kernel for AI requests, the kernel needs some settings like URL and credentials to the AI models.

The SDK currently supports OpenAI and Azure OpenAI, among other connectors.

If you need an Azure OpenAI key, go here.

In [ ]:
from services import Service

# Select a service to use for this notebook (available services: OpenAI, AzureOpenAI, HuggingFace)
selectedService = Service.OpenAI
In [ ]:
kernel = sk.Kernel()

service_id = None
if selectedService == Service.OpenAI:
    from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion

    api_key, org_id = sk.openai_settings_from_dot_env()
    service_id = "oai_chat_gpt"
    kernel.add_service(
        OpenAIChatCompletion(service_id=service_id, ai_model_id="gpt-3.5-turbo-1106", api_key=api_key, org_id=org_id),
    )
elif selectedService == Service.AzureOpenAI:
    from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion

    deployment, api_key, endpoint = sk.azure_openai_settings_from_dot_env()
    service_id = "aoai_chat_completion"
    kernel.add_service(
        AzureChatCompletion(service_id=service_id, deployment_name=deployment, endpoint=endpoint, api_key=api_key),
    )

Great, now that you're familiar with setting up the Semantic Kernel, let's see how we can use it to run prompts.