From 157eb29a82d1a54eb83ff1e8175f7aabb6c56e4a Mon Sep 17 00:00:00 2001 From: PeterZhong Date: Fri, 11 Jul 2025 19:23:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=AA=E5=88=ABMCP?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E5=AF=BC=E8=87=B4=E5=AF=B9=E8=AF=9D=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- host/Gateway.cs | 7 ++-- host/McpServerList.cs | 70 ++++++++++++++++----------------- ui/dockpane/DialogDockpane.xaml | 2 +- ui/message/ChatMessageItem.cs | 2 + ui/message/MessageListItem.cs | 1 + ui/message/ToolMessageItem.cs | 2 + 6 files changed, 45 insertions(+), 39 deletions(-) diff --git a/host/Gateway.cs b/host/Gateway.cs index da3d05f..bc64a6b 100644 --- a/host/Gateway.cs +++ b/host/Gateway.cs @@ -239,8 +239,8 @@ public class Gateway public static async void SendMessageStream(string message, string model, string gdbPath, Action callback) { Llm modelObj = new Bailian(); - List bailianModels = []; - List dmxModels = ["gpt-4o","claude-sonnet-4-20250514-thinking","claude-sonnet-4-20250514","grok-3-reasoner","gemini-2.5-pro"]; + List bailianModels = ["qwen3-235b-a22b","qwen3-32b","qwq-32b","qwen-max-latest","deepseek-r1","deepseek-r1-0528","deepseek-r1-distill-qwen-32b","deepseek-r1-distill-llama-70b","deepseek-v3"]; + List dmxModels = ["gpt-4o","claude-sonnet-4-20250514-thinking","claude-sonnet-4-20250514","grok-3-reasoner","gemini-2.5-pro","o4-mini"]; if (bailianModels.Contains(model)) { modelObj = new Bailian @@ -312,6 +312,7 @@ public class Gateway // MessageBox.Show(ex.Message,"获取MCP列表失败"); } goOn = true; + long accTokens = 0; string toolPattern = "([\\s\\S]*?)([\\s\\S]*?)<\\/name>([\\s\\S]*?)([\\s\\S]*?)<\\/arguments>([\\s\\S]*?)<\\/tool_use>"; string promptPattern = "([\\s\\S]*?)([\\s\\S]*?)<\\/name>([\\s\\S]*?)([\\s\\S]*?)<\\/arguments>([\\s\\S]*?)<\\/prompt>"; McpServerList mcpServerList = new McpServerList(); @@ -868,7 +869,7 @@ public class Gateway { log.Error(e.Message); failedMcp.Add(i); - failedMcpString.Add(mcpServerList.GetAllServerNames()[i]); + failedMcpString.Add(mcpServerList.GetAllServerNames()[i-1]); } } diff --git a/host/McpServerList.cs b/host/McpServerList.cs index 497f502..0d94479 100644 --- a/host/McpServerList.cs +++ b/host/McpServerList.cs @@ -49,41 +49,41 @@ public class McpServerList "F:\\secondsemester\\linktool\\test\\LinkTool0607\\LinkTool0607.gdb" } }); - servers.Add("fetch", new StdioMcpServer() - { - Name = "fetch", - Type = "stdio", - Command = "uvx", - Args = new List() - { - "mcp-server-fetch" - } - }); - servers.Add("bing-search", new StdioMcpServer() - { - Name = "bing-search", - Type = "stdio", - Command = "npx", - Args = new List() - { - "bing-cn-mcp" - } - }); - servers.Add("mcp-python-interpreter", new StdioMcpServer() - { - Name = "mcp-python-interpreter", - Type = "stdio", - Command = "uvx", - Args = new List() - { - "--native-tls", - "mcp-python-interpreter", - "--dir", - "F:\\secondsemester\\linktool\\test\\LinkTool0607\\LinkTool0607.gdb", - "--python-path", - "C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\custom\\python.exe" - } - }); + // servers.Add("fetch", new StdioMcpServer() + // { + // Name = "fetch", + // Type = "stdio", + // Command = "uvx", + // Args = new List() + // { + // "mcp-server-fetch" + // } + // }); + // servers.Add("bing-search", new StdioMcpServer() + // { + // Name = "bing-search", + // Type = "stdio", + // Command = "npx", + // Args = new List() + // { + // "bing-cn-mcp" + // } + // }); + // servers.Add("mcp-python-interpreter", new StdioMcpServer() + // { + // Name = "mcp-python-interpreter", + // Type = "stdio", + // Command = "uvx", + // Args = new List() + // { + // "--native-tls", + // "mcp-python-interpreter", + // "--dir", + // "F:\\secondsemester\\linktool\\test\\LinkTool0607\\LinkTool0607.gdb", + // "--python-path", + // "C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\custom\\python.exe" + // } + // }); } public McpServerList(string json) diff --git a/ui/dockpane/DialogDockpane.xaml b/ui/dockpane/DialogDockpane.xaml index 08c5c6c..cf6875d 100644 --- a/ui/dockpane/DialogDockpane.xaml +++ b/ui/dockpane/DialogDockpane.xaml @@ -48,7 +48,7 @@ - + diff --git a/ui/message/ChatMessageItem.cs b/ui/message/ChatMessageItem.cs index 2c35847..6bfd55b 100644 --- a/ui/message/ChatMessageItem.cs +++ b/ui/message/ChatMessageItem.cs @@ -6,4 +6,6 @@ public class ChatMessageItem : MessageListItem public string role { get; set; } public string content { get; set; } public MessageType type { get; set; } + + public long accumulateTokens { get; set; } } \ No newline at end of file diff --git a/ui/message/MessageListItem.cs b/ui/message/MessageListItem.cs index 31610a5..32eba23 100644 --- a/ui/message/MessageListItem.cs +++ b/ui/message/MessageListItem.cs @@ -16,4 +16,5 @@ public interface MessageListItem string role { get; set; } string content { get; set; } MessageType type { get; set; } + long accumulateTokens { get; set; } } \ No newline at end of file diff --git a/ui/message/ToolMessageItem.cs b/ui/message/ToolMessageItem.cs index 211a4db..03f9492 100644 --- a/ui/message/ToolMessageItem.cs +++ b/ui/message/ToolMessageItem.cs @@ -12,4 +12,6 @@ public class ToolMessageItem : MessageListItem public MessageType type { get; set; } public string status { get; set; } public string result { get; set; } + + public long accumulateTokens { get; set; } } \ No newline at end of file