Semantic Kernel

ai
nlp
Author

Oren Bochman

Published

Saturday, June 8, 2024

import semantic_kernel as sk
from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion, OpenAIChatCompletion
import semantic_kernel.ai.open_ai as sk_oai


kernel = sk.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()
api_key , org_id = sk_oai.openai_settings_from_dot_env()
kernel.add_text_completion_service("openai", OpenAIChatCompletion("gpt-3.5-turbo-0301", api_key, org_id))

print("You made a kernel!")
import semantic_kernel as sk
from semantic_kernel.connectors.ai.hugging_face import HuggingFaceTextCompletion

kernel = sk.Kernel()

kernel.add_text_completion_service("huggingface", HuggingFaceTextCompletion("gpt2", task="text-generation"))

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/2004-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/2004-06-03-sk-repl/semantic-kernel/2024-04-03-sk-repl.html.