-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Semantic Kernel ITextCompletion As ITextGeneration #183
Conversation
Add a new file SemanticKernelTextGeneration.cs to implement the ITextGeneration interface for Semantic Kernel Text Completion. This class provides the functionality to generate text asynchronously based on a prompt and text generation options. The AIRequestSettings are converted from the TextGenerationOptions to set parameters such as temperature, top-p, presence penalty, frequency penalty, stop sequences, max tokens, results per prompt, and token selection biases. The SemanticKernelTextGeneration class is added to the KernelMemoryBuilderExtensions as an extension method to configure the Semantic Kernel Text Completion service.
could you upgrade the code to work with SK RC2 please? (e.g. rebase to latest main) |
Updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made a few changes, mostly moving the files from Core to Abstractions. There's an error in the new example, easy fix
putting on hold this, until #189 is merged. Some important changes to accommodate third-party/OSS models. |
The new changes have brought some configurable options, and I will adapt the interface as soon as possible. |
#189 merged please note that there are some extra feature in I would be careful not to inject SK interface without including the tokenization logic, because it would go against the intended use. |
- Refactored the Semantic Kernel Text Generation and Embedding Generation classes to improve code organization and readability. - Added a new class, SemanticKernelConfig, to store configuration settings for the Text Generator and Embedding Generator. - Updated the KernelMemoryBuilderExtensions class to include methods for injecting the new Text Generator and Embedding Generator implementations. - The Text Generator and Embedding Generator now use the provided configuration and tokenizer instances. - Renamed the SemanticKernelTextGeneration class to SemanticKernelTextGenerator to better reflect its purpose. - The SemanticKernelTextEmbeddingGenerator class now implements the ITextEmbeddingGenerator interface and uses the provided Text Tokenizer to count tokens. - The GenerateEmbeddingAsync method in the SemanticKernelTextEmbeddingGenerator class now calls the GenerateEmbeddingAsync method in the ITextEmbeddingGeneration instance. - The CountTokens method in the SemanticKernelTextEmbeddingGenerator class now calls the CountTokens method in the provided Text Tokenizer.
- Update SemanticKernelTextEmbeddingGenerator.cs to add a using statement and modify the constructor to handle null arguments. - Update SemanticKernelTextGenerator.cs to add a using statement and modify the constructor to handle null arguments.
@dluc updated, please review again. |
Looks like there are more breaking changes coming from RC4, let's wait until next week to reduce churn |
Motivation and Context (Why the change? What's the scenario?)
This seems somewhat recursive, to use Semantic Kernel as the infrastructure for Kernel Memory. However, the interfaces of both are very similar. So, I added an adapter that can directly use SK's ITextCompletion to maximize the reuse of LLM adapted for SK.
High level description (Approach, Design)