Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Cellm/Cellm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.5" />
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.5" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="9.0.5" />
<PackageReference Include="Microsoft.SemanticKernel.Connectors.Google" Version="1.56.0-alpha" />
<PackageReference Include="Mistral.SDK" Version="2.2.0" />
<PackageReference Include="ModelContextProtocol" Version="0.1.0-preview.11" />
<PackageReference Include="OllamaSharp" Version="5.2.2" />
Expand Down
45 changes: 12 additions & 33 deletions src/Cellm/Models/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,4 @@
// Circumventing limitations anywhere in the codebase is a direct violation of the
// Fair Core License, Version 1.0 until a commit transitions to the Apache 2.0 Future License.
// Once a commit transitions to the Apache 2.0 Future License, you can checkout out
// that commit and use the code under the Apache 2.0 License. A commit transitions to
// the Apache 2.0 Future License on the second anniversary of the date the git commit
// became available.
//
// The relevant section of the Fair Core License, Version 1.0 is:
//
// > ### Limitations
// > You must not move, change, disable, or circumvent the license key functionality
// > in the Software; or modify any portion of the Software protected by the license
// > key to:
//
// > 1. enable access to the protected functionality without a valid license key; or
//
// > 2. remove the protected functionality.
//
// You can checkout the latest commit licensed under the Apache 2.0 License like this:
//
// $ git checkout $(git rev-list -n 1 --before="2 years ago" HEAD)
//
// For more details, go to https://github.com/getcellm/cellm/blob/main/LICENSE.

using System.ClientModel;
using System.ClientModel;
using System.ClientModel.Primitives;
using System.Net.Http.Headers;
using System.Threading.RateLimiting;
Expand All @@ -49,6 +25,8 @@
using Microsoft.Extensions.AI;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.Google;
using Mistral.SDK;
using OllamaSharp;
using OpenAI;
Expand Down Expand Up @@ -282,15 +260,16 @@ public static IServiceCollection AddGeminiChatClient(this IServiceCollection ser
var geminiConfiguration = serviceProvider.GetRequiredService<IOptionsMonitor<GeminiConfiguration>>();
var resilientHttpClient = serviceProvider.GetKeyedService<HttpClient>("ResilientHttpClient") ?? throw new NullReferenceException("ResilientHttpClient");

var openAiClient = new OpenAIClient(
new ApiKeyCredential(geminiConfiguration.CurrentValue.ApiKey),
new OpenAIClientOptions
{
Transport = new HttpClientPipelineTransport(resilientHttpClient),
Endpoint = geminiConfiguration.CurrentValue.BaseAddress
});
#pragma warning disable SKEXP0070 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
var geminiClient = new GoogleAIGeminiChatCompletionService(
geminiConfiguration.CurrentValue.DefaultModel,
geminiConfiguration.CurrentValue.ApiKey,
httpClient: resilientHttpClient);
#pragma warning restore SKEXP0070 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.

return openAiClient.GetChatClient(geminiConfiguration.CurrentValue.DefaultModel).AsIChatClient();
#pragma warning disable SKEXP0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
return geminiClient.AsChatClient();
#pragma warning restore SKEXP0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
}, ServiceLifetime.Transient)
.UseFunctionInvocation();

Expand Down
48 changes: 48 additions & 0 deletions src/Cellm/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,16 @@
"Microsoft.Extensions.Primitives": "9.0.5"
}
},
"Microsoft.SemanticKernel.Connectors.Google": {
"type": "Direct",
"requested": "[1.56.0-alpha, )",
"resolved": "1.56.0-alpha",
"contentHash": "tbQcwGzb5vjwzlGvqKRytZCvc9MywavNk7OopVm5ApY9+iJ9tOzqaNSNTQ1I9BvEM6lQw/xJon3h3IaWOpiRgA==",
"dependencies": {
"Microsoft.SemanticKernel.Abstractions": "1.56.0",
"Microsoft.SemanticKernel.Core": "1.56.0"
}
},
"Mistral.SDK": {
"type": "Direct",
"requested": "[2.2.0, )",
Expand Down Expand Up @@ -378,6 +388,11 @@
"resolved": "8.0.0",
"contentHash": "3WA9q9yVqJp222P3x1wYIGDAkpjAku0TMUaaQV22g6L67AI0LdOIrVS7Ht2vJfLHGSPVuqN94vIr15qn+HEkHw=="
},
"Microsoft.Bcl.HashCode": {
"type": "Transitive",
"resolved": "1.1.1",
"contentHash": "MalY0Y/uM/LjXtHfX/26l2VtN4LDNZ2OE3aumNOHDLsT4fNYy2hiHXI4CXCqKpNUNm7iJ2brrc4J89UdaL56FA=="
},
"Microsoft.Diagnostics.NETCore.Client": {
"type": "Transitive",
"resolved": "0.2.510501",
Expand Down Expand Up @@ -596,11 +611,39 @@
"Microsoft.Extensions.Options": "9.0.5"
}
},
"Microsoft.Extensions.VectorData.Abstractions": {
"type": "Transitive",
"resolved": "9.5.0",
"contentHash": "+hvBYS60Tp9ELEpBVOEa1qBaWgJiEzI9cZdlKf00zJULgI6oPYN/xYps4SaFvyf3O8C+WsDC3Ilsfc147nwVuQ==",
"dependencies": {
"Microsoft.Extensions.AI.Abstractions": "9.5.0"
}
},
"Microsoft.NETCore.Platforms": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "VyPlqzH2wavqquTcYpkIIAQ6WdenuKoFN0BdYBbCWsclXacSOHNQn66Gt4z5NBqEYW0FAPm5rlvki9ZiCij5xQ=="
},
"Microsoft.SemanticKernel.Abstractions": {
"type": "Transitive",
"resolved": "1.56.0",
"contentHash": "2KYiqrHLLZiQQ6xK0nXxGSZ9TItXsET08S9Y8NVdeguvJjuTt2wpqXIryccGURwTmvv3dhL3pipgCyapzjDXtA==",
"dependencies": {
"Microsoft.Bcl.HashCode": "1.1.1",
"Microsoft.Extensions.AI": "9.5.0",
"Microsoft.Extensions.VectorData.Abstractions": "9.5.0"
}
},
"Microsoft.SemanticKernel.Core": {
"type": "Transitive",
"resolved": "1.56.0",
"contentHash": "r+vmdSgL7xnpKTemVcktZMKglosYrr9tLe8MJK1/xik1yMO0XGl/wsz4cLeAzLAXRwLN+LTx9QZ0HPOcJ+d2qw==",
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "8.0.1",
"Microsoft.SemanticKernel.Abstractions": "1.56.0",
"System.Numerics.Tensors": "9.0.0"
}
},
"Microsoft.Win32.SystemEvents": {
"type": "Transitive",
"resolved": "5.0.0",
Expand Down Expand Up @@ -684,6 +727,11 @@
"resolved": "10.0.0-preview.2.25163.2",
"contentHash": "XHyvtQSgco0Sv0kz9yNBv93k3QOoAVzIVd5XbQoTqjV9sqkzWHsToNknyxtNjcXQwb+O9TfzSlNobsBWwnKD3Q=="
},
"System.Numerics.Tensors": {
"type": "Transitive",
"resolved": "9.0.0",
"contentHash": "hyJB4UlpAi19Xr9AXzu2NuagKC4lPfHObNMEAA0HmqFz2rX7wKgzeYzO/jM/eBHDhnUGFFEjk5cOoJaxqg5J4A=="
},
"System.Numerics.Vectors": {
"type": "Transitive",
"resolved": "4.5.0",
Expand Down
Loading