Skip to content

Commit ac54712

Browse files
committed
fix: don't send default parameters; Params may vary by model
1 parent fd9448e commit ac54712

17 files changed

Lines changed: 77 additions & 69 deletions
File renamed without changes.

src/MaIN.Domain/Configuration/BackendInferenceParams/AnthropicInferenceParams.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ public class AnthropicInferenceParams : IBackendInferenceParams
88
{
99
public BackendType Backend => BackendType.Anthropic;
1010

11-
public float Temperature { get; init; } = 1.0f;
12-
public int MaxTokens { get; init; } = 4096;
13-
public int TopK { get; init; } = -1;
14-
public float TopP { get; init; } = 1.0f;
11+
public float? Temperature { get; init; }
12+
public int? MaxTokens { get; init; }
13+
public int? TopK { get; init; }
14+
public float? TopP { get; init; }
1515
public Grammar? Grammar { get; set; }
1616
}

src/MaIN.Domain/Configuration/BackendInferenceParams/DeepSeekInferenceParams.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ public class DeepSeekInferenceParams : IBackendInferenceParams
88
{
99
public BackendType Backend => BackendType.DeepSeek;
1010

11-
public float Temperature { get; init; } = 0.7f;
12-
public int MaxTokens { get; init; } = 4096;
13-
public float TopP { get; init; } = 1.0f;
14-
public float FrequencyPenalty { get; init; }
15-
public float PresencePenalty { get; init; }
11+
public float? Temperature { get; init; }
12+
public int? MaxTokens { get; init; }
13+
public float? TopP { get; init; }
14+
public float? FrequencyPenalty { get; init; }
15+
public float? PresencePenalty { get; init; }
1616
public string? ResponseFormat { get; init; }
1717
public Grammar? Grammar { get; set; }
1818
}

src/MaIN.Domain/Configuration/BackendInferenceParams/GeminiInferenceParams.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ public class GeminiInferenceParams : IBackendInferenceParams
88
{
99
public BackendType Backend => BackendType.Gemini;
1010

11-
public float Temperature { get; init; } = 0.7f;
12-
public int MaxTokens { get; init; } = 4096;
13-
public float TopP { get; init; } = 0.95f;
11+
public float? Temperature { get; init; }
12+
public int? MaxTokens { get; init; }
13+
public float? TopP { get; init; }
1414
public string[]? StopSequences { get; init; }
1515
public Grammar? Grammar { get; set; }
1616
}

src/MaIN.Domain/Configuration/BackendInferenceParams/GroqCloudInferenceParams.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ public class GroqCloudInferenceParams : IBackendInferenceParams
88
{
99
public BackendType Backend => BackendType.GroqCloud;
1010

11-
public float Temperature { get; init; } = 0.7f;
12-
public int MaxTokens { get; init; } = 4096;
13-
public float TopP { get; init; } = 1.0f;
14-
public float FrequencyPenalty { get; init; }
11+
public float? Temperature { get; init; }
12+
public int? MaxTokens { get; init; }
13+
public float? TopP { get; init; }
14+
public float? FrequencyPenalty { get; init; }
1515
public string? ResponseFormat { get; init; }
1616
public Grammar? Grammar { get; set; }
1717
}

src/MaIN.Domain/Configuration/BackendInferenceParams/OllamaInferenceParams.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ public class OllamaInferenceParams : IBackendInferenceParams
88
{
99
public BackendType Backend => BackendType.Ollama;
1010

11-
public float Temperature { get; init; } = 0.8f;
12-
public int MaxTokens { get; init; } = 4096;
13-
public int TopK { get; init; } = 40;
14-
public float TopP { get; init; } = 0.9f;
15-
public int NumCtx { get; init; } = 2048;
16-
public int NumGpu { get; init; } = 30;
11+
public float? Temperature { get; init; }
12+
public int? MaxTokens { get; init; }
13+
public int? TopK { get; init; }
14+
public float? TopP { get; init; }
15+
public int? NumCtx { get; init; }
16+
public int? NumGpu { get; init; }
1717
public Grammar? Grammar { get; set; }
1818
}

src/MaIN.Domain/Configuration/BackendInferenceParams/OpenAiInferenceParams.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ public class OpenAiInferenceParams : IBackendInferenceParams
88
{
99
public BackendType Backend => BackendType.OpenAi;
1010

11-
public float Temperature { get; init; } = 0.7f;
12-
public int MaxTokens { get; init; } = 4096;
13-
public float TopP { get; init; } = 1.0f;
14-
public float FrequencyPenalty { get; init; }
15-
public float PresencePenalty { get; init; }
11+
public float? Temperature { get; init; }
12+
public int? MaxTokens { get; init; }
13+
public float? TopP { get; init; }
14+
public float? FrequencyPenalty { get; init; }
15+
public float? PresencePenalty { get; init; }
1616
public string? ResponseFormat { get; init; }
1717
public Grammar? Grammar { get; set; }
1818
}

src/MaIN.Domain/Configuration/BackendInferenceParams/XaiInferenceParams.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ public class XaiInferenceParams : IBackendInferenceParams
88
{
99
public BackendType Backend => BackendType.Xai;
1010

11-
public float Temperature { get; init; } = 0.7f;
12-
public int MaxTokens { get; init; } = 4096;
13-
public float TopP { get; init; } = 1.0f;
14-
public float FrequencyPenalty { get; init; }
15-
public float PresencePenalty { get; init; }
11+
public float? Temperature { get; init; }
12+
public int? MaxTokens { get; init; }
13+
public float? TopP { get; init; }
14+
public float? FrequencyPenalty { get; init; }
15+
public float? PresencePenalty { get; init; }
1616
public Grammar? Grammar { get; set; }
1717
}

src/MaIN.Domain/Entities/Chat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public AIModel? ModelInstance
4040
public List<Message> Messages { get; set; } = [];
4141
public ChatType Type { get; set; } = ChatType.Conversation;
4242
public bool ImageGen { get; set; }
43-
public IBackendInferenceParams BackendParams { get; set; } = new LocalInferenceParams();
43+
public IBackendInferenceParams? BackendParams { get; set; }
4444
public LocalInferenceParams? LocalParams => BackendParams as LocalInferenceParams;
4545

4646
public Grammar? InferenceGrammar

src/MaIN.Services/Services/ChatService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using MaIN.Domain.Configuration;
2+
using MaIN.Domain.Configuration.BackendInferenceParams;
23
using MaIN.Domain.Entities;
34
using MaIN.Domain.Exceptions.Chats;
45
using MaIN.Domain.Models;
@@ -38,6 +39,7 @@ public async Task<ChatResult> Completions(
3839
chat.ImageGen = true;
3940
}
4041
chat.Backend ??= settings.BackendType;
42+
chat.BackendParams ??= BackendParamsFactory.Create(chat.Backend.Value);
4143

4244
chat.Messages.Where(x => x.Type == MessageType.NotSet).ToList()
4345
.ForEach(x => x.Type = chat.Backend != BackendType.Self ? MessageType.CloudLLM : MessageType.LocalLLM);

0 commit comments

Comments
 (0)