|
2 | 2 | <img width="768" alt="logo" src="https://github.com/user-attachments/assets/bdb80520-216e-4742-b016-b71ca6eaac03" /> |
3 | 3 |
|
4 | 4 | # DSRs |
5 | | -<em>A DSPy rewrite(not a port) with Rust in mind.</em> |
| 5 | +<em>A high-performance DSPy rewrite in Rust for building LLM-powered applications</em> |
| 6 | + |
| 7 | +[](LICENSE) |
| 8 | +[](https://www.rust-lang.org) |
| 9 | +[](#) |
| 10 | + |
6 | 11 | </div> |
7 | 12 |
|
8 | | -## Project Status |
| 13 | +--- |
| 14 | + |
| 15 | +## 🚀 Overview |
| 16 | + |
| 17 | +**DSRs** (DSPy Rust) is a ground-up rewrite of the DSPy framework in Rust, designed for building robust, high-performance applications powered by Language Models. Unlike a simple port, DSRs leverages Rust's type system, memory safety, and concurrency features to provide a more efficient and reliable foundation for LLM applications. |
| 18 | + |
| 19 | +## 📦 Installation |
| 20 | + |
| 21 | +Add DSRs to your `Cargo.toml`: |
| 22 | + |
| 23 | +```toml |
| 24 | +[dependencies] |
| 25 | +dsrs = "0.0.1b" |
| 26 | +``` |
| 27 | + |
| 28 | +Or use cargo: |
| 29 | + |
| 30 | +```bash |
| 31 | +cargo add dsrs |
| 32 | +``` |
| 33 | + |
| 34 | +## 🔧 Quick Start |
| 35 | + |
| 36 | +Here's a simple example to get you started: |
| 37 | + |
| 38 | +```rust |
| 39 | +use dsrs::prelude::*; |
| 40 | +use std::collections::HashMap; |
| 41 | +use indexmap::IndexMap; |
| 42 | + |
| 43 | +#[tokio::main] |
| 44 | +async fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 45 | + // Define a signature for Q&A |
| 46 | + let signature = Signature::builder() |
| 47 | + .name("QASignature".to_string()) |
| 48 | + .instruction("Answer the question concisely and accurately.".to_string()) |
| 49 | + .input_fields(IndexMap::from([( |
| 50 | + "question".to_string(), |
| 51 | + Field::InputField { |
| 52 | + prefix: "Question:".to_string(), |
| 53 | + desc: "The question to answer".to_string(), |
| 54 | + format: None, |
| 55 | + output_type: "String".to_string(), |
| 56 | + }, |
| 57 | + )])) |
| 58 | + .output_fields(IndexMap::from([( |
| 59 | + "answer".to_string(), |
| 60 | + Field::OutputField { |
| 61 | + prefix: "Answer:".to_string(), |
| 62 | + desc: "The answer to the question".to_string(), |
| 63 | + format: None, |
| 64 | + output_type: "String".to_string(), |
| 65 | + }, |
| 66 | + )])) |
| 67 | + .build()?; |
| 68 | + |
| 69 | + // Create a predictor |
| 70 | + let predictor = Predict { |
| 71 | + signature: &signature |
| 72 | + }; |
| 73 | + |
| 74 | + // Prepare input |
| 75 | + let inputs = HashMap::from([ |
| 76 | + ("question".to_string(), "What is the capital of France?".to_string()) |
| 77 | + ]); |
| 78 | + |
| 79 | + // Execute prediction |
| 80 | + let result = predictor.forward(inputs, None, None).await?; |
| 81 | + |
| 82 | + println!("Answer: {}", result.get("answer", None)); |
9 | 83 |
|
10 | | -⚠️ **This project is in early development** ⚠️ |
| 84 | + Ok(()) |
| 85 | +} |
| 86 | +``` |
11 | 87 |
|
12 | | -## TODOs for v0 |
| 88 | +## 🧪 Testing |
| 89 | + |
| 90 | +Run the test suite: |
| 91 | + |
| 92 | +```bash |
| 93 | +# All tests |
| 94 | +cargo test |
| 95 | + |
| 96 | +# Specific test |
| 97 | +cargo test test_predictors |
| 98 | + |
| 99 | +# With output |
| 100 | +cargo test -- --nocapture |
| 101 | +``` |
| 102 | + |
| 103 | +--- |
| 104 | + |
| 105 | +## 📈 Project Status |
| 106 | + |
| 107 | +⚠️ **Early Development** - DSRs is actively being developed. The API may change between versions. |
13 | 108 |
|
14 | 109 | ### Core Framework |
15 | 110 | - [x] Implement core DSPy abstractions |
|
36 | 131 | - [ ] Implement zero-copy parsing where possible[optim clean up] |
37 | 132 | - [x] Rayon dependency added for parallel execution |
38 | 133 | - [ ] Batch processing for LM calls |
| 134 | + |
| 135 | +## 📄 License |
| 136 | + |
| 137 | +This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details. |
| 138 | + |
| 139 | +## 🙏 Acknowledgments |
| 140 | + |
| 141 | +- Inspired by the original [DSPy](https://github.com/stanfordnlp/dspy) framework |
| 142 | +- Built with the amazing Rust ecosystem |
| 143 | + |
| 144 | +<div align="center"> |
| 145 | + |
| 146 | +**[Documentation](https://docs.rs/dsrs) • [Examples](examples/) • [Issues](https://github.com/yourusername/dsrs/issues) • [Discussions](https://github.com/yourusername/dsrs/discussions)** |
| 147 | + |
| 148 | +</div> |
0 commit comments