|
| 1 | +# SharpAIKit |
| 2 | + |
| 3 | +A unified .NET large-model application and agentic AI development framework. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +SharpAIKit is a comprehensive AI/LLM toolkit for .NET that provides a unified interface for working with large language models, building AI agents, and implementing RAG (Retrieval-Augmented Generation) applications. It's designed to be more powerful and simpler than LangChain, with killer features that leverage the .NET ecosystem. |
| 8 | + |
| 9 | +## Key Features |
| 10 | + |
| 11 | +### Core Capabilities |
| 12 | +- **Unified LLM Interface** - One API for all OpenAI-compatible models |
| 13 | +- **LCEL-style Chains** - Elegant chain composition with pipe operators |
| 14 | +- **Multiple Memory Strategies** - Buffer, Window, Summary, Vector, and Entity memory |
| 15 | +- **Advanced Agents** - ReAct, Plan-and-Execute, and Multi-Agent systems |
| 16 | +- **RAG Engine** - Built-in document indexing and intelligent Q&A |
| 17 | +- **Full Observability** - Console, logging, metrics, and file tracing |
| 18 | + |
| 19 | +### Killer Features Beyond LangChain |
| 20 | +- **🔮 Native C# Code Interpreter** - Execute C# code directly using Roslyn, no Python needed |
| 21 | +- **🕸️ SharpGraph** - Graph-based orchestration with FSM, supports loops and complex branches |
| 22 | +- **🧬 DSPy-style Optimizer** - Automatically optimize prompts through iterative improvement |
| 23 | + |
| 24 | +## Installation |
| 25 | + |
| 26 | +```bash |
| 27 | +dotnet add package SharpAIKit |
| 28 | +``` |
| 29 | + |
| 30 | +## Quick Start |
| 31 | + |
| 32 | +```csharp |
| 33 | +using SharpAIKit.LLM; |
| 34 | + |
| 35 | +// Create a client for any OpenAI-compatible API |
| 36 | +var client = LLMClientFactory.Create( |
| 37 | + apiKey: "your-api-key", |
| 38 | + baseUrl: "https://api.deepseek.com/v1", |
| 39 | + model: "deepseek-chat" |
| 40 | +); |
| 41 | + |
| 42 | +// Simple chat |
| 43 | +var response = await client.ChatAsync("Hello!"); |
| 44 | +Console.WriteLine(response); |
| 45 | + |
| 46 | +// Streaming output |
| 47 | +await foreach (var chunk in client.ChatStreamAsync("Tell me a story")) |
| 48 | +{ |
| 49 | + Console.Write(chunk); |
| 50 | +} |
| 51 | +``` |
| 52 | + |
| 53 | +## Supported LLM Providers |
| 54 | + |
| 55 | +SharpAIKit supports all OpenAI-compatible APIs, including: |
| 56 | + |
| 57 | +- OpenAI |
| 58 | +- DeepSeek |
| 59 | +- Qwen (Alibaba) |
| 60 | +- Mistral |
| 61 | +- Yi (01.AI) |
| 62 | +- Groq |
| 63 | +- Moonshot (Kimi) |
| 64 | +- Zhipu GLM |
| 65 | +- Ollama (Local) |
| 66 | +- Any custom OpenAI-compatible endpoint |
| 67 | + |
| 68 | +## Example: Code Interpreter |
| 69 | + |
| 70 | +```csharp |
| 71 | +using SharpAIKit.CodeInterpreter; |
| 72 | + |
| 73 | +var interpreter = new RoslynCodeInterpreter(); |
| 74 | +var result = await interpreter.ExecuteAsync<double>("Math.Pow(3, 5)"); |
| 75 | +Console.WriteLine($"3^5 = {result}"); // Output: 243 |
| 76 | +``` |
| 77 | + |
| 78 | +## Example: Graph Orchestration |
| 79 | + |
| 80 | +```csharp |
| 81 | +using SharpAIKit.Graph; |
| 82 | + |
| 83 | +var graph = new SharpGraphBuilder("start") |
| 84 | + .Node("start", async state => { |
| 85 | + state.NextNode = "process"; |
| 86 | + return state; |
| 87 | + }) |
| 88 | + .Node("process", async state => { |
| 89 | + state.Output = "Done"; |
| 90 | + state.ShouldEnd = true; |
| 91 | + return state; |
| 92 | + }) |
| 93 | + .Build(); |
| 94 | + |
| 95 | +var result = await graph.ExecuteAsync(); |
| 96 | +``` |
| 97 | + |
| 98 | +## Example: Prompt Optimization |
| 99 | + |
| 100 | +```csharp |
| 101 | +using SharpAIKit.Optimizer; |
| 102 | + |
| 103 | +var optimizer = new DSPyOptimizer(client) |
| 104 | + .AddExample("What is C#?", "C# is an object-oriented programming language...") |
| 105 | + .SetMetric(Metrics.Contains); |
| 106 | + |
| 107 | +var result = await optimizer.OptimizeAsync("Answer: {input}"); |
| 108 | +Console.WriteLine(result.OptimizedPrompt); |
| 109 | +``` |
| 110 | + |
| 111 | +## Documentation |
| 112 | + |
| 113 | +For detailed documentation and examples, visit: |
| 114 | +- [GitHub Repository](https://github.com/dxpython/SharpAIKit) |
| 115 | +- [English Documentation](https://github.com/dxpython/SharpAIKit/blob/main/README_EN.md) |
| 116 | +- [中文文档](https://github.com/dxpython/SharpAIKit/blob/main/README_CN.md) |
| 117 | + |
| 118 | +## License |
| 119 | + |
| 120 | +This project is licensed under the MIT License - see the [LICENSE](https://github.com/dxpython/SharpAIKit/blob/main/LICENSE) file for details. |
| 121 | + |
0 commit comments