Skip to content

Commit 7d8b1c3

Browse files
committed
Strip out OpenAI.
1 parent 9ea58b6 commit 7d8b1c3

7 files changed

Lines changed: 6 additions & 241 deletions

File tree

src/Automation/ChatClientFactory.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Microsoft.Extensions.AI;
22
using Microsoft.Extensions.Configuration;
33
using OllamaSharp;
4-
using OpenAI;
54
using System;
65
using System.Collections.Generic;
76
using System.Linq;
@@ -19,13 +18,11 @@ public interface IChatClientFactory
1918

2019
internal sealed class ChatClientFactory : IChatClientFactory
2120
{
22-
private readonly OpenAIClient _openAIClient;
2321
private readonly IHttpClientFactory _httpClientFactory;
2422
private readonly IConfiguration _configuration;
2523

26-
public ChatClientFactory(OpenAIClient openAIClient, IHttpClientFactory httpClientFactory, IConfiguration configuration)
24+
public ChatClientFactory(IHttpClientFactory httpClientFactory, IConfiguration configuration)
2725
{
28-
_openAIClient = openAIClient;
2926
_httpClientFactory = httpClientFactory;
3027
_configuration = configuration;
3128
}
@@ -43,8 +40,6 @@ public IChatClient CreateClient(string urn)
4340

4441
switch (provider)
4542
{
46-
case "openai":
47-
return _openAIClient.GetChatClient(model).AsIChatClient();
4843
case "ollama":
4944
{
5045
var httpClient = _httpClientFactory.CreateClient();
@@ -69,9 +64,6 @@ public async Task<IList<string>> GetModels(string urn, CancellationToken token)
6964

7065
switch (provider)
7166
{
72-
case "openai":
73-
var openAiModels = await _openAIClient.GetOpenAIModelClient().GetModelsAsync(token);
74-
return [.. openAiModels.Value.Select(x => x.Id)];
7567
case "ollama":
7668
{
7769
using var httpClient = _httpClientFactory.CreateClient();

src/Automation/Estranged.Automation.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
<PackageReference Include="OllamaSharp" Version="5.4.7" />
2424
<PackageReference Include="System.Net.Http.Json" Version="9.0.9" />
2525
<PackageReference Include="Microsoft.Extensions.AI" Version="9.9.1" />
26-
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.9.0-preview.1.25458.4" />
2726
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.11" />
2827
</ItemGroup>
2928

src/Automation/Program.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using Microsoft.Extensions.Http;
77
using Microsoft.Extensions.Logging;
88
using Octokit;
9-
using OpenAI;
109
using OllamaSharp;
1110
using System;
1211
using System.Net.Http.Headers;
@@ -57,7 +56,6 @@ public static int Main(string[] args)
5756
.AddTransient<DiscordRunner>()
5857
.AddSingleton<IGitHubClient>(gitHubClient)
5958
.AddSingleton(discordSocketClient)
60-
.AddSingleton(new OpenAIClient(configuration["OPENAI_APIKEY"]))
6159
.AddSingleton(provider =>
6260
{
6361
var httpClient = provider.GetRequiredService<IHttpClientFactory>().CreateClient();

src/Automation/Responders/DalleResponder.cs

Lines changed: 0 additions & 98 deletions
This file was deleted.

src/Automation/Responders/GptResponder.cs

Lines changed: 0 additions & 121 deletions
This file was deleted.

src/Automation/Responders/LoreResponder.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using Microsoft.Extensions.Configuration;
55
using Microsoft.Extensions.Logging;
66
using ModelContextProtocol.Client;
7-
using OpenAI;
87
using System;
98
using System.Collections.Generic;
109
using System.Linq;
@@ -15,17 +14,17 @@ namespace Estranged.Automation.Responders
1514
{
1615
internal sealed class LoreResponder : IResponder
1716
{
18-
private readonly ILogger<GptResponder> _logger;
17+
private readonly ILogger<LoreResponder> _logger;
1918
private readonly IConfiguration _configuration;
2019
private readonly IFeatureFlags _featureFlags;
21-
private readonly OpenAIClient _openAIClient;
20+
private readonly IChatClientFactory _chatClientFactory;
2221

23-
public LoreResponder(ILogger<GptResponder> logger, IConfiguration configuration, IFeatureFlags featureFlags, OpenAIClient openAIClient)
22+
public LoreResponder(ILogger<LoreResponder> logger, IConfiguration configuration, IFeatureFlags featureFlags, IChatClientFactory chatClientFactory)
2423
{
2524
_logger = logger;
2625
_configuration = configuration;
2726
_featureFlags = featureFlags;
28-
_openAIClient = openAIClient;
27+
_chatClientFactory = chatClientFactory;
2928
}
3029

3130
public async Task ProcessMessage(IMessage originalMessage, CancellationToken token)
@@ -75,9 +74,7 @@ private async Task<IList<McpClientTool>> GetTools()
7574

7675
private async Task Chat(IList<IMessage> messageHistory, int initialMessagePrefixLength, IList<McpClientTool> tools, CancellationToken token)
7776
{
78-
var openAIClient = _openAIClient.GetChatClient("gpt-4o-mini");
79-
80-
using IChatClient chatClient = openAIClient.AsIChatClient()
77+
using IChatClient chatClient = _chatClientFactory.CreateClient("urn:ollama:quen3:8b")
8178
.AsBuilder()
8279
.UseFunctionInvocation()
8380
.Build();

src/Automation/ServiceCollectionExtensions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ public static IServiceCollection AddResponderServices(this IServiceCollection se
2323
.AddSingleton<IResponder, HowAreYouResponder>()
2424
.AddSingleton<IResponder, CopyReactionEmoji>()
2525
.AddSingleton<IResponder, SpammerResponder>()
26-
.AddSingleton<IResponder, DalleResponder>()
2726
.AddSingleton<IResponder, StableDiffusionResponder>()
28-
.AddSingleton<IResponder, GptResponder>()
2927
.AddSingleton<IResponder, OllamaResponder>()
3028
.AddSingleton<IResponder, RetentionResponder>()
3129
.AddSingleton<IResponder, LoreResponder>()

0 commit comments

Comments
 (0)