SharpClaw - .NET 企业版
约 293 字小于 1 分钟
2026-03-07
基于 C# / .NET 10 生态的企业级实现,深度集成 Entity Framework Core。
核心特性
.NET 生态
- C# 10
- .NET 10
- EF Core 深度集成
- ASP.NET Core
企业级特性
- 事务支持
- 依赖注入
- 中间件
- 规范化设计
性能优化
- 异步编程
- 缓存机制
- 编译优化
- 性能监控
快速开始
安装
# .NET CLI
dotnet new install sharpclaw
dotnet new sharpclaw -n MyAgent
cd MyAgent
dotnet run配置
// Program.cs
var builder = WebApplication.CreateBuilder(args);
// 添加 Agent 服务
builder.Services.AddSharpClaw(options =>
{
options.LLMProvider = "openai";
options.ApiKey = builder.Configuration["OpenAI:ApiKey"];
});
// 添加 EF Core
builder.Services.AddDbContext<AgentDbContext>(options =>
options.UseSqlite("Data Source=agent.db"));技术架构
核心服务
// Agent 服务
public class AgentService
{
private readonly ILlmClient _llm;
private readonly AgentDbContext _db;
public async Task<string> ChatAsync(string message)
{
// 异步处理
var response = await _llm.CompleteAsync(message);
// EF Core 保存
var record = new ChatRecord { Message = message, Response = response };
_db.ChatRecords.Add(record);
await _db.SaveChangesAsync();
return response;
}
}相关链接
- GitHub: imxcstar/sharpclaw