mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 02:19:06 +00:00
Moving kernel-syntax-examples to the python/samples folder. Leaving README behind to point to the new folders (will delete in a few sprints) ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows SK Contribution Guidelines (https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) - [X] The code follows the .NET coding conventions (https://learn.microsoft.com/dotnet/csharp/fundamentals/coding-style/coding-conventions) verified with `dotnet format` - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄 Co-authored-by: name <email>
35 lines
992 B
Python
35 lines
992 B
Python
# Copyright (c) Microsoft. All rights reserved.
|
|
|
|
import asyncio
|
|
import os
|
|
|
|
import semantic_kernel as sk
|
|
import semantic_kernel.connectors.ai.open_ai as sk_oai
|
|
|
|
kernel = sk.Kernel()
|
|
|
|
useAzureOpenAI = False
|
|
model = "text-davinci-002"
|
|
service_id = model
|
|
|
|
# Configure AI service used by the kernel
|
|
if useAzureOpenAI:
|
|
api_key, endpoint = sk.azure_openai_settings_from_dot_env()
|
|
kernel.add_text_completion_service(
|
|
service_id, sk_oai.AzureTextCompletion(model, api_key, endpoint)
|
|
)
|
|
else:
|
|
api_key, org_id = sk.openai_settings_from_dot_env()
|
|
kernel.add_text_completion_service(
|
|
service_id, sk_oai.OpenAITextCompletion(model, api_key, org_id)
|
|
)
|
|
|
|
# note: using skills from the samples folder
|
|
skills_directory = os.path.join(__file__, "../../../../samples/skills")
|
|
skill = kernel.import_semantic_skill_from_directory(skills_directory, "FunSkill")
|
|
|
|
result = asyncio.run(
|
|
kernel.run_async(skill["Joke"], input_str="time travel to dinosaur age")
|
|
)
|
|
print(result)
|