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
72
73
74
75
76
77
//! Ensemble definitions and validation.
//!
//! An **Ensemble** is a collection of [`EnsembleLlm`](crate::ensemble_llm::EnsembleLlm)s
//! used together. Ensembles are the foundation of ObjectiveAI's multi-model approach.
//!
//! # Key Properties
//!
//! - **Immutable**: Any change produces a new Ensemble ID
//! - **No weights**: Weights are execution-time parameters, not part of the Ensemble
//! - **Content-addressed**: IDs are deterministically computed from the definition
//! - **Deduplicated**: Duplicate LLMs are merged with their counts summed
//! - **Bounded**: Total LLM count must be between 1 and 128 (individual LLMs with
//! `count: 0` are skipped, but the sum of all counts must be at least 1)
//!
//! # Example
//!
//! ```
//! use objectiveai::ensemble::{EnsembleBase, Ensemble};
//! use objectiveai::ensemble_llm::{EnsembleLlmBase, EnsembleLlmBaseWithFallbacksAndCount, OutputMode};
//! use objectiveai::chat::completions::request::{Message, SystemMessage, SimpleContent};
//!
//! let ensemble_base = EnsembleBase {
//! llms: vec![
//! // A simple GPT-4 configuration
//! EnsembleLlmBaseWithFallbacksAndCount {
//! count: None,
//! inner: EnsembleLlmBase {
//! model: "openai/gpt-4o".to_string(),
//! output_mode: OutputMode::Instruction,
//! ..Default::default()
//! },
//! fallbacks: None,
//! },
//! // Claude with a system prompt
//! EnsembleLlmBaseWithFallbacksAndCount {
//! count: None,
//! inner: EnsembleLlmBase {
//! model: "anthropic/claude-3.5-sonnet".to_string(),
//! output_mode: OutputMode::JsonSchema,
//! prefix_messages: Some(vec![
//! Message::System(SystemMessage {
//! content: SimpleContent::Text("You are a careful evaluator.".to_string()),
//! name: None,
//! }),
//! ]),
//! ..Default::default()
//! },
//! fallbacks: None,
//! },
//! // Gemini with lower temperature
//! EnsembleLlmBaseWithFallbacksAndCount {
//! count: Some(2), // Include 2 instances
//! inner: EnsembleLlmBase {
//! model: "google/gemini-2.0-flash-001".to_string(),
//! output_mode: OutputMode::ToolCall,
//! temperature: Some(0.3),
//! ..Default::default()
//! },
//! fallbacks: None,
//! },
//! ],
//! };
//!
//! let ensemble: Ensemble = ensemble_base.try_into().unwrap();
//! println!("Ensemble ID: {}", ensemble.id);
//! ```
pub use *;
pub use *;