Skip to content

Commit af17c31

Browse files
committed
fix: Use model backend when creating BackendParams
Assign the backend from the chat model before creating BackendParams and use it to initialize BackendParams and to set message types. This ensures message Type mapping is based on model.Backend (and avoids relying on BackendParams.Backend prior to initialization), clarifying initialization order and avoiding potential mismatches.
1 parent cec95a6 commit af17c31

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/MaIN.Services/Services/ChatService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public async Task<ChatResult> Completions(
4444
throw new ChatModelNotAvailableException(chat.Id, chat.ModelId);
4545
}
4646

47-
chat.BackendParams ??= BackendParamsFactory.Create(model!.Backend);
48-
var backend = chat.BackendParams.Backend;
47+
var backend = model!.Backend;
48+
chat.BackendParams ??= BackendParamsFactory.Create(backend);
4949

5050
chat.Messages.Where(x => x.Type == MessageType.NotSet).ToList()
5151
.ForEach(x => x.Type = backend != BackendType.Self ? MessageType.CloudLLM : MessageType.LocalLLM);

0 commit comments

Comments
 (0)