Skip to content

Commit 4e33b19

Browse files
authored
Enhance README with new feature descriptions
Updated features section with detailed explanations and examples.
1 parent 21be41d commit 4e33b19

File tree

1 file changed

+82
-13
lines changed

1 file changed

+82
-13
lines changed

README.md

Lines changed: 82 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,43 +74,112 @@ dotnet add package SharpAIKit
7474

7575
---
7676

77-
<div align="center">
77+
<div >
7878

7979
**⭐ Star this project if it helps you!**
8080

8181
---
8282

83-
## 🎯 Killer Features
83+
## 🎯 Killer Features Beyond LangChain
8484

8585
### 🔮 Native C# Code Interpreter
86-
Execute C# code directly using Roslyn - no Python dependency, blazing fast!
86+
**Execute C# code directly using Roslyn - no Python dependency, blazing fast!**
87+
88+
**Why it's killer:** LangChain's Code Interpreter depends on Python, deployment is troublesome and slow. SharpAIKit uses .NET's Roslyn compiler, executes in-memory, extremely fast.
8789

8890
```csharp
91+
using SharpAIKit.CodeInterpreter;
92+
8993
var interpreter = new RoslynCodeInterpreter();
94+
95+
// Math calculation
9096
var result = await interpreter.ExecuteAsync<double>("Math.Pow(3, 5)");
91-
// Result: 243
97+
Console.WriteLine($"3^5 = {result}"); // Output: 243
98+
99+
// Fibonacci sequence
100+
var fibCode = """
101+
var n = 10;
102+
var fib = new List<int> { 0, 1 };
103+
for (int i = 2; i < n; i++) {
104+
fib.Add(fib[i-1] + fib[i-2]);
105+
}
106+
string.Join(", ", fib)
107+
""";
108+
var fibResult = await interpreter.ExecuteAsync(fibCode);
109+
Console.WriteLine(fibResult.Output); // Output: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34
92110
```
93111

94112
### 🕸️ SharpGraph
95-
Graph-based orchestration with FSM - handle loops and complex workflows!
113+
**Graph-based orchestration with FSM - handle loops and complex workflows!**
114+
115+
**Why it's killer:** LangChain's Chain is linear (DAG), hard to handle loops. SharpGraph uses Finite State Machine, supports loops and complex branches.
96116

97117
```csharp
98-
var graph = new SharpGraphBuilder("start")
99-
.Node("start", async state => { ... })
100-
.Edge("start", "next", condition: state => ...)
118+
using SharpAIKit.Graph;
119+
120+
// Self-correcting loop graph: write code → run → check error → fix → run again
121+
var graph = new SharpGraphBuilder("start", maxIterations: 20)
122+
.Node("start", async state => {
123+
state.Set("attempts", 0);
124+
state.NextNode = "write_code";
125+
return state;
126+
})
127+
.Node("write_code", async state => {
128+
// Write code logic
129+
state.NextNode = "execute_code";
130+
return state;
131+
})
132+
.Node("execute_code", async state => {
133+
// Execute code, handle errors
134+
state.NextNode = "check_result";
135+
return state;
136+
})
137+
.Node("check_result", async state => {
138+
// Check if result is valid
139+
if (valid) state.ShouldEnd = true;
140+
else state.NextNode = "fix_code"; // Loop back
141+
return state;
142+
})
143+
.Node("fix_code", async state => {
144+
state.NextNode = "write_code"; // Loop back to retry
145+
return state;
146+
})
101147
.Build();
148+
149+
var result = await graph.ExecuteAsync();
102150
```
103151

104152
### 🧬 DSPy-style Optimizer
105-
Automatically optimize prompts through iterative improvement!
153+
**Automatically optimize prompts through iterative improvement!**
154+
155+
**Why it's killer:** LangChain's Prompts are hardcoded, poor effects require manual tweaking. DSPy Optimizer automatically finds the best prompt through iterations.
106156

107157
```csharp
158+
using SharpAIKit.Optimizer;
159+
108160
var optimizer = new DSPyOptimizer(client)
109-
.AddExample("input", "expected output")
110-
.SetMetric(Metrics.Contains);
111-
var result = await optimizer.OptimizeAsync("initial prompt");
161+
{
162+
MaxIterations = 10,
163+
TargetScore = 0.9
164+
};
165+
166+
// Add training examples
167+
optimizer
168+
.AddExample("What is C#?", "C# is an object-oriented programming language...")
169+
.AddExample("What is Python?", "Python is an interpreted programming language...");
170+
171+
// Set evaluation metric
172+
optimizer.SetMetric(Metrics.Contains);
173+
174+
// Optimize prompt
175+
var initialPrompt = "Answer questions about programming languages: {input}";
176+
var result = await optimizer.OptimizeAsync(initialPrompt);
177+
178+
Console.WriteLine($"Optimized: {result.OptimizedPrompt}");
179+
Console.WriteLine($"Best score: {result.BestScore:F2}");
180+
// The optimizer automatically adds few-shot examples and improves the prompt!
112181
```
113182

114-
See [中文文档](README_CN.md) for detailed examples.
183+
See [中文文档](README_CN.md) or [English Documentation](README_EN.md) for detailed examples.
115184

116185
</div>

0 commit comments

Comments
 (0)