1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/// Gemini_rs: Async Rust client for Google Gemini generative language models.
///
/// # Features
/// - Async chat with Gemini models
/// - Conversation memory (contextual chat)
/// - Simple, ergonomic API
///
/// # Example
/// ```rust
/// use Gemini_rs::Client;
/// #[tokio::main]
/// async fn main() {
/// let mut c = Client::new("your_api_key", "gemini-2.5-flash");
/// let res = c.chat("Hello my name is Max").await;
/// if let Err(e) = res {
/// panic!("{}", e);
/// }
/// let res2 = c.chat("Whats my name answer in single word only (answer containing more than 1 word will be treated as incorrect)").await;
/// let name = res2.unwrap_or_else(|_| "Error".to_string());
/// println!("Gemini answered: {}", name);
/// assert_eq!(&name, "Max");
/// }
/// ```
///
/// # API
/// ## Main Structs
/// - [`Client`]: main entry point for chat and memory
/// - [`GeminiContent`], [`GeminiPart`], [`GeminiRequest`], [`GeminiResponse`], [`Candidate`], [`Content`], [`Part`], [`SafetyRating`]
///
/// ## Client Methods
/// - `Client::new(api_key, model)` – create a new client
/// - `Client::with_config(config)` – create with custom config
/// - `client.chat(input)` – send a message, get a response (async, with memory)
/// - `client.chat_once(input)` – stateless single message (async)
/// - `client.clear_memory()` – clear conversation history
/// - `client.memory_size()` – get memory size
/// - `client.get_history()` – get conversation history
/// - `client.set_max_memory_size(size)` – set max memory size
///
/// ## Model/Response Utilities
/// - `GeminiContent::new(role, content)` – create a message
/// - `GeminiResponse::from_json(json_str)` – parse from JSON
/// - `GeminiResponse::from_value(value)` – parse from serde_json::Value
/// - `GeminiResponse::extract_text()` – get first generated text
/// - `GeminiResponse::extract_all_texts()` – get all generated texts
/// - `GeminiResponse::get_string()` – get cleaned response string
///
/// ## Advanced API
/// - `call_api_with_config(config, messages)` – low-level async API call
/// - `call_api(messages)` – async API call using env vars
// lib.rs
use Error;
pub use Client;
pub use *;
async