mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 02:19:06 +00:00
### Motivation and Context <!-- 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. --> Closes #12970, #13352 ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> 1. Migrate Google AI connector to use the new Google AI SDK. 2. This PR also marks the VertexAI connector as deprecated in favor of the Google AI connector. With this update, if users wants to connect to a VertexAI project instead of a Google AI endpoint, they can do so with the Google AI connector. 3. This PR also adds the ability for users to provide a custom client to the Google AI connector (#13352). 4. This PR also marks `AzureTextCompletion` deprecated. ### 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 - [ ] I didn't break anyone 😄
34 lines
943 B
Python
34 lines
943 B
Python
# Copyright (c) Microsoft. All rights reserved.
|
|
|
|
import asyncio
|
|
import os
|
|
|
|
from semantic_kernel import Kernel
|
|
from semantic_kernel.connectors.ai.open_ai import OpenAITextCompletion
|
|
from semantic_kernel.functions import KernelArguments
|
|
|
|
|
|
async def main():
|
|
kernel = Kernel()
|
|
|
|
model = "gpt-3.5-turbo-instruct"
|
|
service_id = model
|
|
|
|
# Configure AI service used by the kernel
|
|
kernel.add_service(
|
|
OpenAITextCompletion(service_id=service_id, ai_model_id=model),
|
|
)
|
|
|
|
# note: using plugins from the samples folder
|
|
plugins_directory = os.path.join(__file__, "../../../../../prompt_template_samples/")
|
|
plugin = kernel.add_plugin(parent_directory=plugins_directory, plugin_name="FunPlugin")
|
|
|
|
arguments = KernelArguments(input="time travel to dinosaur age", style="super silly")
|
|
|
|
result = await kernel.invoke(plugin["Joke"], arguments)
|
|
print(result)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|