Skip to content

Commit c059cbf

Browse files
committed
praisonai Rust SDK implementation v0.1.0
1 parent 13540df commit c059cbf

File tree

29 files changed

+3658
-9
lines changed

29 files changed

+3658
-9
lines changed

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,10 @@ issue_details.json
8585

8686
*.log
8787
.internal
88-
.praisonai
88+
.praisonai
89+
90+
# Rust / Cargo
91+
target/
92+
Cargo.lock
93+
**/*.rs.bk
94+
*.pdb

src/praisonai-rust/Cargo.toml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
[workspace]
2+
resolver = "2"
3+
members = [
4+
"praisonai",
5+
"praisonai-derive",
6+
"praisonai-cli",
7+
]
8+
9+
[workspace.package]
10+
version = "0.1.0"
11+
edition = "2021"
12+
license = "MIT"
13+
authors = ["MervinPraison"]
14+
repository = "https://github.com/MervinPraison/PraisonAI"
15+
homepage = "https://docs.praison.ai"
16+
description = "High-performance, agentic AI framework for Rust"
17+
keywords = ["ai", "agents", "llm", "openai", "anthropic"]
18+
categories = ["api-bindings", "asynchronous"]
19+
20+
[workspace.dependencies]
21+
# Core async runtime
22+
tokio = { version = "1", features = ["full"] }
23+
async-trait = "0.1"
24+
futures = "0.3"
25+
26+
# Serialization
27+
serde = { version = "1", features = ["derive"] }
28+
serde_json = "1"
29+
serde_yaml = "0.9"
30+
31+
# Error handling
32+
thiserror = "2"
33+
anyhow = "1"
34+
35+
# CLI
36+
clap = { version = "4", features = ["derive"] }
37+
38+
# LLM providers (via rig-core for multi-provider support)
39+
rig-core = "0.9"
40+
41+
# HTTP client
42+
reqwest = { version = "0.12", features = ["json", "stream"] }
43+
44+
# Logging
45+
tracing = "0.1"
46+
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
47+
48+
# UUID for session/agent IDs
49+
uuid = { version = "1", features = ["v4"] }
50+
51+
# Optional: TUI
52+
ratatui = "0.29"
53+
crossterm = "0.28"
54+
55+
# Optional: MCP support
56+
# rmcp = { version = "0.12", optional = true }
57+
58+
# Testing
59+
tokio-test = "0.4"
60+
61+
# Proc macro dependencies
62+
syn = { version = "2", features = ["full", "parsing", "extra-traits"] }
63+
quote = "1"
64+
proc-macro2 = "1"
65+
66+
[profile.release]
67+
lto = true
68+
codegen-units = 1
69+
strip = true
70+
panic = "abort"
71+
72+
[profile.dev]
73+
opt-level = 0
74+
debug = true

src/praisonai-rust/FEATURE_PARITY_TRACKER.json

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,40 @@
11
{
2-
"version": "1.5.5",
2+
"version": "0.1.0",
33
"lastUpdated": "2026-02-04",
4-
"generatedBy": "praisonai._dev.parity.generator",
4+
"generatedBy": "manual",
55
"sourceOfTruth": "Python SDK (praisonaiagents)",
6-
"status": "NOT_STARTED",
6+
"status": "IN_PROGRESS",
77
"summary": {
88
"pythonCoreFeatures": 282,
9-
"rustFeatures": 0,
10-
"gapCount": 282
9+
"rustFeatures": 25,
10+
"gapCount": 257,
11+
"implementedFeatures": [
12+
"Agent",
13+
"AgentBuilder",
14+
"AgentConfig",
15+
"AgentTeam",
16+
"AgentFlow",
17+
"Tool",
18+
"ToolResult",
19+
"ToolRegistry",
20+
"#[tool] macro",
21+
"LlmProvider",
22+
"LlmConfig",
23+
"Message",
24+
"Role",
25+
"Memory",
26+
"MemoryAdapter",
27+
"ConversationHistory",
28+
"MemoryConfig",
29+
"HooksConfig",
30+
"OutputConfig",
31+
"ExecutionConfig",
32+
"Process (Sequential/Parallel/Hierarchical)",
33+
"Route",
34+
"Parallel",
35+
"Loop",
36+
"Repeat"
37+
]
1138
},
1239
"pythonCoreSDK": {
1340
"exports": [
@@ -296,8 +323,39 @@
296323
]
297324
},
298325
"rustSDK": {
299-
"path": "/home/runner/work/PraisonAI/PraisonAI/src/praisonai-rust",
300-
"exports": [],
301-
"modules": {}
326+
"path": "/Users/praison/praisonai-package/src/praisonai-rust",
327+
"crates": {
328+
"praisonai": {
329+
"modules": ["agent", "tools", "llm", "memory", "workflows", "config", "error"],
330+
"exports": [
331+
"Agent", "AgentBuilder", "AgentConfig",
332+
"Tool", "ToolResult", "ToolRegistry", "ToolDefinition",
333+
"LlmProvider", "LlmConfig", "Message", "Role", "ToolCall", "LlmResponse", "Usage", "OpenAiProvider",
334+
"Memory", "MemoryAdapter", "ConversationHistory", "InMemoryAdapter",
335+
"AgentTeam", "AgentFlow", "Process", "StepResult", "WorkflowContext", "Route", "Parallel", "Loop", "Repeat",
336+
"MemoryConfig", "HooksConfig", "OutputConfig", "ExecutionConfig",
337+
"Error", "Result"
338+
]
339+
},
340+
"praisonai-derive": {
341+
"exports": ["tool"]
342+
},
343+
"praisonai-cli": {
344+
"binary": "praisonai-rust",
345+
"commands": ["chat", "run", "prompt"]
346+
}
347+
},
348+
"examples": [
349+
"basic_agent",
350+
"with_tools",
351+
"multi_agent",
352+
"memory_example",
353+
"config_example",
354+
"workflow_patterns"
355+
],
356+
"tests": {
357+
"unit_tests": 20,
358+
"status": "all_passing"
359+
}
302360
}
303361
}

src/praisonai-rust/README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//! Basic agent example
2+
//!
3+
//! Run with: cargo run --example basic_agent
4+
5+
use praisonai::Agent;
6+
7+
#[tokio::main]
8+
async fn main() -> anyhow::Result<()> {
9+
// Create a simple agent
10+
let agent = Agent::new()
11+
.name("assistant")
12+
.instructions("You are a helpful AI assistant. Be concise and friendly.")
13+
.model("gpt-4o-mini")
14+
.build()?;
15+
16+
println!("Agent created: {}", agent.name());
17+
println!("Model: {}", agent.model());
18+
19+
let response = agent.chat("What is 2 + 2?").await?;
20+
println!("Response: {}", response);
21+
22+
Ok(())
23+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
//! Configuration options example
2+
//!
3+
//! Run with: cargo run -p praisonai --example config_example
4+
5+
use praisonai::{Agent, OutputConfig, ExecutionConfig, MemoryConfig};
6+
7+
#[tokio::main]
8+
async fn main() -> anyhow::Result<()> {
9+
println!("=== PraisonAI Configuration Examples ===\n");
10+
11+
// 1. Output Configuration
12+
println!("1. Output Configuration:");
13+
let output_silent = OutputConfig::new().silent();
14+
let output_verbose = OutputConfig::new().verbose();
15+
let output_json = OutputConfig::new().json().file("output.json");
16+
17+
println!(" - Silent mode: {}", output_silent.mode);
18+
println!(" - Verbose mode: {}", output_verbose.mode);
19+
println!(" - JSON mode: {}, file: {:?}", output_json.mode, output_json.file);
20+
21+
// 2. Execution Configuration
22+
println!("\n2. Execution Configuration:");
23+
let exec_config = ExecutionConfig::new()
24+
.max_iterations(5)
25+
.timeout(60)
26+
.no_stream();
27+
28+
println!(" - Max iterations: {}", exec_config.max_iterations);
29+
println!(" - Timeout: {} seconds", exec_config.timeout_secs);
30+
println!(" - Streaming: {}", exec_config.stream);
31+
32+
// 3. Memory Configuration
33+
println!("\n3. Memory Configuration:");
34+
let mem_config = MemoryConfig::new()
35+
.with_long_term()
36+
.provider("sqlite")
37+
.max_messages(100);
38+
39+
println!(" - Short-term: {}", mem_config.use_short_term);
40+
println!(" - Long-term: {}", mem_config.use_long_term);
41+
println!(" - Provider: {}", mem_config.provider);
42+
println!(" - Max messages: {}", mem_config.max_messages);
43+
44+
// 4. Agent with all configurations
45+
println!("\n4. Creating Agent with Custom Config:");
46+
let agent = Agent::new()
47+
.name("configured-agent")
48+
.instructions("You are a configured assistant.")
49+
.model("gpt-4o-mini")
50+
.temperature(0.5)
51+
.max_tokens(1000)
52+
.max_iterations(3)
53+
.verbose(true)
54+
.stream(false)
55+
.memory_config(MemoryConfig::new().max_messages(20))
56+
.build()?;
57+
58+
println!(" - Name: {}", agent.name());
59+
println!(" - Model: {}", agent.model());
60+
println!(" - Agent ID: {}", agent.id());
61+
62+
println!("\n=== All configurations demonstrated successfully! ===");
63+
64+
Ok(())
65+
}

0 commit comments

Comments
 (0)