import semantic_kernel as sk
from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion, OpenAIChatCompletion
import semantic_kernel.ai.open_ai as sk_oai
= sk.Kernel()
kernel
#useAzureOpenAI = False
# if useAzureOpenAI:
# deployment, api_key, endpoint = sk.azure_openai_settings_from_dot_env()
# kernel.add_text_completion_service("azureopenai", AzureChatCompletion(deployment, endpoint, api_key))
# else:
#api_key, org_id = sk.openai_settings_from_dot_env()
= sk_oai.openai_settings_from_dot_env()
api_key , org_id "openai", OpenAIChatCompletion("gpt-3.5-turbo-0301", api_key, org_id))
kernel.add_text_completion_service(
print("You made a kernel!")
import semantic_kernel as sk
from semantic_kernel.connectors.ai.hugging_face import HuggingFaceTextCompletion
= sk.Kernel()
kernel
"huggingface", HuggingFaceTextCompletion("gpt2", task="text-generation"))
kernel.add_text_completion_service(
print("You made an open source kernel using an open source AI model!")
Citation
BibTeX citation:
@online{bochman2024,
author = {Bochman, Oren},
title = {Semantic {Kernel}},
date = {2024-06-08},
url = {https://orenbochman.github.io/posts/2024/2024-06-03-sk-repl/semantic-kernel/2024-04-03-sk-repl.html},
langid = {en}
}
For attribution, please cite this work as:
Bochman, Oren. 2024. “Semantic Kernel.” June 8, 2024. https://orenbochman.github.io/posts/2024/2024-06-03-sk-repl/semantic-kernel/2024-04-03-sk-repl.html.