feat: 新增agent接口

This commit is contained in:
chenchun
2025-12-23 17:08:42 +08:00
parent 3c3e134d2b
commit ec4fdc39fe
5 changed files with 83 additions and 316 deletions

View File

@@ -145,21 +145,14 @@ public class AiChatService : ApplicationService
}
}
// 判断是否有工具调用
if (input.Tools != null && input.Tools.Count > 0)
{
// 使用 ChatManager 处理支持工具调用的对话
await _chatManager.CompleteChatWithToolsAsync(_httpContextAccessor.HttpContext, input,
CurrentUser.Id, sessionId, null, cancellationToken);
}
else
{
// 使用原来的 AiGateWayManager 处理普通对话
await _aiGateWayManager.CompleteChatStreamForStatisticsAsync(_httpContextAccessor.HttpContext, input,
CurrentUser.Id, sessionId, null, cancellationToken);
}
// 使用 ChatManager
}
[HttpPost("ai-chat/agent/send")]
public async Task PostAgentSendAsync()
{
await _chatManager.CompleteChatStreamAsync();
}
/// <summary>
/// 发送消息
@@ -215,7 +208,9 @@ public class AiChatService : ApplicationService
mcpTools.add(McpServerTool.Create(toolMethod, instance));
}
}
var json = System.Text.Json.JsonSerializer.Serialize(mcpTools.Select(x=>x.ProtocolTool).ToList(),McpJsonUtilities.DefaultOptions);
var json = System.Text.Json.JsonSerializer.Serialize(mcpTools.Select(x => x.ProtocolTool).ToList(),
McpJsonUtilities.DefaultOptions);
return json;
}
}