-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
.Net: Update Ollama Client in Ollama Connector to use OllamaSharp #6194
Open
feiyun0112
wants to merge
30
commits into
microsoft:feature-connectors-ollama
Choose a base branch
from
feiyun0112:feature-connectors-ollama
base: feature-connectors-ollama
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
.Net: Update Ollama Client in Ollama Connector to use OllamaSharp #6194
feiyun0112
wants to merge
30
commits into
microsoft:feature-connectors-ollama
from
feiyun0112:feature-connectors-ollama
+1,158
−1
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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. --> ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ ] The code builds clean without any errors or warnings - [ ] 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 - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄
### Motivation and Context This PR adds Ollama text embedding support ### Description Referenced existing implementation of OllamaTextGeneration service and OpenAITextEmbeddingGenerationService for implementation. I have also added a sample (Example82_OllamaTextEmbeddingGenerationService), Tested locally against ollama llama2:7b - Examples may need to be re-numbered as 80, 81, 82 already exist in master - I wasn't able to run all tests as I don't have OpenAI access ![image](https://github.com/microsoft/semantic-kernel/assets/33104478/0aba99fc-9a76-4387-87c7-d1b2ffe9cce2) ### Contribution Checklist - [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 - [ ] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 --------- Co-authored-by: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
### Motivation and Context Restructured the Ollama connector core following the suggestions in the latest ADR ### Description Followed the HuggingFace connector on the main branch as a reference. ### 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 - [ ] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 --------- Co-authored-by: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
This PR adds a total of 35 unit tests for the Ollama connector. The tests are created with the HuggingFace unit tests as a reference > GitHub Actions (CI) changes may be required to run the new test project in the pipeline I also saw some redundancies in the HuggingFaceTextGeneration unit tests, for example, in the code below, `var contents = await sut.GetTextContentsAsync("fake-test");` is redundant, and I found this redundancy in another test (`GetStreamingTextContentsShouldHaveModelIdDefinedAsync()`) in the same file ```csharp [Fact] public async Task GetTextContentsShouldHaveModelIdDefinedAsync() { //Arrange var sut = new HuggingFaceTextGenerationService("fake-model", endpoint: new Uri("https://fake-random-test-host/fake-path"), httpClient: this._httpClient); //Act var contents = await sut.GetTextContentsAsync("fake-test"); this._messageHandlerStub.ResponseToReturn = new HttpResponseMessage(System.Net.HttpStatusCode.OK) { Content = new StringContent(@" [ { ""generated_text"": ""Why the sky is blue? | Dept. of Science & Mathematics Education | University of Notre Dame\nWhen I was in high school I had a pretty simple conception of reality. I believed that if something made sense to me, then it must also be true. I believed that some problems were so fundamental that I couldn’t understand"" } ]", Encoding.UTF8, "application/json") }; // Act var textContent = await sut.GetTextContentAsync("Any prompt"); // Assert Assert.NotNull(textContent.ModelId); Assert.Equal("fake-model", textContent.ModelId); } Also fixed one project restructuring issue which was missed in the previous PR, KernelBuilder and ServiceCollection extensions are moved to the root of the Ollama connector project ``` <!-- 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 - [ ] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 --------- Co-authored-by: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
### Motivation and Context Fixes the following build errors ![image](https://github.com/microsoft/semantic-kernel/assets/33104478/a5bc8115-3b86-460d-8010-427b39f4013b) ### 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 - [ ] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
markwallace-microsoft
added
the
kernel
Issues or pull requests impacting the core kernel
label
May 11, 2024
@feiyun0112 Thanks for the contribution, this issue is currently under analysis. |
RogerBarreto
added
the
needs discussion
Issues that require discussion by the internal Semantic Kernel team before proceeding
label
May 12, 2024
dotnet/src/Connectors/Connectors.Ollama/Services/OllamaChatCompletionService.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Connectors/Connectors.Ollama/Services/OllamaTextGenerationService.cs
Outdated
Show resolved
Hide resolved
…pletionService.cs Co-authored-by: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
…erationService.cs Co-authored-by: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
kernel
Issues or pull requests impacting the core kernel
needs discussion
Issues that require discussion by the internal Semantic Kernel team before proceeding
.NET
Issue or Pull requests regarding .NET code
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix #5993