mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 11:19:56 +00:00
### Motivation and Context Delete all *_async where *_sync doesn't exist to make the library more Pythonic. Fixes #4629 ### 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 😄 --------- Co-authored-by: Evan Mattson <[email protected]>
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
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 = True
|
|
model = "gpt-35-turbo-instruct" if useAzureOpenAI else "gpt-3.5-turbo-instruct"
|
|
service_id = model
|
|
|
|
# Configure AI service used by the kernel
|
|
if useAzureOpenAI:
|
|
deployment_name, api_key, endpoint = sk.azure_openai_settings_from_dot_env()
|
|
kernel.add_text_completion_service(
|
|
service_id,
|
|
sk_oai.AzureTextCompletion(deployment_name=model, api_key=api_key, endpoint=endpoint),
|
|
)
|
|
else:
|
|
api_key, org_id = sk.openai_settings_from_dot_env()
|
|
kernel.add_text_completion_service(
|
|
service_id,
|
|
sk_oai.OpenAITextCompletion(deployment_name=model, api_key=api_key, org_id=org_id),
|
|
)
|
|
|
|
# note: using plugins from the samples folder
|
|
plugins_directory = os.path.join(__file__, "../../../../samples/plugins")
|
|
plugin = kernel.import_semantic_plugin_from_directory(plugins_directory, "FunPlugin")
|
|
|
|
result = asyncio.run(kernel.run(plugin["Joke"], input_str="time travel to dinosaur age"))
|
|
print(result)
|