修复个别MCP失败导致对话失败的问题
This commit is contained in:
parent
9b1f479425
commit
157eb29a82
@ -239,8 +239,8 @@ public class Gateway
|
|||||||
public static async void SendMessageStream(string message, string model, string gdbPath, Action<MessageListItem> callback)
|
public static async void SendMessageStream(string message, string model, string gdbPath, Action<MessageListItem> callback)
|
||||||
{
|
{
|
||||||
Llm modelObj = new Bailian();
|
Llm modelObj = new Bailian();
|
||||||
List<string> bailianModels = [];
|
List<string> 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<string> dmxModels = ["gpt-4o","claude-sonnet-4-20250514-thinking","claude-sonnet-4-20250514","grok-3-reasoner","gemini-2.5-pro"];
|
List<string> 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))
|
if (bailianModels.Contains(model))
|
||||||
{
|
{
|
||||||
modelObj = new Bailian
|
modelObj = new Bailian
|
||||||
@ -312,6 +312,7 @@ public class Gateway
|
|||||||
// MessageBox.Show(ex.Message,"获取MCP列表失败");
|
// MessageBox.Show(ex.Message,"获取MCP列表失败");
|
||||||
}
|
}
|
||||||
goOn = true;
|
goOn = true;
|
||||||
|
long accTokens = 0;
|
||||||
string toolPattern = "<tool_use>([\\s\\S]*?)<name>([\\s\\S]*?)<\\/name>([\\s\\S]*?)<arguments>([\\s\\S]*?)<\\/arguments>([\\s\\S]*?)<\\/tool_use>";
|
string toolPattern = "<tool_use>([\\s\\S]*?)<name>([\\s\\S]*?)<\\/name>([\\s\\S]*?)<arguments>([\\s\\S]*?)<\\/arguments>([\\s\\S]*?)<\\/tool_use>";
|
||||||
string promptPattern = "<prompt>([\\s\\S]*?)<name>([\\s\\S]*?)<\\/name>([\\s\\S]*?)<arguments>([\\s\\S]*?)<\\/arguments>([\\s\\S]*?)<\\/prompt>";
|
string promptPattern = "<prompt>([\\s\\S]*?)<name>([\\s\\S]*?)<\\/name>([\\s\\S]*?)<arguments>([\\s\\S]*?)<\\/arguments>([\\s\\S]*?)<\\/prompt>";
|
||||||
McpServerList mcpServerList = new McpServerList();
|
McpServerList mcpServerList = new McpServerList();
|
||||||
@ -868,7 +869,7 @@ public class Gateway
|
|||||||
{
|
{
|
||||||
log.Error(e.Message);
|
log.Error(e.Message);
|
||||||
failedMcp.Add(i);
|
failedMcp.Add(i);
|
||||||
failedMcpString.Add(mcpServerList.GetAllServerNames()[i]);
|
failedMcpString.Add(mcpServerList.GetAllServerNames()[i-1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -49,41 +49,41 @@ public class McpServerList
|
|||||||
"F:\\secondsemester\\linktool\\test\\LinkTool0607\\LinkTool0607.gdb"
|
"F:\\secondsemester\\linktool\\test\\LinkTool0607\\LinkTool0607.gdb"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
servers.Add("fetch", new StdioMcpServer()
|
// servers.Add("fetch", new StdioMcpServer()
|
||||||
{
|
// {
|
||||||
Name = "fetch",
|
// Name = "fetch",
|
||||||
Type = "stdio",
|
// Type = "stdio",
|
||||||
Command = "uvx",
|
// Command = "uvx",
|
||||||
Args = new List<string>()
|
// Args = new List<string>()
|
||||||
{
|
// {
|
||||||
"mcp-server-fetch"
|
// "mcp-server-fetch"
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
servers.Add("bing-search", new StdioMcpServer()
|
// servers.Add("bing-search", new StdioMcpServer()
|
||||||
{
|
// {
|
||||||
Name = "bing-search",
|
// Name = "bing-search",
|
||||||
Type = "stdio",
|
// Type = "stdio",
|
||||||
Command = "npx",
|
// Command = "npx",
|
||||||
Args = new List<string>()
|
// Args = new List<string>()
|
||||||
{
|
// {
|
||||||
"bing-cn-mcp"
|
// "bing-cn-mcp"
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
servers.Add("mcp-python-interpreter", new StdioMcpServer()
|
// servers.Add("mcp-python-interpreter", new StdioMcpServer()
|
||||||
{
|
// {
|
||||||
Name = "mcp-python-interpreter",
|
// Name = "mcp-python-interpreter",
|
||||||
Type = "stdio",
|
// Type = "stdio",
|
||||||
Command = "uvx",
|
// Command = "uvx",
|
||||||
Args = new List<string>()
|
// Args = new List<string>()
|
||||||
{
|
// {
|
||||||
"--native-tls",
|
// "--native-tls",
|
||||||
"mcp-python-interpreter",
|
// "mcp-python-interpreter",
|
||||||
"--dir",
|
// "--dir",
|
||||||
"F:\\secondsemester\\linktool\\test\\LinkTool0607\\LinkTool0607.gdb",
|
// "F:\\secondsemester\\linktool\\test\\LinkTool0607\\LinkTool0607.gdb",
|
||||||
"--python-path",
|
// "--python-path",
|
||||||
"C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\custom\\python.exe"
|
// "C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\custom\\python.exe"
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
public McpServerList(string json)
|
public McpServerList(string json)
|
||||||
|
|||||||
@ -48,7 +48,7 @@
|
|||||||
<ComboBoxItem Content="deepseek-r1-distill-llama-70b" />
|
<ComboBoxItem Content="deepseek-r1-distill-llama-70b" />
|
||||||
<ComboBoxItem Content="deepseek-v3" />
|
<ComboBoxItem Content="deepseek-v3" />
|
||||||
<Separator></Separator>
|
<Separator></Separator>
|
||||||
<ComboBoxItem Content="gpt-4o" />
|
<ComboBoxItem Content="o4-mini" />
|
||||||
<ComboBoxItem Content="claude-sonnet-4-20250514-thinking" />
|
<ComboBoxItem Content="claude-sonnet-4-20250514-thinking" />
|
||||||
<ComboBoxItem Content="claude-sonnet-4-20250514" />
|
<ComboBoxItem Content="claude-sonnet-4-20250514" />
|
||||||
<ComboBoxItem Content="grok-3-reasoner" />
|
<ComboBoxItem Content="grok-3-reasoner" />
|
||||||
|
|||||||
@ -6,4 +6,6 @@ public class ChatMessageItem : MessageListItem
|
|||||||
public string role { get; set; }
|
public string role { get; set; }
|
||||||
public string content { get; set; }
|
public string content { get; set; }
|
||||||
public MessageType type { get; set; }
|
public MessageType type { get; set; }
|
||||||
|
|
||||||
|
public long accumulateTokens { get; set; }
|
||||||
}
|
}
|
||||||
@ -16,4 +16,5 @@ public interface MessageListItem
|
|||||||
string role { get; set; }
|
string role { get; set; }
|
||||||
string content { get; set; }
|
string content { get; set; }
|
||||||
MessageType type { get; set; }
|
MessageType type { get; set; }
|
||||||
|
long accumulateTokens { get; set; }
|
||||||
}
|
}
|
||||||
@ -12,4 +12,6 @@ public class ToolMessageItem : MessageListItem
|
|||||||
public MessageType type { get; set; }
|
public MessageType type { get; set; }
|
||||||
public string status { get; set; }
|
public string status { get; set; }
|
||||||
public string result { get; set; }
|
public string result { get; set; }
|
||||||
|
|
||||||
|
public long accumulateTokens { get; set; }
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user