From 9b5711d3124622b1f1b18500d442c76492da877a Mon Sep 17 00:00:00 2001
From: chunhualin1 <chunhualin1@lenovo.com>
Date: 星期一, 17 八月 2026 16:52:33 +0800
Subject: [PATCH] 优化llm插件及bug修复
---
src/Moli.Desktop.Tests/Llm/LlmModelRegistryTests.cs | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/src/Moli.Desktop.Tests/Llm/LlmModelRegistryTests.cs b/src/Moli.Desktop.Tests/Llm/LlmModelRegistryTests.cs
index 03c53b1..018232b 100644
--- a/src/Moli.Desktop.Tests/Llm/LlmModelRegistryTests.cs
+++ b/src/Moli.Desktop.Tests/Llm/LlmModelRegistryTests.cs
@@ -15,7 +15,13 @@
var document = await registry.LoadAsync();
Assert.Equal(1, document.SchemaVersion);
+ var model = Assert.Single(document.Models);
+ Assert.Equal("http://127.0.0.1:11434/v1", model.BaseUrl);
+ Assert.Null(model.Endpoint);
Assert.True(File.Exists(Path.Combine(paths.ConfigDirectory, LlmModelRegistry.FileName)));
+ var saved = await File.ReadAllTextAsync(Path.Combine(paths.ConfigDirectory, LlmModelRegistry.FileName));
+ Assert.Contains("baseUrl", saved, StringComparison.Ordinal);
+ Assert.DoesNotContain("chat/completions", saved, StringComparison.Ordinal);
}
[Fact]
@@ -64,6 +70,44 @@
}
[Fact]
+ public async Task LoadAsync_AcceptsBaseUrlAndLegacyChatEndpoint()
+ {
+ var (registry, paths, _) = CreateRegistry();
+ Directory.CreateDirectory(paths.ConfigDirectory);
+ await File.WriteAllTextAsync(Path.Combine(paths.ConfigDirectory, LlmModelRegistry.FileName), """
+ {
+ "schemaVersion": 1,
+ "defaultModel": "from-base",
+ "models": [
+ {
+ "id": "from-base",
+ "label": "Base",
+ "provider": "openai-compatible",
+ "baseUrl": "https://api.deepseek.com",
+ "apiModel": "deepseek-v4-flash",
+ "enabled": true
+ },
+ {
+ "id": "from-endpoint",
+ "label": "Legacy",
+ "provider": "openai-compatible",
+ "endpoint": "http://127.0.0.1:11434/v1/chat/completions",
+ "apiModel": "qwen2.5:14b",
+ "enabled": true
+ }
+ ]
+ }
+ """);
+
+ var document = await registry.LoadAsync();
+
+ Assert.Equal(2, document.Models.Count);
+ Assert.Equal("https://api.deepseek.com", document.Models[0].BaseUrl);
+ Assert.Equal("http://127.0.0.1:11434/v1", document.Models[1].BaseUrl);
+ Assert.All(document.Models, model => Assert.Null(model.Endpoint));
+ }
+
+ [Fact]
public async Task LoadAsync_BacksUpInvalidJsonAndRecovers()
{
var (registry, paths, diagnostics) = CreateRegistry();
--
Gitblit v1.9.1