feat: 新增agent接口
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user