diff --git a/.azure/container-group.yml b/.azure/container-group.yml index 5d7f760..c06178b 100644 --- a/.azure/container-group.yml +++ b/.azure/container-group.yml @@ -33,17 +33,7 @@ properties: secureValue: ${RELEASE_HISTORY_TOKEN} - name: APPLICATIONINSIGHTS_CONNECTION_STRING value: ${APPINSIGHTS_CONN_STR} - - name: ConnectionStrings__bottomlymodel - secureValue: "Endpoint=http://localhost:11434;Key=${OLLAMA_API_KEY}" - - name: ollama - properties: - image: ollama/ollama:latest - resources: - requests: - cpu: 0.5 - memoryInGB: 0.5 - environmentVariables: - - name: OLLAMA_API_KEY + - name: bottomly_ollama_api_key secureValue: ${OLLAMA_API_KEY} imageRegistryCredentials: - server: ghcr.io diff --git a/Bottomly.AppHost/AppHost.cs b/Bottomly.AppHost/AppHost.cs index 1e74f12..f567516 100644 --- a/Bottomly.AppHost/AppHost.cs +++ b/Bottomly.AppHost/AppHost.cs @@ -11,19 +11,8 @@ var mongodb = mongo.AddDatabase("mongodb", "bottomly"); -// var ollama = builder.AddOllama("ollama") -// .WithEnvironment("OLLAMA_API_KEY", builder.Configuration["AppHost:OllamaApiKey"]) -// .WithDataVolume() -// .WithLifetime(ContainerLifetime.Persistent); - -var ollama = builder.AddOllamaLocal("ollama"); - -var bottomlyModel = ollama.AddModel("bottomlymodel", "qwen3.5:cloud"); - var bottomly = builder.AddProject("bottomly") .WaitFor(mongodb) - .WaitFor(ollama) - .WithReference(bottomlyModel) .WithReference(mongodb) ; diff --git a/Bottomly.AppHost/Bottomly.AppHost.csproj b/Bottomly.AppHost/Bottomly.AppHost.csproj index ec78659..3a05c1f 100644 --- a/Bottomly.AppHost/Bottomly.AppHost.csproj +++ b/Bottomly.AppHost/Bottomly.AppHost.csproj @@ -16,8 +16,6 @@ - - diff --git a/Bottomly/Configuration/BottomlyOptions.cs b/Bottomly/Configuration/BottomlyOptions.cs index 4067894..0c81547 100644 --- a/Bottomly/Configuration/BottomlyOptions.cs +++ b/Bottomly/Configuration/BottomlyOptions.cs @@ -10,8 +10,7 @@ public class BottomlyOptions public string GiphyApiKey { get; set; } = string.Empty; public string Environment { get; set; } = "live"; public string GitHubToken { get; set; } = string.Empty; - public bool EnableLlm { get; set; } = false; - public bool IsDebug => Environment != "live"; public string BraveApiKey { get; set; } = string.Empty; + public string OllamaApiKey { get; set; } = string.Empty; } \ No newline at end of file diff --git a/Bottomly/Program.cs b/Bottomly/Program.cs index b55d7c0..f016622 100644 --- a/Bottomly/Program.cs +++ b/Bottomly/Program.cs @@ -7,7 +7,6 @@ using Bottomly.Slack; using Bottomly.Slack.MembershipEventHandlers; using Bottomly.Slack.MessageEventHandlers; -using Bottomly.Slack.MessageEventHandlers.ConversationMessageHandling; using Bottomly.Slack.ReactionHandlers; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Configuration; @@ -47,7 +46,7 @@ opts.Environment = builder.Configuration["bottomly_env"] ?? "live"; opts.GitHubToken = builder.Configuration["bottomly_github_token"] ?? string.Empty; opts.BraveApiKey = builder.Configuration["bottomly_brave_api_key"] ?? string.Empty; - opts.EnableLlm = builder.Configuration.GetValue("EnableLlm"); + opts.OllamaApiKey = builder.Configuration["bottomly_ollama_api_key"] ?? string.Empty; }); var opts = builder.Services.BuildServiceProvider().GetRequiredService>(); @@ -104,13 +103,18 @@ builder.Services.AddHostedService(sp => sp.GetRequiredService()); // LLM Support -builder.AddOllamaApiClient("bottomlymodel") +builder.AddOllamaApiClient("bottomlymodel", x => + { + x.Endpoint = new Uri("https://ollama.com"); + x.SelectedModel = "qwen3.5:cloud"; + }) .AddChatClient(); // The built-in resilience settings are super aggressive, with a 10s timeout. // Running locally Qwen3 takes ~2m to respond to simple queries, so we need to override the defaults. #pragma warning disable EXTEXP0001 builder.Services.AddHttpClient("bottomlymodel_httpClient") + .ConfigureHttpClient(c => c.DefaultRequestHeaders.Add("Authorization", $"Bearer {opts.Value.OllamaApiKey}")) .RemoveAllResilienceHandlers() #pragma warning restore EXTEXP0001 .AddStandardResilienceHandler(options => @@ -129,7 +133,7 @@ var app = builder.Build(); var featureFlagRepository = app.Services.GetRequiredService(); -await featureFlagRepository.SeedAsync("EnableLlm", opts.Value.EnableLlm); +await featureFlagRepository.SeedAsync("EnableLlm", false); var populator = app.Services.GetRequiredService(); await populator.PopulateMembers(); @@ -147,8 +151,7 @@ public static class HostBuilderExtensions { extension(HostApplicationBuilder builder) { - public void RegisterEventHandlers(Assembly assembly, Type[] exclude) - { + public void RegisterEventHandlers(Assembly assembly, Type[] exclude) => assembly.GetTypes() .Where(t => typeof(IMessageEventHandler).IsAssignableFrom(t) && t is { IsInterface: false, IsAbstract: false }) @@ -156,14 +159,11 @@ public void RegisterEventHandlers(Assembly assembly, Type[] exclude) .Where(t => !exclude.Contains(t)) .ToList() .ForEach(t => builder.Services.AddSingleton(typeof(IMessageEventHandler), t)); - } - public void RegisterCommands(Assembly assembly) - { + public void RegisterCommands(Assembly assembly) => assembly.GetTypes() .Where(t => typeof(ICommand).IsAssignableFrom(t) && t is { IsInterface: false, IsAbstract: false }) .ToList() .ForEach(t => builder.Services.AddSingleton(t)); - } } } \ No newline at end of file