Skip to content

Commit 51c4f73

Browse files
committed
Fix compilation errors for SK 1.74.0 API changes
1 parent 9243056 commit 51c4f73

3 files changed

Lines changed: 20 additions & 13 deletions

File tree

src/ABook.Agents/AgentOrchestrator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public async Task StartContinuityCheckAsync(int bookId, CancellationToken ct = d
8989
throw new InvalidOperationException("An agent is already running for this book.");
9090
try
9191
{
92-
await _continuity.CheckAsync(bookId, ct);
92+
await _continuity.CheckAsync(bookId, ct: ct);
9393
_state.SetStatus(bookId, new AgentRunStatus(AgentRole.ContinuityChecker, "Done", null));
9494
}
9595
catch
@@ -147,7 +147,7 @@ await _notifier.NotifyWorkflowProgressAsync(bookId,
147147
ct.ThrowIfCancellationRequested();
148148
_state.UpdateRunRole(bookId, AgentRole.ContinuityChecker, null);
149149
await _notifier.NotifyWorkflowProgressAsync(bookId, "Running final continuity check…", false, ct);
150-
await _continuity.CheckAsync(bookId, ct);
150+
await _continuity.CheckAsync(bookId, ct: ct);
151151

152152
_state.SetStatus(bookId, new AgentRunStatus(AgentRole.ContinuityChecker, "Done", null));
153153
await _notifier.NotifyWorkflowProgressAsync(bookId, "Workflow complete!", true, ct);
@@ -260,7 +260,7 @@ await _notifier.NotifyWorkflowProgressAsync(bookId,
260260
ct.ThrowIfCancellationRequested();
261261
_state.UpdateRunRole(bookId, AgentRole.ContinuityChecker, null);
262262
await _notifier.NotifyWorkflowProgressAsync(bookId, "Running continuity check…", false, ct);
263-
await _continuity.CheckAsync(bookId, ct);
263+
await _continuity.CheckAsync(bookId, ct: ct);
264264

265265
_state.SetStatus(bookId, new AgentRunStatus(AgentRole.ContinuityChecker, "Done", null));
266266
await _notifier.NotifyWorkflowProgressAsync(bookId, "Workflow complete!", true, ct);

src/ABook.Agents/ContinuityCheckerAgent.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ manuscript is consistent so far.
123123
$"Chapter {c.Number}: {c.Title}\nOutline: {c.Outline}\nContent excerpt: {c.Content?[..Math.Min(600, c.Content?.Length ?? 0)]}..."))
124124
: "(No preceding chapters yet.)";
125125

126-
var currentExcerpt = c =>
126+
var currentExcerpt =
127127
$"Chapter {currentChapter.Number}: {currentChapter.Title}\n" +
128128
$"Outline: {currentChapter.Outline}\n" +
129129
$"Content: {currentChapter.Content}";
@@ -137,7 +137,7 @@ against the preceding chapters. Do NOT report problems between the preceding cha
137137
{prevSynopsis}
138138
139139
## Chapter Under Review
140-
{currentExcerpt(currentChapter)}
140+
{currentExcerpt}
141141
"""
142142
: $"""
143143
Check Chapter {currentChapter.Number} ("{currentChapter.Title}") for continuity issues
@@ -147,7 +147,7 @@ against the preceding chapters. Do NOT report problems between the preceding cha
147147
{prevSynopsis}
148148
149149
## Chapter Under Review
150-
{currentExcerpt(currentChapter)}
150+
{currentExcerpt}
151151
152152
## Detailed Passages (retrieved for continuity review)
153153
{ragContext}

src/ABook.Infrastructure/Llm/LlmProviderFactory.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
#pragma warning disable SKEXP0070
1+
#pragma warning disable SKEXP0070, SKEXP0010
22

33
using ABook.Core.Interfaces;
44
using ABook.Core.Models;
55
using Microsoft.SemanticKernel;
66
using Microsoft.SemanticKernel.ChatCompletion;
77
using Microsoft.SemanticKernel.Connectors.Ollama;
88
using Microsoft.SemanticKernel.Embeddings;
9+
using OpenAI;
10+
using System.ClientModel;
911

1012
namespace ABook.Infrastructure.Llm;
1113

@@ -18,8 +20,7 @@ public IChatCompletionService CreateChatCompletion(LlmConfiguration config) =>
1820
LlmProvider.OpenAI => new Microsoft.SemanticKernel.Connectors.OpenAI.OpenAIChatCompletionService(
1921
config.ModelName, config.ApiKey ?? throw new InvalidOperationException("OpenAI requires an API key.")),
2022
LlmProvider.LMStudio => new Microsoft.SemanticKernel.Connectors.OpenAI.OpenAIChatCompletionService(
21-
config.ModelName, config.ApiKey ?? "lm-studio",
22-
endpoint: new Uri(config.Endpoint.TrimEnd('/') + "/v1")),
23+
config.ModelName, new Uri(config.Endpoint.TrimEnd('/') + "/v1"), config.ApiKey ?? "lm-studio"),
2324
_ => throw new NotSupportedException($"Provider {config.Provider} is not yet supported.")
2425
};
2526

@@ -32,8 +33,9 @@ public ITextEmbeddingGenerationService CreateEmbeddingGeneration(LlmConfiguratio
3233
LlmProvider.OpenAI => new Microsoft.SemanticKernel.Connectors.OpenAI.OpenAITextEmbeddingGenerationService(
3334
embeddingModel, config.ApiKey ?? throw new InvalidOperationException("OpenAI requires an API key.")),
3435
LlmProvider.LMStudio => new Microsoft.SemanticKernel.Connectors.OpenAI.OpenAITextEmbeddingGenerationService(
35-
embeddingModel, config.ApiKey ?? "lm-studio",
36-
endpoint: new Uri(config.Endpoint.TrimEnd('/') + "/v1")),
36+
embeddingModel, new OpenAIClient(
37+
new ApiKeyCredential(config.ApiKey ?? "lm-studio"),
38+
new OpenAIClientOptions { Endpoint = new Uri(config.Endpoint.TrimEnd('/') + "/v1") })),
3739
_ => throw new NotSupportedException($"Provider {config.Provider} is not yet supported for embeddings.")
3840
};
3941
}
@@ -57,9 +59,14 @@ public Kernel CreateKernel(LlmConfiguration config)
5759
case LlmProvider.LMStudio:
5860
var lmKey = config.ApiKey ?? "lm-studio";
5961
var lmEndpoint = new Uri(config.Endpoint.TrimEnd('/') + "/v1");
60-
builder.AddOpenAIChatCompletion(config.ModelName, lmKey, endpoint: lmEndpoint);
62+
builder.AddOpenAIChatCompletion(config.ModelName, lmEndpoint, lmKey);
6163
if (!string.IsNullOrWhiteSpace(config.EmbeddingModelName))
62-
builder.AddOpenAITextEmbeddingGeneration(config.EmbeddingModelName, lmKey, endpoint: lmEndpoint);
64+
{
65+
var lmClient = new OpenAIClient(
66+
new ApiKeyCredential(lmKey),
67+
new OpenAIClientOptions { Endpoint = lmEndpoint });
68+
builder.AddOpenAITextEmbeddingGeneration(config.EmbeddingModelName, lmClient);
69+
}
6370
break;
6471
default:
6572
throw new NotSupportedException($"Provider {config.Provider} is not yet supported.");

0 commit comments

Comments
 (0)