Skip to content

Commit

Permalink
feat: Replace GoogleAI provider with Google's OpenAI compatible endpo…
Browse files Browse the repository at this point in the history
…int (#63)
  • Loading branch information
kaspermarstal authored Nov 21, 2024
1 parent e9df85d commit 1e7a4f0
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 201 deletions.
2 changes: 0 additions & 2 deletions src/Cellm/Models/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Cellm.AddIn;
using Cellm.AddIn.Exceptions;
using Cellm.Models.Anthropic;
using Cellm.Models.GoogleAi;
using Cellm.Models.Llamafile;
using Cellm.Models.OpenAi;
using Cellm.Prompts;
Expand Down Expand Up @@ -37,7 +36,6 @@ public async Task<Prompt> Send(Prompt prompt, string? provider, Uri? baseAddress
IModelResponse response = parsedProvider switch
{
Providers.Anthropic => await _sender.Send(new AnthropicRequest(prompt, provider, baseAddress)),
Providers.GoogleAi => await _sender.Send(new GoogleAiRequest(prompt, provider, baseAddress)),
Providers.Llamafile => await _sender.Send(new LlamafileRequest(prompt)),
Providers.OpenAi => await _sender.Send(new OpenAiRequest(prompt, provider, baseAddress)),
_ => throw new InvalidOperationException($"Provider {parsedProvider} is defined but not implemented")
Expand Down
19 changes: 0 additions & 19 deletions src/Cellm/Models/GoogleAi/GoogleAiConfiguration.cs

This file was deleted.

5 changes: 0 additions & 5 deletions src/Cellm/Models/GoogleAi/GoogleAiRequest.cs

This file was deleted.

92 changes: 0 additions & 92 deletions src/Cellm/Models/GoogleAi/GoogleAiRequestHandler.cs

This file was deleted.

5 changes: 0 additions & 5 deletions src/Cellm/Models/GoogleAi/GoogleAiResponse.cs

This file was deleted.

57 changes: 0 additions & 57 deletions src/Cellm/Models/GoogleAi/Models.cs

This file was deleted.

1 change: 0 additions & 1 deletion src/Cellm/Models/Providers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
public enum Providers
{
Anthropic,
GoogleAi,
Llamafile,
OpenAi
}
11 changes: 0 additions & 11 deletions src/Cellm/Services/ServiceLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Cellm.AddIn.Exceptions;
using Cellm.Models;
using Cellm.Models.Anthropic;
using Cellm.Models.GoogleAi;
using Cellm.Models.Llamafile;
using Cellm.Models.OpenAi;
using Cellm.Models.PipelineBehavior;
Expand Down Expand Up @@ -47,7 +46,6 @@ private static IServiceCollection ConfigureServices(IServiceCollection services)
services
.Configure<CellmConfiguration>(configuration.GetRequiredSection(nameof(CellmConfiguration)))
.Configure<AnthropicConfiguration>(configuration.GetRequiredSection(nameof(AnthropicConfiguration)))
.Configure<GoogleAiConfiguration>(configuration.GetRequiredSection(nameof(GoogleAiConfiguration)))
.Configure<OpenAiConfiguration>(configuration.GetRequiredSection(nameof(OpenAiConfiguration)))
.Configure<LlamafileConfiguration>(configuration.GetRequiredSection(nameof(LlamafileConfiguration)))
.Configure<RateLimiterConfiguration>(configuration.GetRequiredSection(nameof(RateLimiterConfiguration)))
Expand Down Expand Up @@ -125,15 +123,6 @@ private static IServiceCollection ConfigureServices(IServiceCollection services)
anthropicHttpClient.Timeout = TimeSpan.FromHours(1);
}).AddResilienceHandler($"{nameof(AnthropicRequestHandler)}ResiliencePipeline", resiliencePipelineConfigurator.ConfigureResiliencePipeline);

var googleAiConfiguration = configuration.GetRequiredSection(nameof(GoogleAiConfiguration)).Get<GoogleAiConfiguration>()
?? throw new NullReferenceException(nameof(GoogleAiConfiguration));

services.AddHttpClient<IRequestHandler<GoogleAiRequest, GoogleAiResponse>, GoogleAiRequestHandler>(googleHttpClient =>
{
googleHttpClient.BaseAddress = googleAiConfiguration.BaseAddress;
googleHttpClient.Timeout = TimeSpan.FromHours(1);
}).AddResilienceHandler($"{nameof(GoogleAiRequestHandler)}ResiliencePipeline", resiliencePipelineConfigurator.ConfigureResiliencePipeline);

var openAiConfiguration = configuration.GetRequiredSection(nameof(OpenAiConfiguration)).Get<OpenAiConfiguration>()
?? throw new NullReferenceException(nameof(OpenAiConfiguration));

Expand Down
12 changes: 12 additions & 0 deletions src/Cellm/appsettings.Local.Google.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"OpenAiConfiguration": {
"BaseAddress": "https://generativelanguage.googleapis.com/v1beta/openai/",
"DefaultModel": "gemini-1.5-flash",
"ApiKey": "YOUR_GEMINI_API_KEY"

},
"CellmConfiguration": {
"DefaultProvider": "OpenAi",
"HttpTimeoutInSeconds": 30
}
}
9 changes: 0 additions & 9 deletions src/Cellm/appsettings.Local.GoogleAi.json

This file was deleted.

0 comments on commit 1e7a4f0

Please sign in to comment.