herolib-ai 0.3.13

AI client with multi-provider support (Groq, OpenRouter, SambaNova) and automatic failover
Documentation
//! herolib-ai: AI client with multi-provider support.
//!
//! This crate provides a unified AI client that supports multiple providers
//! (Groq, OpenRouter, SambaNova) with automatic failover and verification support.
//!
//! # Features
//!
//! - **Multi-provider support**: Automatically tries providers in order of preference
//! - **OpenAI-compatible API**: Works with any OpenAI-compatible endpoint
//! - **Automatic failover**: Falls back to alternative providers on failure
//! - **Verification support**: Retry with feedback until response passes validation
//! - **Model abstraction**: Use our model names, mapped to provider-specific IDs
//!
//! # Example
//!
//! ```no_run
//! use herolib_ai::{AiClient, Model, PromptBuilderExt};
//!
//! // Create client from environment variables
//! let client = AiClient::from_env();
//!
//! // Simple chat
//! let response = client
//!     .prompt()
//!     .model(Model::Llama3_3_70B)
//!     .system("You are a helpful coding assistant")
//!     .user("Write a hello world in Rust")
//!     .execute_content()
//!     .unwrap();
//!
//! println!("{}", response);
//! ```
//!
//! # Verification Example
//!
//! ```no_run
//! use herolib_ai::{AiClient, Model, PromptBuilderExt};
//!
//! let client = AiClient::from_env();
//!
//! let response = client
//!     .prompt()
//!     .model(Model::Qwen2_5Coder32B)
//!     .system("You are a JSON generator. Only output valid JSON.")
//!     .user("Generate a JSON object with name and age fields")
//!     .verify(|content| {
//!         // Verify the response is valid JSON
//!         match serde_json::from_str::<serde_json::Value>(content) {
//!             Ok(_) => Ok(()),
//!             Err(e) => Err(format!("Invalid JSON: {}. Please output only valid JSON.", e)),
//!         }
//!     })
//!     .max_retries(3)
//!     .execute_verified()
//!     .unwrap();
//! ```
//!
//! # Environment Variables
//!
//! Set API keys using environment variables:
//! - `GROQ_API_KEY` - Groq API key
//! - `OPENROUTER_API_KEY` - OpenRouter API key
//! - `SAMBANOVA_API_KEY` - SambaNova API key

pub mod client;
pub mod embedding;
pub mod error;
pub mod model;
pub mod prompt;
pub mod provider;
pub mod transcription;
pub mod types;

#[cfg(feature = "rhai")]
pub mod rhai;

// Re-export commonly used types
pub use client::{AiClient, chat_simple};
pub use embedding::{EmbeddingModel, EmbeddingRequest, EmbeddingResponse};
pub use error::{AiError, AiResult};
pub use model::Model;
pub use prompt::{PromptBuilder, PromptBuilderExt, VerifyFn};
pub use provider::{Provider, ProviderConfig};
pub use transcription::{
    TranscriptionModel, TranscriptionOptions, TranscriptionResponse, VerboseTranscriptionResponse,
};
pub use types::{ChatCompletionRequest, ChatCompletionResponse, Message, Role, Usage};