agentai/
lib.rs

1//! # AgentAI
2//!
3//! AgentAI is a Rust library designed to simplify the creation of AI agents. It leverages
4//! the [GenAI](https://crates.io/crates/genai) library to interface with a wide range of popular
5//! Large Language Models (LLMs), making it versatile and powerful. Written in Rust, AgentAI
6//! benefits from strong static typing and robust error handling, ensuring more reliable
7//! and maintainable code. Whether you're developing simple or complex AI agents, AgentAI provides
8//! a streamlined and efficient development process.
9//!
10//! ## Features
11//!
12//! - Multi LLM -- we support most of LLM API (OpenAI, Anthropic, Gemini, Ollama and all OpenAI API Compatible)
13//! - Choose correct LLM for the task -- use many smaller specialized LLMs to save costs and choose best of all the worlds
14//! - Support for MCP Server -- no need to write your own Agent Tools, you can leverage, already existing
15//!   solutions, based on Model Context Protocol
16//!
17//! > **Warning**
18//! > This library is under heavy development. The interface can change at any moment without any notice.
19//!
20//! ## Installation
21//! To start using AgentAI crate just enter in root directory for your project this command:
22//!
23//! ```bash
24//! cargo add agentai
25//! ```
26//!
27//! This will install this crate with all required dependencies.
28//!
29//! ## Feature flags
30#![doc = document_features::document_features!()]
31//!
32//! ## Usage
33//! Here is a basic example of how to create an AI agent using AgentAI:
34//! ```rust
35//! use agentai::Agent;
36//!
37//! #[tokio::main]
38//! async fn main() -> anyhow::Result<()> {
39//!     let mut agent = Agent::new("You are a useful assistant", &());
40//!     let answer: String = agent.run("gpt-4o", "Why sky is blue?").await?;
41//!     println!("Answer: {}", answer);
42//!     Ok(())
43//! }
44//! ```
45//!
46//!## Examples
47//!
48#![allow(rustdoc::redundant_explicit_links)]
49//! For more examples, check out the [examples](crate::examples) directory. You can build and run them using Cargo with the following command:
50//!
51//! ```bash
52//! cargo run --example <example_name>
53//! ```
54//!
55//! The <example_name> should match the filename of the example you want to run (without the file extension).
56//! For example, to run the example that includes the essential parts required to implement an AI agent, use:
57//!
58//! ```bash
59//! cargo run --example simple
60//! ```
61
62pub mod agent;
63pub mod tool;
64
65// This module will be enabled only when generating documentation
66#[cfg(doc)]
67pub mod examples;
68
69#[allow(unused_imports)]
70pub use agent::*;
71
72#[allow(unused_imports)]
73pub use tool::*;