Expand description
Structured LLM agents in Rust: JSON-schema input/output, system prompt building, optional chat
history, context providers, and optional tools. Backed by genai (e.g.
Gemini with JSON response format).
§Features
| Feature | Purpose |
|---|---|
searxng | SearXNG search tool |
calculator | Expression evaluation tool |
webpage_scraper | Fetch and simplify web pages |
§Example
use nano_agent::{
AgentConfig, BasicChatInputSchema, BasicNanoAgent, NanoAgent,
context::{ChatHistory, SystemPromptGenerator},
};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, JsonSchema)]
struct Out {
chat_message: String,
}
let mut agent = BasicNanoAgent::<BasicChatInputSchema, Out>::new(
AgentConfig::new("gemini-2.5-flash-lite")
.with_system_prompt_generator(SystemPromptGenerator::new())
.with_chat_history(ChatHistory::new()),
);
let _reply: Out = agent
.run(BasicChatInputSchema {
chat_message: "Hello".into(),
})
.await?;Re-exports§
pub use genai;
Modules§
Structs§
- Agent
Config - Agent configuration.
- Agent
Inner - Inner agent state.
- Basic
Chat Input Schema - Basic chat input schema.
- Basic
Chat Output Schema - Basic chat output schema.
- Basic
Nano Agent - Wraps
AgentInnerand implementsNanoAgentwith no extra state or hooks.
Enums§
- Agent
Error - Agent error.
Traits§
- Nano
Agent - Schema-driven chat agent: system prompt, optional history, structured I/O.