Skip to content

Commit 746644c

Browse files
committed
error is throw when invalid model type is provided
1 parent a0599b2 commit 746644c

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,7 @@ public async Task<IAgentContextExecutor> CreateAsync(bool flow = false, bool int
210210
{
211211
if (_ensureModelDownloaded && !string.IsNullOrWhiteSpace(_agent.Model))
212212
{
213-
var model = ModelRegistry.GetById(_agent.Model);
214-
if (model is LocalModel)
215-
{
216-
await AIHub.Model().EnsureDownloadedAsync(_agent.Model);
217-
}
213+
await AIHub.Model().EnsureDownloadedAsync(_agent.Model);
218214
}
219215

220216
await _agentService.CreateAgent(_agent, flow, interactiveResponse, _inferenceParams, _memoryParams, _disableCache);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public async Task<ChatResult> CompleteAsync(
216216
throw new EmptyChatException(_chat.Id);
217217
}
218218

219-
if (_ensureModelDownloaded && _chat.ModelInstance is LocalModel)
219+
if (_ensureModelDownloaded)
220220
{
221221
await AIHub.Model().EnsureDownloadedAsync(_chat.ModelId);
222222
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ public async Task<IModelContext> EnsureDownloadedAsync(string modelId, Cancellat
6262

6363
var model = ModelRegistry.GetById(modelId);
6464

65-
if (model is not LocalModel localModel || localModel.IsDownloaded(_defaultModelsPath))
65+
if (model is not LocalModel localModel)
66+
{
67+
throw new InvalidModelTypeException(nameof(LocalModel));
68+
}
69+
70+
if (localModel.IsDownloaded(_defaultModelsPath))
6671
{
6772
return this;
6873
}

0 commit comments

Comments
 (0)