Skip to content

Commit 7fbf1d5

Browse files
committed
post merge fixes
1 parent 00ddba5 commit 7fbf1d5

File tree

3 files changed

+31
-30
lines changed

3 files changed

+31
-30
lines changed

MaIN.Core.IntegrationTests/BackendParamsTests.cs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using MaIN.Domain.Entities;
44
using MaIN.Domain.Configuration.BackendInferenceParams;
55
using MaIN.Domain.Exceptions;
6+
using MaIN.Domain.Models;
67
using MaIN.Domain.Models.Concrete;
78

89
namespace MaIN.Core.IntegrationTests;
@@ -17,7 +18,7 @@ public async Task OpenAi_Should_RespondWithParams()
1718
SkipIfMissingKey(LLMApiRegistry.GetEntry(BackendType.OpenAi)?.ApiKeyEnvName!);
1819

1920
var result = await AIHub.Chat()
20-
.WithModel<Gpt4oMini>()
21+
.WithModel(Models.OpenAi.Gpt4oMini)
2122
.WithMessage(TestQuestion)
2223
.WithInferenceParams(new OpenAiInferenceParams
2324
{
@@ -39,7 +40,7 @@ public async Task Anthropic_Should_RespondWithParams()
3940
SkipIfMissingKey(LLMApiRegistry.GetEntry(BackendType.Anthropic)?.ApiKeyEnvName!);
4041

4142
var result = await AIHub.Chat()
42-
.WithModel<ClaudeSonnet4>()
43+
.WithModel(Models.Anthropic.ClaudeSonnet4)
4344
.WithMessage(TestQuestion)
4445
.WithInferenceParams(new AnthropicInferenceParams
4546
{
@@ -61,7 +62,7 @@ public async Task Gemini_Should_RespondWithParams()
6162
SkipIfMissingKey(LLMApiRegistry.GetEntry(BackendType.Gemini)?.ApiKeyEnvName!);
6263

6364
var result = await AIHub.Chat()
64-
.WithModel<Gemini2_0Flash>()
65+
.WithModel(Models.Gemini.Gemini2_0Flash)
6566
.WithMessage(TestQuestion)
6667
.WithInferenceParams(new GeminiInferenceParams
6768
{
@@ -83,7 +84,7 @@ public async Task DeepSeek_Should_RespondWithParams()
8384
SkipIfMissingKey(LLMApiRegistry.GetEntry(BackendType.DeepSeek)?.ApiKeyEnvName!);
8485

8586
var result = await AIHub.Chat()
86-
.WithModel<DeepSeekReasoner>()
87+
.WithModel(Models.DeepSeek.Reasoner)
8788
.WithMessage(TestQuestion)
8889
.WithInferenceParams(new DeepSeekInferenceParams
8990
{
@@ -105,7 +106,7 @@ public async Task GroqCloud_Should_RespondWithParams()
105106
SkipIfMissingKey(LLMApiRegistry.GetEntry(BackendType.GroqCloud)?.ApiKeyEnvName!);
106107

107108
var result = await AIHub.Chat()
108-
.WithModel<Llama3_1_8bInstant>()
109+
.WithModel(Models.Groq.Llama3_1_8bInstant)
109110
.WithMessage(TestQuestion)
110111
.WithInferenceParams(new GroqCloudInferenceParams
111112
{
@@ -127,7 +128,7 @@ public async Task Xai_Should_RespondWithParams()
127128
SkipIfMissingKey(LLMApiRegistry.GetEntry(BackendType.Xai)?.ApiKeyEnvName!);
128129

129130
var result = await AIHub.Chat()
130-
.WithModel<Grok3Beta>()
131+
.WithModel(Models.Xai.Grok3Beta)
131132
.WithMessage(TestQuestion)
132133
.WithInferenceParams(new XaiInferenceParams
133134
{
@@ -149,7 +150,7 @@ public async Task Self_Should_RespondWithParams()
149150
Skip.If(!File.Exists("C:/Models/gemma2-2b.gguf"), "Local model not found at C:/Models/gemma2-2b.gguf");
150151

151152
var result = await AIHub.Chat()
152-
.WithModel<Gemma2_2b>()
153+
.WithModel(Models.Local.Gemma2_2b)
153154
.WithMessage(TestQuestion)
154155
.WithInferenceParams(new LocalInferenceParams
155156
{
@@ -173,7 +174,7 @@ public async Task LocalOllama_Should_RespondWithParams()
173174
SkipIfOllamaNotRunning();
174175

175176
var result = await AIHub.Chat()
176-
.WithModel<OllamaGemma3_4b>()
177+
.WithModel(Models.Ollama.Gemma3_4b)
177178
.WithMessage(TestQuestion)
178179
.WithInferenceParams(new OllamaInferenceParams
179180
{
@@ -197,7 +198,7 @@ public async Task ClaudOllama_Should_RespondWithParams()
197198
SkipIfMissingKey(LLMApiRegistry.GetEntry(BackendType.Ollama)?.ApiKeyEnvName!);
198199

199200
var result = await AIHub.Chat()
200-
.WithModel<OllamaGemma3_4b>()
201+
.WithModel(Models.Ollama.Gemma3_4b)
201202
.WithMessage(TestQuestion)
202203
.WithInferenceParams(new OllamaInferenceParams
203204
{
@@ -222,7 +223,7 @@ public async Task Self_Should_ThrowWhenGivenWrongParams()
222223
{
223224
await Assert.ThrowsAsync<InvalidBackendParamsException>(() =>
224225
AIHub.Chat()
225-
.WithModel<Gemma2_2b>()
226+
.WithModel(Models.Local.Gemma2_2b)
226227
.WithMessage(TestQuestion)
227228
.WithInferenceParams(new OpenAiInferenceParams())
228229
.CompleteAsync());
@@ -233,7 +234,7 @@ public async Task OpenAi_Should_ThrowWhenGivenWrongParams()
233234
{
234235
await Assert.ThrowsAsync<InvalidBackendParamsException>(() =>
235236
AIHub.Chat()
236-
.WithModel<Gpt4oMini>()
237+
.WithModel(Models.OpenAi.Gpt4oMini)
237238
.WithMessage(TestQuestion)
238239
.WithInferenceParams(new DeepSeekInferenceParams())
239240
.CompleteAsync());
@@ -244,7 +245,7 @@ public async Task Anthropic_Should_ThrowWhenGivenWrongParams()
244245
{
245246
await Assert.ThrowsAsync<InvalidBackendParamsException>(() =>
246247
AIHub.Chat()
247-
.WithModel<ClaudeSonnet4>()
248+
.WithModel(Models.Anthropic.ClaudeSonnet4)
248249
.WithMessage(TestQuestion)
249250
.WithInferenceParams(new OpenAiInferenceParams())
250251
.CompleteAsync());
@@ -255,7 +256,7 @@ public async Task Gemini_Should_ThrowWhenGivenWrongParams()
255256
{
256257
await Assert.ThrowsAsync<InvalidBackendParamsException>(() =>
257258
AIHub.Chat()
258-
.WithModel<Gemini2_0Flash>()
259+
.WithModel(Models.Gemini.Gemini2_0Flash)
259260
.WithMessage(TestQuestion)
260261
.WithInferenceParams(new AnthropicInferenceParams())
261262
.CompleteAsync());
@@ -266,7 +267,7 @@ public async Task DeepSeek_Should_ThrowWhenGivenWrongParams()
266267
{
267268
await Assert.ThrowsAsync<InvalidBackendParamsException>(() =>
268269
AIHub.Chat()
269-
.WithModel<DeepSeekReasoner>()
270+
.WithModel(Models.DeepSeek.Reasoner)
270271
.WithMessage(TestQuestion)
271272
.WithInferenceParams(new GeminiInferenceParams())
272273
.CompleteAsync());
@@ -277,7 +278,7 @@ public async Task GroqCloud_Should_ThrowWhenGivenWrongParams()
277278
{
278279
await Assert.ThrowsAsync<InvalidBackendParamsException>(() =>
279280
AIHub.Chat()
280-
.WithModel<Llama3_1_8bInstant>()
281+
.WithModel(Models.Groq.Llama3_1_8bInstant)
281282
.WithMessage(TestQuestion)
282283
.WithInferenceParams(new OpenAiInferenceParams())
283284
.CompleteAsync());
@@ -288,7 +289,7 @@ public async Task Xai_Should_ThrowWhenGivenWrongParams()
288289
{
289290
await Assert.ThrowsAsync<InvalidBackendParamsException>(() =>
290291
AIHub.Chat()
291-
.WithModel<Grok3Beta>()
292+
.WithModel(Models.Xai.Grok3Beta)
292293
.WithMessage(TestQuestion)
293294
.WithInferenceParams(new AnthropicInferenceParams())
294295
.CompleteAsync());
@@ -299,7 +300,7 @@ public async Task Ollama_Should_ThrowWhenGivenWrongParams()
299300
{
300301
await Assert.ThrowsAsync<InvalidBackendParamsException>(() =>
301302
AIHub.Chat()
302-
.WithModel<OllamaGemma3_4b>()
303+
.WithModel(Models.Ollama.Gemma3_4b)
303304
.WithMessage(TestQuestion)
304305
.WithInferenceParams(new DeepSeekInferenceParams())
305306
.CompleteAsync());

src/MaIN.Infrastructure/Mappers/ChatDocumentMapper.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ internal static class ChatDocumentMapper
1616
ImageGen = chat.ImageGen,
1717
ToolsConfiguration = chat.ToolsConfiguration,
1818
MemoryParams = chat.MemoryParams.ToDocument(),
19-
InferenceParams = chat.InterferenceParams.ToDocument(),
19+
InferenceParams = (chat.BackendParams as LocalInferenceParams)?.ToDocument(),
2020
ConvState = chat.ConversationState,
2121
Properties = chat.Properties,
2222
Interactive = chat.Interactive,
@@ -35,7 +35,7 @@ internal static class ChatDocumentMapper
3535
ToolsConfiguration = chat.ToolsConfiguration,
3636
ConversationState = chat.ConvState as Conversation.State,
3737
MemoryParams = chat.MemoryParams!.ToDomain(),
38-
InterferenceParams = chat.InferenceParams!.ToDomain(),
38+
BackendParams = chat.InferenceParams?.ToDomain() ?? new LocalInferenceParams(),
3939
Interactive = chat.Interactive,
4040
Translate = chat.Translate,
4141
Type = Enum.Parse<ChatType>(chat.Type.ToString())
@@ -78,7 +78,7 @@ internal static class ChatDocumentMapper
7878
Type = llmTokenValue.Type
7979
};
8080

81-
private static InferenceParamsDocument ToDocument(this InferenceParams inferenceParams) => new()
81+
private static InferenceParamsDocument ToDocument(this LocalInferenceParams inferenceParams) => new()
8282
{
8383
Temperature = inferenceParams.Temperature,
8484
ContextSize = inferenceParams.ContextSize,
@@ -96,7 +96,7 @@ internal static class ChatDocumentMapper
9696
Grammar = inferenceParams.Grammar
9797
};
9898

99-
private static InferenceParams ToDomain(this InferenceParamsDocument inferenceParams) => new()
99+
private static LocalInferenceParams ToDomain(this InferenceParamsDocument inferenceParams) => new()
100100
{
101101
Temperature = inferenceParams.Temperature,
102102
ContextSize = inferenceParams.ContextSize,

src/MaIN.Services/Services/LLMService/LLMService.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -546,22 +546,22 @@ private static string FormatToolsForPrompt(ToolsConfiguration toolsConfig)
546546
return (tokens, isComplete, hasFailed);
547547
}
548548

549-
private static BaseSamplingPipeline CreateSampler(LocalInferenceParams interferenceParams)
549+
private static BaseSamplingPipeline CreateSampler(LocalInferenceParams inferenceParams)
550550
{
551-
return interferenceParams.Temperature == 0
551+
return inferenceParams.Temperature == 0
552552
? new GreedySamplingPipeline()
553553
{
554-
Grammar = interferenceParams.Grammar is not null
555-
? new Grammar(interferenceParams.Grammar.Value, "root")
554+
Grammar = inferenceParams.Grammar is not null
555+
? new Grammar(inferenceParams.Grammar.Value, "root")
556556
: null
557557
}
558558
: new DefaultSamplingPipeline()
559559
{
560-
Temperature = interferenceParams.Temperature,
561-
TopP = interferenceParams.TopP,
562-
TopK = interferenceParams.TopK,
563-
Grammar = interferenceParams.Grammar is not null
564-
? new Grammar(interferenceParams.Grammar.Value, "root")
560+
Temperature = inferenceParams.Temperature,
561+
TopP = inferenceParams.TopP,
562+
TopK = inferenceParams.TopK,
563+
Grammar = inferenceParams.Grammar is not null
564+
? new Grammar(inferenceParams.Grammar.Value, "root")
565565
: null
566566
};
567567
}

0 commit comments

Comments
 (0)