Expand description
agent-diva-nano — minimal “create an agent” library.
Add to your project:
[dependencies]
agent-diva-nano = "0.4.11"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }§Quick start
use agent_diva_nano::{chat, NanoConfig};
let config = NanoConfig {
model: "deepseek-chat".to_string(),
api_key: std::env::var("NANO_API_KEY")?,
..Default::default()
};
let reply = chat("What is Rust ownership?", &config).await?;
println!("{}", reply);§Stateful agent
For multi-turn conversations, use Agent directly:
use agent_diva_nano::{Agent, NanoConfig};
let config = NanoConfig {
model: "deepseek-chat".to_string(),
api_key: std::env::var("NANO_API_KEY")?,
..Default::default()
};
let mut agent = Agent::new(config).build().await?;
agent.start().await?;
let r1 = agent.send("Hello").await?;
let r2 = agent.send("Tell me more").await?;
agent.stop().await;§Flexible tool assembly
Use ToolAssembly for fine-grained control over which tools are available:
use agent_diva_nano::{AgentBuilder, ToolAssembly, BuiltInToolsConfig};
// Create agent with minimal tools (only filesystem)
let assembly = ToolAssembly::new(std::path::PathBuf::from("./workspace"))
.builtin(BuiltInToolsConfig::minimal())
.build();
// Or create agent with custom tools only
let assembly = ToolAssembly::new(std::path::PathBuf::from("./workspace"))
.builtin(BuiltInToolsConfig::none())
.with_tool(my_custom_tool);Re-exports§
pub use config::NanoConfig;pub use config::ShellToolConfig;pub use config::SoulConfig;pub use config::WebSearchConfig;pub use config::WebToolConfig;pub use agent::Agent;pub use agent::AgentBuilder;pub use agent::AgentLoopMode;pub use chat::chat;pub use chat::chat_stream;pub use error::NanoError;pub use tool_assembly::ToolAssembly;pub use nano_loop::NanoAgentLoop;pub use nano_loop::NanoLoopConfig;pub use nano_loop::NanoRuntimeControlCommand;
Modules§
- agent
- Agent creation and management for agent-diva-nano.
- chat
- config
- error
- nano_
loop - Lightweight agent loop implementation for agent-diva-nano.
- tool_
assembly - Thin wrapper around the shared agent-diva tool assembly.
Structs§
- Built
InTools Config - Re-export tool assembly types. Built-in tool toggles shared by the main agent and nano runtime.
- File
Manager - Re-export FileManager when files feature is enabled. File manager - main interface for file operations
- MCPServer
Config - Re-export MCP server configuration from the core crate. MCP server connection configuration (stdio or HTTP)
- Provider
Registry - Re-export provider registry so consumers can resolve provider names from model identifiers. Registry of available LLM providers
- Tool
Registry - Re-export tool types for custom tool creation. Registry of available tools.
Enums§
- Agent
Event - Re-export core event types so consumers don’t need to depend on
agent-diva-core. Streaming events emitted by the agent - Tool
Error - Re-export tool types for custom tool creation. Tool errors.
Traits§
- Subagent
Spawner - Tool
- Re-export tool types for custom tool creation. Trait for tools.