Skip to content

Commit fd9448e

Browse files
committed
Rename provider to backend
1 parent 5b3c364 commit fd9448e

33 files changed

Lines changed: 144 additions & 135 deletions

MaIN.Core.IntegrationTests/ProviderParamsTests.cs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
using MaIN.Core.Hub;
22
using MaIN.Domain.Configuration;
33
using MaIN.Domain.Entities;
4-
using MaIN.Domain.Entities.ProviderParams;
4+
using MaIN.Domain.Configuration.BackendInferenceParams;
55
using MaIN.Domain.Exceptions;
66
using MaIN.Domain.Models.Concrete;
77

88
namespace MaIN.Core.IntegrationTests;
99

10-
public class ProviderParamsTests : IntegrationTestBase
10+
public class BackendParamsTests : IntegrationTestBase
1111
{
1212
private const string TestQuestion = "What is 2+2? Answer with just the number.";
1313

@@ -19,7 +19,7 @@ public async Task OpenAi_Should_RespondWithParams()
1919
var result = await AIHub.Chat()
2020
.WithModel<Gpt4oMini>()
2121
.WithMessage(TestQuestion)
22-
.WithInferenceParams(new OpenAiParams
22+
.WithInferenceParams(new OpenAiInferenceParams
2323
{
2424
Temperature = 0.3f,
2525
MaxTokens = 100,
@@ -41,7 +41,7 @@ public async Task Anthropic_Should_RespondWithParams()
4141
var result = await AIHub.Chat()
4242
.WithModel<ClaudeSonnet4>()
4343
.WithMessage(TestQuestion)
44-
.WithInferenceParams(new AnthropicParams
44+
.WithInferenceParams(new AnthropicInferenceParams
4545
{
4646
Temperature = 0.3f,
4747
MaxTokens = 100,
@@ -63,7 +63,7 @@ public async Task Gemini_Should_RespondWithParams()
6363
var result = await AIHub.Chat()
6464
.WithModel<Gemini2_0Flash>()
6565
.WithMessage(TestQuestion)
66-
.WithInferenceParams(new GeminiParams
66+
.WithInferenceParams(new GeminiInferenceParams
6767
{
6868
Temperature = 0.3f,
6969
MaxTokens = 100,
@@ -85,7 +85,7 @@ public async Task DeepSeek_Should_RespondWithParams()
8585
var result = await AIHub.Chat()
8686
.WithModel<DeepSeekReasoner>()
8787
.WithMessage(TestQuestion)
88-
.WithInferenceParams(new DeepSeekParams
88+
.WithInferenceParams(new DeepSeekInferenceParams
8989
{
9090
Temperature = 0.3f,
9191
MaxTokens = 100,
@@ -107,7 +107,7 @@ public async Task GroqCloud_Should_RespondWithParams()
107107
var result = await AIHub.Chat()
108108
.WithModel<Llama3_1_8bInstant>()
109109
.WithMessage(TestQuestion)
110-
.WithInferenceParams(new GroqCloudParams
110+
.WithInferenceParams(new GroqCloudInferenceParams
111111
{
112112
Temperature = 0.3f,
113113
MaxTokens = 100,
@@ -129,7 +129,7 @@ public async Task Xai_Should_RespondWithParams()
129129
var result = await AIHub.Chat()
130130
.WithModel<Grok3Beta>()
131131
.WithMessage(TestQuestion)
132-
.WithInferenceParams(new XaiParams
132+
.WithInferenceParams(new XaiInferenceParams
133133
{
134134
Temperature = 0.3f,
135135
MaxTokens = 100,
@@ -175,7 +175,7 @@ public async Task LocalOllama_Should_RespondWithParams()
175175
var result = await AIHub.Chat()
176176
.WithModel<OllamaGemma3_4b>()
177177
.WithMessage(TestQuestion)
178-
.WithInferenceParams(new OllamaParams
178+
.WithInferenceParams(new OllamaInferenceParams
179179
{
180180
Temperature = 0.3f,
181181
MaxTokens = 100,
@@ -199,7 +199,7 @@ public async Task ClaudOllama_Should_RespondWithParams()
199199
var result = await AIHub.Chat()
200200
.WithModel<OllamaGemma3_4b>()
201201
.WithMessage(TestQuestion)
202-
.WithInferenceParams(new OllamaParams
202+
.WithInferenceParams(new OllamaInferenceParams
203203
{
204204
Temperature = 0.3f,
205205
MaxTokens = 100,
@@ -220,88 +220,88 @@ public async Task ClaudOllama_Should_RespondWithParams()
220220
[Fact]
221221
public async Task Self_Should_ThrowWhenGivenWrongParams()
222222
{
223-
await Assert.ThrowsAsync<InvalidProviderParamsException>(() =>
223+
await Assert.ThrowsAsync<InvalidBackendParamsException>(() =>
224224
AIHub.Chat()
225225
.WithModel<Gemma2_2b>()
226226
.WithMessage(TestQuestion)
227-
.WithInferenceParams(new OpenAiParams())
227+
.WithInferenceParams(new OpenAiInferenceParams())
228228
.CompleteAsync());
229229
}
230230

231231
[Fact]
232232
public async Task OpenAi_Should_ThrowWhenGivenWrongParams()
233233
{
234-
await Assert.ThrowsAsync<InvalidProviderParamsException>(() =>
234+
await Assert.ThrowsAsync<InvalidBackendParamsException>(() =>
235235
AIHub.Chat()
236236
.WithModel<Gpt4oMini>()
237237
.WithMessage(TestQuestion)
238-
.WithInferenceParams(new DeepSeekParams())
238+
.WithInferenceParams(new DeepSeekInferenceParams())
239239
.CompleteAsync());
240240
}
241241

242242
[Fact]
243243
public async Task Anthropic_Should_ThrowWhenGivenWrongParams()
244244
{
245-
await Assert.ThrowsAsync<InvalidProviderParamsException>(() =>
245+
await Assert.ThrowsAsync<InvalidBackendParamsException>(() =>
246246
AIHub.Chat()
247247
.WithModel<ClaudeSonnet4>()
248248
.WithMessage(TestQuestion)
249-
.WithInferenceParams(new OpenAiParams())
249+
.WithInferenceParams(new OpenAiInferenceParams())
250250
.CompleteAsync());
251251
}
252252

253253
[Fact]
254254
public async Task Gemini_Should_ThrowWhenGivenWrongParams()
255255
{
256-
await Assert.ThrowsAsync<InvalidProviderParamsException>(() =>
256+
await Assert.ThrowsAsync<InvalidBackendParamsException>(() =>
257257
AIHub.Chat()
258258
.WithModel<Gemini2_0Flash>()
259259
.WithMessage(TestQuestion)
260-
.WithInferenceParams(new AnthropicParams())
260+
.WithInferenceParams(new AnthropicInferenceParams())
261261
.CompleteAsync());
262262
}
263263

264264
[Fact]
265265
public async Task DeepSeek_Should_ThrowWhenGivenWrongParams()
266266
{
267-
await Assert.ThrowsAsync<InvalidProviderParamsException>(() =>
267+
await Assert.ThrowsAsync<InvalidBackendParamsException>(() =>
268268
AIHub.Chat()
269269
.WithModel<DeepSeekReasoner>()
270270
.WithMessage(TestQuestion)
271-
.WithInferenceParams(new GeminiParams())
271+
.WithInferenceParams(new GeminiInferenceParams())
272272
.CompleteAsync());
273273
}
274274

275275
[Fact]
276276
public async Task GroqCloud_Should_ThrowWhenGivenWrongParams()
277277
{
278-
await Assert.ThrowsAsync<InvalidProviderParamsException>(() =>
278+
await Assert.ThrowsAsync<InvalidBackendParamsException>(() =>
279279
AIHub.Chat()
280280
.WithModel<Llama3_1_8bInstant>()
281281
.WithMessage(TestQuestion)
282-
.WithInferenceParams(new OpenAiParams())
282+
.WithInferenceParams(new OpenAiInferenceParams())
283283
.CompleteAsync());
284284
}
285285

286286
[Fact]
287287
public async Task Xai_Should_ThrowWhenGivenWrongParams()
288288
{
289-
await Assert.ThrowsAsync<InvalidProviderParamsException>(() =>
289+
await Assert.ThrowsAsync<InvalidBackendParamsException>(() =>
290290
AIHub.Chat()
291291
.WithModel<Grok3Beta>()
292292
.WithMessage(TestQuestion)
293-
.WithInferenceParams(new AnthropicParams())
293+
.WithInferenceParams(new AnthropicInferenceParams())
294294
.CompleteAsync());
295295
}
296296

297297
[Fact]
298298
public async Task Ollama_Should_ThrowWhenGivenWrongParams()
299299
{
300-
await Assert.ThrowsAsync<InvalidProviderParamsException>(() =>
300+
await Assert.ThrowsAsync<InvalidBackendParamsException>(() =>
301301
AIHub.Chat()
302302
.WithModel<OllamaGemma3_4b>()
303303
.WithMessage(TestQuestion)
304-
.WithInferenceParams(new DeepSeekParams())
304+
.WithInferenceParams(new DeepSeekInferenceParams())
305305
.CompleteAsync());
306306
}
307307

src/MaIN.Core.UnitTests/AgentContextTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public async Task CreateAsync_ShouldCallAgentServiceCreateAgent()
137137
It.IsAny<Agent>(),
138138
It.IsAny<bool>(),
139139
It.IsAny<bool>(),
140-
It.IsAny<IProviderInferenceParams>(),
140+
It.IsAny<IBackendInferenceParams>(),
141141
It.IsAny<MemoryParams>(),
142142
It.IsAny<bool>()))
143143
.ReturnsAsync(agent);
@@ -151,7 +151,7 @@ public async Task CreateAsync_ShouldCallAgentServiceCreateAgent()
151151
It.IsAny<Agent>(),
152152
It.Is<bool>(f => f == true),
153153
It.Is<bool>(r => r == false),
154-
It.IsAny<IProviderInferenceParams>(),
154+
It.IsAny<IBackendInferenceParams>(),
155155
It.IsAny<MemoryParams>(),
156156
It.IsAny<bool>()),
157157
Times.Once);

src/MaIN.Core/Hub/Contexts/AgentContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace MaIN.Core.Hub.Contexts;
1818
public sealed class AgentContext : IAgentBuilderEntryPoint, IAgentConfigurationBuilder, IAgentContextExecutor
1919
{
2020
private readonly IAgentService _agentService;
21-
private IProviderInferenceParams? _inferenceParams;
21+
private IBackendInferenceParams? _inferenceParams;
2222
private MemoryParams? _memoryParams;
2323
private bool _disableCache;
2424
private bool _ensureModelDownloaded;
@@ -152,7 +152,7 @@ public IAgentConfigurationBuilder WithMcpConfig(Mcp mcpConfig)
152152
return this;
153153
}
154154

155-
public IAgentConfigurationBuilder WithInferenceParams(IProviderInferenceParams inferenceParams)
155+
public IAgentConfigurationBuilder WithInferenceParams(IBackendInferenceParams inferenceParams)
156156
{
157157
_inferenceParams = inferenceParams;
158158
return this;

src/MaIN.Core/Hub/Contexts/ChatContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ public IChatMessageBuilder EnsureModelDownloaded()
9292
return this;
9393
}
9494

95-
public IChatConfigurationBuilder WithInferenceParams(IProviderInferenceParams inferenceParams)
95+
public IChatConfigurationBuilder WithInferenceParams(IBackendInferenceParams inferenceParams)
9696
{
97-
_chat.ProviderParams = inferenceParams;
97+
_chat.BackendParams = inferenceParams;
9898
return this;
9999
}
100100

src/MaIN.Core/Hub/Contexts/Interfaces/AgentContext/IAgentConfigurationBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ public interface IAgentConfigurationBuilder : IAgentActions
7979
/// based on specific parameters. Inference parameters can influence various aspects of the chat, such as response length,
8080
/// temperature, and other model-specific settings.
8181
/// </summary>
82-
/// <param name="inferenceParams">An <see cref="IProviderInferenceParams"/> object that holds the parameters for inference, such as Temperature, MaxTokens,
82+
/// <param name="inferenceParams">An <see cref="IBackendInferenceParams"/> object that holds the parameters for inference, such as Temperature, MaxTokens,
8383
/// TopP, etc. These parameters control the generation behavior of the agent.</param>
8484
/// <returns>The context instance implementing <see cref="IAgentConfigurationBuilder"/> for method chaining.</returns>
85-
IAgentConfigurationBuilder WithInferenceParams(IProviderInferenceParams inferenceParams);
85+
IAgentConfigurationBuilder WithInferenceParams(IBackendInferenceParams inferenceParams);
8686

8787
/// <summary>
8888
/// Sets the memory parameters for the chat session, allowing you to customize how the AI accesses and uses its memory

src/MaIN.Core/Hub/Contexts/Interfaces/ChatContext/IChatConfigurationBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ public interface IChatConfigurationBuilder : IChatActions
1414
/// responses based on specific parameters. Inference parameters can influence various aspects of the chat, such as response length,
1515
/// temperature, and other model-specific settings.
1616
/// </summary>
17-
/// <param name="inferenceParams">An <see cref="IProviderInferenceParams"/> object that holds the parameters for inference, such as Temperature,
17+
/// <param name="inferenceParams">An <see cref="IBackendInferenceParams"/> object that holds the parameters for inference, such as Temperature,
1818
/// MaxTokens, TopP, etc. These parameters control the generation behavior of the chat.</param>
1919
/// <returns>The context instance implementing <see cref="IChatConfigurationBuilder"/> for method chaining.</returns>
20-
IChatConfigurationBuilder WithInferenceParams(IProviderInferenceParams inferenceParams);
20+
IChatConfigurationBuilder WithInferenceParams(IBackendInferenceParams inferenceParams);
2121

2222
/// <summary>
2323
/// Attaches external tools/functions that the model can invoke during the conversation.

src/MaIN.Domain/Entities/ProviderParams/AnthropicParams.cs renamed to src/MaIN.Domain/Configuration/BackendInferenceParams/AnthropicInferenceParams.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
using MaIN.Domain.Configuration;
2+
using MaIN.Domain.Entities;
23
using Grammar = MaIN.Domain.Models.Grammar;
34

4-
namespace MaIN.Domain.Entities.ProviderParams;
5+
namespace MaIN.Domain.Configuration.BackendInferenceParams;
56

6-
public class AnthropicParams : IProviderInferenceParams
7+
public class AnthropicInferenceParams : IBackendInferenceParams
78
{
89
public BackendType Backend => BackendType.Anthropic;
910

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using MaIN.Domain.Configuration;
2+
using MaIN.Domain.Entities;
3+
using MaIN.Domain.Configuration.BackendInferenceParams;
4+
5+
namespace MaIN.Domain.Configuration.BackendInferenceParams;
6+
7+
public static class BackendParamsFactory
8+
{
9+
public static IBackendInferenceParams Create(BackendType backend) => backend switch
10+
{
11+
BackendType.Self => new LocalInferenceParams(),
12+
BackendType.OpenAi => new OpenAiInferenceParams(),
13+
BackendType.DeepSeek => new DeepSeekInferenceParams(),
14+
BackendType.GroqCloud => new GroqCloudInferenceParams(),
15+
BackendType.Xai => new XaiInferenceParams(),
16+
BackendType.Gemini => new GeminiInferenceParams(),
17+
BackendType.Anthropic => new AnthropicInferenceParams(),
18+
BackendType.Ollama => new OllamaInferenceParams(),
19+
_ => new LocalInferenceParams()
20+
};
21+
}

src/MaIN.Domain/Entities/ProviderParams/DeepSeekParams.cs renamed to src/MaIN.Domain/Configuration/BackendInferenceParams/DeepSeekInferenceParams.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
using MaIN.Domain.Configuration;
2+
using MaIN.Domain.Entities;
23
using Grammar = MaIN.Domain.Models.Grammar;
34

4-
namespace MaIN.Domain.Entities.ProviderParams;
5+
namespace MaIN.Domain.Configuration.BackendInferenceParams;
56

6-
public class DeepSeekParams : IProviderInferenceParams
7+
public class DeepSeekInferenceParams : IBackendInferenceParams
78
{
89
public BackendType Backend => BackendType.DeepSeek;
910

src/MaIN.Domain/Entities/ProviderParams/GeminiParams.cs renamed to src/MaIN.Domain/Configuration/BackendInferenceParams/GeminiInferenceParams.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
using MaIN.Domain.Configuration;
2+
using MaIN.Domain.Entities;
23
using Grammar = MaIN.Domain.Models.Grammar;
34

4-
namespace MaIN.Domain.Entities.ProviderParams;
5+
namespace MaIN.Domain.Configuration.BackendInferenceParams;
56

6-
public class GeminiParams : IProviderInferenceParams
7+
public class GeminiInferenceParams : IBackendInferenceParams
78
{
89
public BackendType Backend => BackendType.Gemini;
910

0 commit comments

Comments
 (0)