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/Llm/LlmModelRegistry.cs |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/Moli.Desktop/Llm/LlmModelRegistry.cs b/src/Moli.Desktop/Llm/LlmModelRegistry.cs
index ca8ee57..e808a8d 100644
--- a/src/Moli.Desktop/Llm/LlmModelRegistry.cs
+++ b/src/Moli.Desktop/Llm/LlmModelRegistry.cs
@@ -109,7 +109,11 @@
             }
 
             seen.Add(model.Id);
-            normalized.Add(model);
+            normalized.Add(model with
+            {
+                BaseUrl = model.GetBaseUrl(),
+                Endpoint = null
+            });
         }
 
         var defaultModel = normalized.Any(model =>
@@ -145,10 +149,9 @@
             return false;
         }
 
-        if (!Uri.TryCreate(model.Endpoint, UriKind.Absolute, out var endpoint) ||
-            endpoint.Scheme is not ("http" or "https"))
+        if (!LlmOpenAiUrls.IsAbsoluteHttpUrl(model.GetBaseUrl()))
         {
-            RecordInvalid(model.Id, "Model endpoint must be an absolute HTTP or HTTPS URL.");
+            RecordInvalid(model.Id, "Model baseUrl must be an absolute HTTP or HTTPS URL.");
             return false;
         }
 
@@ -180,7 +183,7 @@
                 Id = "local-openai-compatible",
                 Label = "Local",
                 Provider = "openai-compatible",
-                Endpoint = "http://127.0.0.1:11434/v1/chat/completions",
+                BaseUrl = "http://127.0.0.1:11434/v1",
                 AuthRef = null,
                 ApiModel = "qwen2.5:14b",
                 SupportsStreaming = true,

--
Gitblit v1.9.1