|
| 1 | +# PraisonAI Rust SDK |
| 2 | + |
| 3 | +High-performance, agentic AI framework for Rust. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +```rust |
| 8 | +use praisonai::{Agent, tool, Tool}; |
| 9 | + |
| 10 | +#[tool(description = "Search the web")] |
| 11 | +async fn search(query: String) -> String { |
| 12 | + format!("Results for: {}", query) |
| 13 | +} |
| 14 | + |
| 15 | +#[tokio::main] |
| 16 | +async fn main() -> anyhow::Result<()> { |
| 17 | + let agent = Agent::new() |
| 18 | + .instructions("You are a helpful assistant") |
| 19 | + .tool(SearchTool::new()) |
| 20 | + .build()?; |
| 21 | + |
| 22 | + let response = agent.chat("Hello!").await?; |
| 23 | + println!("{}", response); |
| 24 | + Ok(()) |
| 25 | +} |
| 26 | +``` |
| 27 | + |
| 28 | +## Installation |
| 29 | + |
| 30 | +Add to your `Cargo.toml`: |
| 31 | + |
| 32 | +```toml |
| 33 | +[dependencies] |
| 34 | +praisonai = "0.1" |
| 35 | +tokio = { version = "1", features = ["full"] } |
| 36 | +``` |
| 37 | + |
| 38 | +## CLI Usage |
| 39 | + |
| 40 | +```bash |
| 41 | +# Install CLI |
| 42 | +cargo install praisonai-cli |
| 43 | + |
| 44 | +# Interactive chat |
| 45 | +praisonai-rust chat |
| 46 | + |
| 47 | +# Single-shot prompt |
| 48 | +praisonai-rust "What is 2+2?" |
| 49 | + |
| 50 | +# Run workflow from YAML |
| 51 | +praisonai-rust run agents.yaml |
| 52 | +``` |
| 53 | + |
| 54 | +## Features |
| 55 | + |
| 56 | +- **Agent-Centric**: Every design decision centers on Agents |
| 57 | +- **Multi-Provider LLM**: OpenAI, Anthropic, Ollama support via rig-core |
| 58 | +- **Tool System**: `#[tool]` macro for easy tool creation |
| 59 | +- **Multi-Agent Workflows**: AgentTeam, AgentFlow patterns |
| 60 | +- **Memory**: Conversation history and long-term storage |
| 61 | +- **Async-First**: Built on Tokio for high performance |
| 62 | + |
| 63 | +## Crates |
| 64 | + |
| 65 | +| Crate | Description | |
| 66 | +|-------|-------------| |
| 67 | +| `praisonai` | Core library (Agent, Tools, Workflows) | |
| 68 | +| `praisonai-derive` | Proc macros (`#[tool]`) | |
| 69 | +| `praisonai-cli` | CLI binary | |
| 70 | + |
| 71 | +## API Parity with Python |
| 72 | + |
| 73 | +```python |
| 74 | +# Python |
| 75 | +from praisonaiagents import Agent, tool |
| 76 | + |
| 77 | +@tool |
| 78 | +def search(query: str) -> str: |
| 79 | + """Search the web.""" |
| 80 | + return f"Results for: {query}" |
| 81 | + |
| 82 | +agent = Agent(instructions="Be helpful", tools=[search]) |
| 83 | +response = agent.start("Hello!") |
| 84 | +``` |
| 85 | + |
| 86 | +```rust |
| 87 | +// Rust |
| 88 | +use praisonai::{Agent, tool, Tool}; |
| 89 | + |
| 90 | +#[tool(description = "Search the web")] |
| 91 | +async fn search(query: String) -> String { |
| 92 | + format!("Results for: {}", query) |
| 93 | +} |
| 94 | + |
| 95 | +let agent = Agent::new() |
| 96 | + .instructions("Be helpful") |
| 97 | + .tool(SearchTool::new()) |
| 98 | + .build()?; |
| 99 | +let response = agent.chat("Hello!").await?; |
| 100 | +``` |
| 101 | + |
| 102 | +## License |
| 103 | + |
| 104 | +MIT |
0 commit comments