Rust API Reference
Version: 0.1.5
ReasonKit Core provides a high-performance, async-first Rust API for building reasoning-enhanced applications.
Core Components
ProtocolExecutor
The primary engine for executing ThinkTools.
use reasonkit_core::thinktool::{ProtocolExecutor, ProtocolInput};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Initialize executor (auto-detects LLM provider)
let executor = ProtocolExecutor::new()?;
// Execute a protocol
let result = executor.execute(
"gigathink",
ProtocolInput::query("What factors drive startup success?")
).await?;
println!("Confidence: {:.2}", result.confidence);
Ok(())
}
ReasoningLoop
A high-level orchestration engine that manages streaming, memory context, and multi-step reasoning chains.
#![allow(unused)]
fn main() {
use reasonkit_core::engine::{ReasoningLoop, ReasoningConfig, StreamHandle};
let config = ReasoningConfig::default();
let mut engine = ReasoningLoop::new(config).await?;
// Start a reasoning session
let mut stream = engine.think("Should we pivot our strategy?").await?;
// Process streaming events
while let Some(event) = stream.next().await {
match event {
StreamHandle::Token(t) => print!("{}", t),
StreamHandle::ToolStart(tool) => println!("\n[Starting {}...]", tool),
StreamHandle::Result(output) => println!("\nFinal Confidence: {}", output.confidence),
_ => {}
}
}
}
ThinkTools
The core reasoning protocols available via ProtocolExecutor:
| Tool ID | Name | Purpose |
|---|---|---|
gigathink | GigaThink | Generates 10+ diverse perspectives for creative problem solving. |
laserlogic | LaserLogic | Validates logical consistency and detects fallacies. |
bedrock | BedRock | Decomposes complex claims into first principles. |
proofguard | ProofGuard | Triangulates claims against 3+ independent sources. |
brutalhonesty | BrutalHonesty | Adversarial self-critique to find blind spots. |
Data Structures
Document
The fundamental unit of knowledge for RAG and memory operations.
#![allow(unused)]
fn main() {
use reasonkit_core::{Document, DocumentType, Source, SourceType};
let doc = Document::new(
DocumentType::Paper,
Source {
source_type: SourceType::Arxiv,
url: Some("https://arxiv.org/abs/2301...".into()),
..Default::default()
}
).with_content("Paper abstract...");
}
ProtocolInput
Builder for passing data to ThinkTools.
#![allow(unused)]
fn main() {
// Simple query
let input = ProtocolInput::query("Analyze this");
// With context
let input = ProtocolInput::query("Analyze this")
.with_field("context", "Previous results...");
// Specialized inputs
let claim = ProtocolInput::claim("Earth is flat");
let argument = ProtocolInput::argument("If A then B...");
}
Feature Flags
Enable optional capabilities in your Cargo.toml:
[dependencies]
reasonkit-core = { version = "0.1.5", features = ["memory", "vibe"] }
memory: Enable vector database integration (reasonkit-mem).vibe: Enable VIBE protocol validation system.aesthetic: Enable UI/UX assessment capabilities.code-intelligence: Enable multi-language code analysis.arf: Enable Autonomous Reasoning Framework.
Error Handling
All public APIs return reasonkit_core::error::Result<T>.
#![allow(unused)]
fn main() {
match executor.execute("unknown_tool", input).await {
Ok(output) => println!("Success"),
Err(reasonkit_core::error::Error::NotFound { resource }) => {
println!("Tool not found: {}", resource);
}
Err(e) => println!("Error: {}", e),
}
}