修复回答状态显示异常问题

This commit is contained in:
PeterZhong 2025-06-08 15:48:41 +08:00
parent d0b6671cce
commit 9b600174e8
2 changed files with 23 additions and 12 deletions

View File

@ -268,7 +268,7 @@ public class Gateway
while (goOn)
{
loop++;
if (loop > 20)
if (loop > 500)
{
MessageBox.Show("达到最大循环次数", "退出循环");
break;
@ -277,8 +277,9 @@ public class Gateway
{
Model = model,
Messages = messages,
Temperature = 0.7,
TopP = 1,
Temperature = 0.3,
TopP = 0.4,
TopK = 7,
MaxTokens = 1000,
};
long timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
@ -317,7 +318,6 @@ public class Gateway
callback?.Invoke(endMessageListItem2);
break;
}
try
{
string chunk = llmStreamChat.Choices[0].Delta.Content;
@ -529,11 +529,16 @@ public class Gateway
var task = method.Invoke(null, args) as Task<JsonRpcResultEntity>;
JsonRpcResultEntity innerResult = await task;
string displayToolName = toolName;
if (displayToolName == "ArcGisProTool")
{
displayToolName = "【GP】"+toolParams["toolName"].ToString();
}
if (innerResult is JsonRpcErrorEntity)
{
MessageListItem toolMessageItem = new ToolMessageItem
{
toolName = toolName,
toolName = displayToolName,
toolParams = toolParams,
type = MessageType.TOOL_MESSAGE,
status = "fail",
@ -556,7 +561,7 @@ public class Gateway
{
MessageListItem toolMessageItem = new ToolMessageItem
{
toolName = toolName,
toolName = displayToolName,
toolParams = toolParams,
type = MessageType.TOOL_MESSAGE,
status = "success",
@ -631,8 +636,10 @@ public class Gateway
private static async Task<string> GetToolInfos(McpServerList mcpServerList)
{
StringBuilder toolInfos = new StringBuilder();
int i = 0;
foreach (McpServer mcpServer in mcpServerList.GetAllServers())
{
i++;
try
{
if (mcpServer is InnerMcpServer)
@ -708,6 +715,7 @@ public class Gateway
}catch (Exception e)
{
log.Error(e.Message);
MessageBox.Show(e.Message, $"第{i}MCP读取错误");
}
}
@ -723,6 +731,7 @@ public class Gateway
catch (Exception e)
{
log.Error(e.Message);
MessageBox.Show(e.Message, $"{userPrompt.Name}提示词读取错误");
}
}
return toolInfos.ToString();

View File

@ -178,6 +178,10 @@ namespace LinkToolAddin.ui.dockpane
//不存在该消息需添加到ListView中
if (msg.content == "")
{
if (msg.type == MessageType.END_TAG)
{
StatusTextBlock.Text = "";
}
return;
}
idList.Add(msgId);
@ -212,9 +216,6 @@ namespace LinkToolAddin.ui.dockpane
borderItemsDict[msgId] = border;
ChatHistoryStackPanel.Children.Add(border);
StatusTextBlock.Text = "回答生成中";
}else if (msg.type == MessageType.END_TAG)
{
StatusTextBlock.Text = "";
}
}
}
@ -224,6 +225,10 @@ namespace LinkToolAddin.ui.dockpane
messageDict[msgId] = msg;
if (msg.content == "")
{
if (msg.type == MessageType.END_TAG)
{
StatusTextBlock.Text = "";
}
ChatHistoryStackPanel.Children.Remove(borderItemsDict[msgId]);
borderItemsDict.TryRemove(msgId, out Border border);
messageDict.TryRemove(msgId, out MessageListItem tempMsg);
@ -263,9 +268,6 @@ namespace LinkToolAddin.ui.dockpane
TextBox textBox = grid.Children[1] as TextBox;
textBox.Text = msg.content;
StatusTextBlock.Text = "回答生成中";
}else if (msg.type == MessageType.END_TAG)
{
StatusTextBlock.Text = "";
}
}
}