From c312d235aaddd925ee3030b5278f900a14ac58a6 Mon Sep 17 00:00:00 2001 From: Shawn Callegari <36091529+shawncal@users.noreply.github.com> Date: Mon, 15 May 2023 10:53:08 -0700 Subject: [PATCH] Introducing Connectors.AI.HuggingFace Package (#889) ### Description In an effort to slim down SemanticKernel.Core and standardize around the Connectors.AI packaging pattern, we're moving the Connectors.HuggingFace calls into their own Connectors.AI.HuggingFace nuget package, which will be an optional reference. This is a code move and repackaging only -- no new functionality. Co-authored-by: Dmytro Struk <13853051+dmytrostruk@users.noreply.github.com> --- dotnet/SK-dotnet.sln | 6 +++++ .../Connectors.AI.HuggingFace.csproj | 24 +++++++++++++++++++ .../HuggingFaceTextCompletion.cs | 2 +- .../TextCompletion/TextCompletionRequest.cs | 2 +- .../TextCompletion/TextCompletionResponse.cs | 2 +- .../HuggingFaceTextEmbeddingGeneration.cs | 2 +- .../TextEmbedding/TextEmbeddingRequest.cs | 2 +- .../TextEmbedding/TextEmbeddingResponse.cs | 2 +- .../Connectors.UnitTests.csproj | 1 + .../HuggingFaceTextCompletionTests.cs | 2 +- .../HuggingFaceEmbeddingGenerationTests.cs | 2 +- .../HuggingFaceTextCompletionTests.cs | 2 +- .../IntegrationTests/IntegrationTests.csproj | 1 + .../Example20_HuggingFace.cs | 2 +- .../KernelSyntaxExamples.csproj | 1 + 15 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 dotnet/src/Connectors/Connectors.AI.HuggingFace/Connectors.AI.HuggingFace.csproj rename dotnet/src/{SemanticKernel/Connectors/HuggingFace => Connectors/Connectors.AI.HuggingFace}/TextCompletion/HuggingFaceTextCompletion.cs (98%) rename dotnet/src/{SemanticKernel/Connectors/HuggingFace => Connectors/Connectors.AI.HuggingFace}/TextCompletion/TextCompletionRequest.cs (83%) rename dotnet/src/{SemanticKernel/Connectors/HuggingFace => Connectors/Connectors.AI.HuggingFace}/TextCompletion/TextCompletionResponse.cs (81%) rename dotnet/src/{SemanticKernel/Connectors/HuggingFace => Connectors/Connectors.AI.HuggingFace}/TextEmbedding/HuggingFaceTextEmbeddingGeneration.cs (98%) rename dotnet/src/{SemanticKernel/Connectors/HuggingFace => Connectors/Connectors.AI.HuggingFace}/TextEmbedding/TextEmbeddingRequest.cs (85%) rename dotnet/src/{SemanticKernel/Connectors/HuggingFace => Connectors/Connectors.AI.HuggingFace}/TextEmbedding/TextEmbeddingResponse.cs (89%) diff --git a/dotnet/SK-dotnet.sln b/dotnet/SK-dotnet.sln index cc2785dd923b..82ebb75dfa2c 100644 --- a/dotnet/SK-dotnet.sln +++ b/dotnet/SK-dotnet.sln @@ -87,6 +87,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Connectors.Memory.AzureCogn EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Skills.Grpc", "src\Skills\Skills.Grpc\Skills.Grpc.csproj", "{E52F805C-794A-4CA9-B684-DFF358B18820}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Connectors.AI.HuggingFace", "src\Connectors\Connectors.AI.HuggingFace\Connectors.AI.HuggingFace.csproj", "{136823BE-8665-4D57-87E0-EF41535539E2}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "InternalUtilities", "InternalUtilities", "{4D3DAE63-41C6-4E1C-A35A-E77BDFC40675}" ProjectSection(SolutionItems) = preProject src\InternalUtilities\InternalUtilities.props = src\InternalUtilities\InternalUtilities.props @@ -214,6 +215,10 @@ Global {E52F805C-794A-4CA9-B684-DFF358B18820}.Debug|Any CPU.Build.0 = Debug|Any CPU {E52F805C-794A-4CA9-B684-DFF358B18820}.Release|Any CPU.ActiveCfg = Release|Any CPU {E52F805C-794A-4CA9-B684-DFF358B18820}.Release|Any CPU.Build.0 = Release|Any CPU + {136823BE-8665-4D57-87E0-EF41535539E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {136823BE-8665-4D57-87E0-EF41535539E2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {136823BE-8665-4D57-87E0-EF41535539E2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {136823BE-8665-4D57-87E0-EF41535539E2}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -251,6 +256,7 @@ Global {A350933D-F9D5-4AD3-8C4F-B856B5020297} = {078F96B4-09E1-4E0E-B214-F71A4F4BF633} {EC3BB6D1-2FB2-4702-84C6-F791DE533ED4} = {0247C2C9-86C3-45BA-8873-28B0948EDC0C} {E52F805C-794A-4CA9-B684-DFF358B18820} = {9ECD1AA0-75B3-4E25-B0B5-9F0945B64974} + {136823BE-8665-4D57-87E0-EF41535539E2} = {0247C2C9-86C3-45BA-8873-28B0948EDC0C} {E4B777A1-28E1-41BE-96AE-7F3EC61FD5D4} = {831DDCA2-7D2C-4C31-80DB-6BDB3E1F7AE0} {4D3DAE63-41C6-4E1C-A35A-E77BDFC40675} = {831DDCA2-7D2C-4C31-80DB-6BDB3E1F7AE0} EndGlobalSection diff --git a/dotnet/src/Connectors/Connectors.AI.HuggingFace/Connectors.AI.HuggingFace.csproj b/dotnet/src/Connectors/Connectors.AI.HuggingFace/Connectors.AI.HuggingFace.csproj new file mode 100644 index 000000000000..63737225a1c3 --- /dev/null +++ b/dotnet/src/Connectors/Connectors.AI.HuggingFace/Connectors.AI.HuggingFace.csproj @@ -0,0 +1,24 @@ + + + + + Microsoft.SemanticKernel.Connectors.AI.HuggingFace + $(AssemblyName) + netstandard2.0 + + + + + + + + + Semantic Kernel - Hugging Face AI connectors + Semantic Kernel connectors for Hugging Face. Contains clients for text completion and text embedding generation. + + + + + + + diff --git a/dotnet/src/SemanticKernel/Connectors/HuggingFace/TextCompletion/HuggingFaceTextCompletion.cs b/dotnet/src/Connectors/Connectors.AI.HuggingFace/TextCompletion/HuggingFaceTextCompletion.cs similarity index 98% rename from dotnet/src/SemanticKernel/Connectors/HuggingFace/TextCompletion/HuggingFaceTextCompletion.cs rename to dotnet/src/Connectors/Connectors.AI.HuggingFace/TextCompletion/HuggingFaceTextCompletion.cs index e09fa498cc18..82cce1dae266 100644 --- a/dotnet/src/SemanticKernel/Connectors/HuggingFace/TextCompletion/HuggingFaceTextCompletion.cs +++ b/dotnet/src/Connectors/Connectors.AI.HuggingFace/TextCompletion/HuggingFaceTextCompletion.cs @@ -11,7 +11,7 @@ using Microsoft.SemanticKernel.AI.TextCompletion; using Microsoft.SemanticKernel.Diagnostics; -namespace Microsoft.SemanticKernel.Connectors.HuggingFace.TextCompletion; +namespace Microsoft.SemanticKernel.Connectors.AI.HuggingFace.TextCompletion; /// /// HuggingFace text completion service. diff --git a/dotnet/src/SemanticKernel/Connectors/HuggingFace/TextCompletion/TextCompletionRequest.cs b/dotnet/src/Connectors/Connectors.AI.HuggingFace/TextCompletion/TextCompletionRequest.cs similarity index 83% rename from dotnet/src/SemanticKernel/Connectors/HuggingFace/TextCompletion/TextCompletionRequest.cs rename to dotnet/src/Connectors/Connectors.AI.HuggingFace/TextCompletion/TextCompletionRequest.cs index b2a656744266..a57ca56bb037 100644 --- a/dotnet/src/SemanticKernel/Connectors/HuggingFace/TextCompletion/TextCompletionRequest.cs +++ b/dotnet/src/Connectors/Connectors.AI.HuggingFace/TextCompletion/TextCompletionRequest.cs @@ -3,7 +3,7 @@ using System; using System.Text.Json.Serialization; -namespace Microsoft.SemanticKernel.Connectors.HuggingFace.TextCompletion; +namespace Microsoft.SemanticKernel.Connectors.AI.HuggingFace.TextCompletion; /// /// HTTP schema to perform completion request. diff --git a/dotnet/src/SemanticKernel/Connectors/HuggingFace/TextCompletion/TextCompletionResponse.cs b/dotnet/src/Connectors/Connectors.AI.HuggingFace/TextCompletion/TextCompletionResponse.cs similarity index 81% rename from dotnet/src/SemanticKernel/Connectors/HuggingFace/TextCompletion/TextCompletionResponse.cs rename to dotnet/src/Connectors/Connectors.AI.HuggingFace/TextCompletion/TextCompletionResponse.cs index 2678ec93808e..91f922f6cb16 100644 --- a/dotnet/src/SemanticKernel/Connectors/HuggingFace/TextCompletion/TextCompletionResponse.cs +++ b/dotnet/src/Connectors/Connectors.AI.HuggingFace/TextCompletion/TextCompletionResponse.cs @@ -2,7 +2,7 @@ using System.Text.Json.Serialization; -namespace Microsoft.SemanticKernel.Connectors.HuggingFace.TextCompletion; +namespace Microsoft.SemanticKernel.Connectors.AI.HuggingFace.TextCompletion; /// /// HTTP Schema for completion response. diff --git a/dotnet/src/SemanticKernel/Connectors/HuggingFace/TextEmbedding/HuggingFaceTextEmbeddingGeneration.cs b/dotnet/src/Connectors/Connectors.AI.HuggingFace/TextEmbedding/HuggingFaceTextEmbeddingGeneration.cs similarity index 98% rename from dotnet/src/SemanticKernel/Connectors/HuggingFace/TextEmbedding/HuggingFaceTextEmbeddingGeneration.cs rename to dotnet/src/Connectors/Connectors.AI.HuggingFace/TextEmbedding/HuggingFaceTextEmbeddingGeneration.cs index 29bceced7d53..a55d80793fcd 100644 --- a/dotnet/src/SemanticKernel/Connectors/HuggingFace/TextEmbedding/HuggingFaceTextEmbeddingGeneration.cs +++ b/dotnet/src/Connectors/Connectors.AI.HuggingFace/TextEmbedding/HuggingFaceTextEmbeddingGeneration.cs @@ -11,7 +11,7 @@ using Microsoft.SemanticKernel.AI.Embeddings; using Microsoft.SemanticKernel.Diagnostics; -namespace Microsoft.SemanticKernel.Connectors.HuggingFace.TextEmbedding; +namespace Microsoft.SemanticKernel.Connectors.AI.HuggingFace.TextEmbedding; /// /// HuggingFace embedding generation service. diff --git a/dotnet/src/SemanticKernel/Connectors/HuggingFace/TextEmbedding/TextEmbeddingRequest.cs b/dotnet/src/Connectors/Connectors.AI.HuggingFace/TextEmbedding/TextEmbeddingRequest.cs similarity index 85% rename from dotnet/src/SemanticKernel/Connectors/HuggingFace/TextEmbedding/TextEmbeddingRequest.cs rename to dotnet/src/Connectors/Connectors.AI.HuggingFace/TextEmbedding/TextEmbeddingRequest.cs index 2b8cd227e179..ca33f268ed61 100644 --- a/dotnet/src/SemanticKernel/Connectors/HuggingFace/TextEmbedding/TextEmbeddingRequest.cs +++ b/dotnet/src/Connectors/Connectors.AI.HuggingFace/TextEmbedding/TextEmbeddingRequest.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Text.Json.Serialization; -namespace Microsoft.SemanticKernel.Connectors.HuggingFace.TextEmbedding; +namespace Microsoft.SemanticKernel.Connectors.AI.HuggingFace.TextEmbedding; /// /// HTTP schema to perform embedding request. diff --git a/dotnet/src/SemanticKernel/Connectors/HuggingFace/TextEmbedding/TextEmbeddingResponse.cs b/dotnet/src/Connectors/Connectors.AI.HuggingFace/TextEmbedding/TextEmbeddingResponse.cs similarity index 89% rename from dotnet/src/SemanticKernel/Connectors/HuggingFace/TextEmbedding/TextEmbeddingResponse.cs rename to dotnet/src/Connectors/Connectors.AI.HuggingFace/TextEmbedding/TextEmbeddingResponse.cs index ee25f69ad9b4..781959e59522 100644 --- a/dotnet/src/SemanticKernel/Connectors/HuggingFace/TextEmbedding/TextEmbeddingResponse.cs +++ b/dotnet/src/Connectors/Connectors.AI.HuggingFace/TextEmbedding/TextEmbeddingResponse.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Text.Json.Serialization; -namespace Microsoft.SemanticKernel.Connectors.HuggingFace.TextEmbedding; +namespace Microsoft.SemanticKernel.Connectors.AI.HuggingFace.TextEmbedding; /// /// HTTP Schema for embedding response. diff --git a/dotnet/src/Connectors/Connectors.UnitTests/Connectors.UnitTests.csproj b/dotnet/src/Connectors/Connectors.UnitTests/Connectors.UnitTests.csproj index daa33434c67e..013fd5820f96 100644 --- a/dotnet/src/Connectors/Connectors.UnitTests/Connectors.UnitTests.csproj +++ b/dotnet/src/Connectors/Connectors.UnitTests/Connectors.UnitTests.csproj @@ -22,6 +22,7 @@ + diff --git a/dotnet/src/Connectors/Connectors.UnitTests/HuggingFace/TextCompletion/HuggingFaceTextCompletionTests.cs b/dotnet/src/Connectors/Connectors.UnitTests/HuggingFace/TextCompletion/HuggingFaceTextCompletionTests.cs index a3cb59e963f4..7e4c1d217adc 100644 --- a/dotnet/src/Connectors/Connectors.UnitTests/HuggingFace/TextCompletion/HuggingFaceTextCompletionTests.cs +++ b/dotnet/src/Connectors/Connectors.UnitTests/HuggingFace/TextCompletion/HuggingFaceTextCompletionTests.cs @@ -6,7 +6,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.SemanticKernel.AI.TextCompletion; -using Microsoft.SemanticKernel.Connectors.HuggingFace.TextCompletion; +using Microsoft.SemanticKernel.Connectors.AI.HuggingFace.TextCompletion; using Xunit; namespace SemanticKernel.Connectors.UnitTests.HuggingFace.TextCompletion; diff --git a/dotnet/src/Connectors/Connectors.UnitTests/HuggingFace/TextEmbedding/HuggingFaceEmbeddingGenerationTests.cs b/dotnet/src/Connectors/Connectors.UnitTests/HuggingFace/TextEmbedding/HuggingFaceEmbeddingGenerationTests.cs index 57fb6c1394a9..c93da5309973 100644 --- a/dotnet/src/Connectors/Connectors.UnitTests/HuggingFace/TextEmbedding/HuggingFaceEmbeddingGenerationTests.cs +++ b/dotnet/src/Connectors/Connectors.UnitTests/HuggingFace/TextEmbedding/HuggingFaceEmbeddingGenerationTests.cs @@ -6,7 +6,7 @@ using System.Net; using System.Net.Http; using System.Threading.Tasks; -using Microsoft.SemanticKernel.Connectors.HuggingFace.TextEmbedding; +using Microsoft.SemanticKernel.Connectors.AI.HuggingFace.TextEmbedding; using Xunit; namespace SemanticKernel.Connectors.UnitTests.HuggingFace.TextEmbedding; diff --git a/dotnet/src/IntegrationTests/Connectors/HuggingFace/TextCompletion/HuggingFaceTextCompletionTests.cs b/dotnet/src/IntegrationTests/Connectors/HuggingFace/TextCompletion/HuggingFaceTextCompletionTests.cs index edb708ef0aa0..0ede61ab25ec 100644 --- a/dotnet/src/IntegrationTests/Connectors/HuggingFace/TextCompletion/HuggingFaceTextCompletionTests.cs +++ b/dotnet/src/IntegrationTests/Connectors/HuggingFace/TextCompletion/HuggingFaceTextCompletionTests.cs @@ -4,7 +4,7 @@ using System.Threading.Tasks; using Microsoft.Extensions.Configuration; using Microsoft.SemanticKernel.AI.TextCompletion; -using Microsoft.SemanticKernel.Connectors.HuggingFace.TextCompletion; +using Microsoft.SemanticKernel.Connectors.AI.HuggingFace.TextCompletion; using Xunit; namespace SemanticKernel.IntegrationTests.Connectors.HuggingFace.TextCompletion; diff --git a/dotnet/src/IntegrationTests/IntegrationTests.csproj b/dotnet/src/IntegrationTests/IntegrationTests.csproj index 246f4b26cf5f..50d89e170081 100644 --- a/dotnet/src/IntegrationTests/IntegrationTests.csproj +++ b/dotnet/src/IntegrationTests/IntegrationTests.csproj @@ -29,6 +29,7 @@ + diff --git a/samples/dotnet/kernel-syntax-examples/Example20_HuggingFace.cs b/samples/dotnet/kernel-syntax-examples/Example20_HuggingFace.cs index 06806a011d24..6b4156322e35 100644 --- a/samples/dotnet/kernel-syntax-examples/Example20_HuggingFace.cs +++ b/samples/dotnet/kernel-syntax-examples/Example20_HuggingFace.cs @@ -3,7 +3,7 @@ using System; using System.Threading.Tasks; using Microsoft.SemanticKernel; -using Microsoft.SemanticKernel.Connectors.HuggingFace.TextCompletion; +using Microsoft.SemanticKernel.Connectors.AI.HuggingFace.TextCompletion; using RepoUtils; /** diff --git a/samples/dotnet/kernel-syntax-examples/KernelSyntaxExamples.csproj b/samples/dotnet/kernel-syntax-examples/KernelSyntaxExamples.csproj index 03c3d13ab24e..4f03e8feb86d 100644 --- a/samples/dotnet/kernel-syntax-examples/KernelSyntaxExamples.csproj +++ b/samples/dotnet/kernel-syntax-examples/KernelSyntaxExamples.csproj @@ -26,6 +26,7 @@ +