本项目是一个使用微软语义内核(Semantic Kernel)与OpenAI以及官方C# SDK实现模型上下文协议的示例。通过该示例,你可以参考模型上下文协议的具体实现,其官方仓库链接为:https://github.com/modelcontextprotocol/csharp-sdk
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"OpenAI": {
"ApiKey": "" ,
"ChatModelId" : "gpt-4o-mini"
}
}
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"EmailSettings": {
"SMTPServer": {
"MailPort": "465",
"MailServer": "" ,
"Sender": "" ,
"SenderName": "" ,
"Password": "" ,
"Username": ""
}
}
}
可以使用Postman等工具发送请求。
示例请求:
POST https://localhost:7113/chat
Body内容:{ "text": "发一封邮件给aFriend,告诉他你是一个AI,并用250字说明你是如何使用C#实现的。"}
将"aFriend"替换为在EmailTool类中的emails字典中已添加的一个名称。
private static readonly Dictionary<string, string> emails = new Dictionary<string, string>
{
{ "example", "mail@example.com" },
{ "aFriend", "friendEmail@gmail.com" }
};
此项目使用MIT许可证。