# GigaThink Module API Documentation
Version: 2.1.0
The GigaThink module implements expansive creative thinking through divergent analysis,
generating 10+ diverse perspectives to explore problems from multiple angles.
## Table of Contents
1. [Module Overview](#module-overview)
2. [Configuration](#configuration)
3. [Core Types](#core-types)
4. [Methods](#methods)
5. [Usage Examples](#usage-examples)
6. [Error Handling](#error-handling)
## Module Overview
GigaThink is designed to break free from linear thinking patterns by systematically
generating multiple analytical perspectives. It employs dimensional analysis across
12 distinct thinking frameworks to ensure comprehensive coverage of the problem space.
Key capabilities:
- Generates minimum 10 distinct perspectives
- Applies 12 analytical dimensions for thorough analysis
- Provides evidence-based confidence scoring
- Supports both synchronous and asynchronous execution
- Includes cross-validation for perspective coherence
## Configuration
### GigaThinkConfig
Configuration struct controlling GigaThink behavior and analysis depth.
```rust
pub struct GigaThinkConfig {
pub min_perspectives: usize,
pub max_perspectives: usize,
pub analysis_depth: usize,
pub cross_validate: bool,
pub timeout_ms: u64,
pub enable_synthesis: bool,
pub confidence_threshold: f64,
}
```
#### Fields
| `min_perspectives` | `usize` | Yes | `10` | Minimum number of perspectives to generate. Guarantees comprehensive analysis coverage. |
| `max_perspectives` | `usize` | Yes | `20` | Maximum number of perspectives to generate. Prevents excessive computation. |
| `analysis_depth` | `usize` | Yes | `3` | Depth of dimensional analysis per perspective. Higher values provide deeper insights. |
| `cross_validate` | `bool` | Yes | `true` | Enable cross-validation of perspectives for coherence. Improves output quality. |
| `timeout_ms` | `u64` | Yes | `30000` | Execution timeout in milliseconds. Prevents hanging operations. |
| `enable_synthesis` | `bool` | Yes | `true` | Generate synthesized insights from all perspectives. Provides holistic understanding. |
| `confidence_threshold` | `f64` | Yes | `0.6` | Minimum confidence for accepted perspectives. Range: 0.0-1.0. |
#### Implementation
```rust
impl Default for GigaThinkConfig {
fn default() -> Self {
Self {
min_perspectives: 10,
max_perspectives: 20,
analysis_depth: 3,
cross_validate: true,
timeout_ms: 30000,
enable_synthesis: true,
confidence_threshold: 0.6,
}
}
}
impl GigaThinkConfig {
/// Create configuration optimized for speed
pub fn fast() -> Self {
Self {
min_perspectives: 5,
max_perspectives: 10,
analysis_depth: 2,
cross_validate: false,
timeout_ms: 15000,
enable_synthesis: false,
confidence_threshold: 0.5,
}
}
/// Create configuration for deep analysis
pub fn deep() -> Self {
Self {
min_perspectives: 15,
max_perspectives: 30,
analysis_depth: 5,
cross_validate: true,
timeout_ms: 60000,
enable_synthesis: true,
confidence_threshold: 0.7,
}
}
}
```
## Core Types
### GigaThink
Main module struct implementing the ThinkToolModule trait.
```rust
pub struct GigaThink {
config: ThinkToolModuleConfig,
gigathink_config: GigaThinkConfig,
}
```
#### Fields
| `config` | `ThinkToolModuleConfig` | Standard module configuration metadata |
| `gigathink_config` | `GigaThinkConfig` | GigaThink-specific configuration parameters |
### GigaThinkResult
Structured output from GigaThink execution containing all analysis results.
```rust
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GigaThinkResult {
pub perspectives: Vec<Perspective>,
pub themes: Vec<Theme>,
pub synthesis: Option<SynthesizedInsight>,
pub metadata: GigaThinkMetadata,
pub confidence: f64,
}
```
#### Fields
| `perspectives` | `Vec<Perspective>` | Generated analytical perspectives |
| `themes` | `Vec<Theme>` | Common themes across perspectives |
| `synthesis` | `Option<SynthesizedInsight>` | Holistic insight from all perspectives |
| `metadata` | `GigaThinkMetadata` | Execution metadata and statistics |
| `confidence` | `f64` | Overall confidence score (0.0-1.0) |
### Perspective
Individual analytical viewpoint with supporting rationale and evidence.
```rust
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Perspective {
pub id: usize,
pub viewpoint: String,
pub rationale: String,
pub evidence: String,
pub confidence: f64,
pub dimensions: Vec<String>,
pub novelty_score: f64,
}
```
#### Fields
| `id` | `usize` | Unique identifier for this perspective |
| `viewpoint` | `String` | The analytical viewpoint or lens |
| `rationale` | `String` | Reasoning behind this perspective |
| `evidence` | `String` | Supporting evidence or examples |
| `confidence` | `f64` | Confidence in this perspective (0.0-1.0) |
| `dimensions` | `Vec<String>` | Analytical dimensions this perspective addresses |
| `novelty_score` | `f64` | How novel/unique this perspective is (0.0-1.0) |
### Theme
Common analytical theme identified across multiple perspectives.
```rust
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Theme {
pub name: String,
pub description: String,
pub perspective_count: usize,
pub confidence: f64,
pub representative_perspectives: Vec<usize>,
}
```
#### Fields
| `name` | `String` | Theme name (e.g., "Economic Impact") |
| `description` | `String` | Detailed theme description |
| `perspective_count` | `usize` | How many perspectives mention this theme |
| `confidence` | `f64` | Confidence in this theme's significance |
| `representative_perspectives` | `Vec<usize>` | IDs of perspectives exemplifying this theme |
### SynthesizedInsight
Holistic insight synthesized from all generated perspectives.
```rust
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SynthesizedInsight {
pub overview: String,
pub key_takeaways: Vec<String>,
pub tensions_and_tradeoffs: Vec<String>,
pub confidence: f64,
}
```
#### Fields
| `overview` | `String` | Comprehensive summary of all perspectives |
| `key_takeaways` | `Vec<String>` | Most important insights extracted |
| `tensions_and_tradeoffs` | `Vec<String>` | Conflicting viewpoints and compromises |
| `confidence` | `f64` | Confidence in the synthesis (0.0-1.0) |
### GigaThinkMetadata
Execution metadata and performance statistics.
```rust
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GigaThinkMetadata {
pub execution_time_ms: u64,
pub perspectives_generated: usize,
pub cross_validation_passed: bool,
pub dimensional_coverage: HashMap<String, usize>,
pub novelty_distribution: Vec<f64>,
}
```
#### Fields
| `execution_time_ms` | `u64` | Total execution time in milliseconds |
| `perspectives_generated` | `usize` | Actual number of perspectives created |
| `cross_validation_passed` | `bool` | Whether cross-validation succeeded |
| `dimensional_coverage` | `HashMap<String, usize>` | Coverage across analytical dimensions |
| `novelty_distribution` | `Vec<f64>` | Distribution of perspective novelty scores |
### AnalysisDimension
Framework for analytical thinking across specific domains.
```rust
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AnalysisDimension {
pub name: String,
pub description: String,
pub questioning_template: String,
pub weight: f64,
}
```
#### Fields
| `name` | `String` | Dimension name (e.g., "Economic") |
| `description` | `String` | Explanation of analytical focus |
| `questioning_template` | `String` | Template for generating questions |
| `weight` | `f64` | Importance weight in analysis (0.0-1.0) |
## Methods
### GigaThink::new()
Create a new GigaThink module with default configuration.
```rust
pub fn new() -> Self
```
Returns: `GigaThink` instance with default settings.
Example:
```rust
let module = GigaThink::new();
assert_eq!(module.name(), "GigaThink");
assert_eq!(module.version(), "2.1.0");
```
### GigaThink::with_config()
Create a new GigaThink module with custom configuration.
```rust
pub fn with_config(config: GigaThinkConfig) -> Self
```
Parameters:
- `config`: `GigaThinkConfig` - Custom configuration parameters
Returns: `GigaThink` instance with specified configuration.
Example:
```rust
let config = GigaThinkConfig::deep();
let module = GigaThink::with_config(config);
```
### GigaThink::builder()
Create a builder for fluent configuration.
```rust
pub fn builder() -> GigaThinkBuilder
```
Returns: `GigaThinkBuilder` for constructing customized instances.
Example:
```rust
let module = GigaThink::builder()
.min_perspectives(15)
.analysis_depth(4)
.build();
```
### GigaThink::execute()
Execute the GigaThink module synchronously.
```rust
impl ThinkToolModule for GigaThink {
fn execute(&self, context: &ThinkToolContext) -> Result<ThinkToolOutput>
}
```
Parameters:
- `context`: `&ThinkToolContext` - Execution context with query and previous steps
Returns: `Result<ThinkToolOutput>` - Structured output or error.
Example:
```rust
let module = GigaThink::new();
let context = ThinkToolContext::new("What factors drive startup success?");
let result = module.execute(&context)?;
```
### GigaThink::execute_async()
Execute the GigaThink module asynchronously.
```rust
impl AsyncThinkToolModule for GigaThink {
async fn execute_async(&self, context: &ThinkToolContext) -> Result<ThinkToolOutput>
}
```
Parameters:
- `context`: `&ThinkToolContext` - Execution context with query and previous steps
Returns: `Result<ThinkToolOutput>` - Structured output or error.
Example:
```rust
let module = GigaThink::new();
let context = ThinkToolContext::new("Analyze AI regulation impacts");
let result = module.execute_async(&context).await?;
```
### GigaThink::config()
Get the module configuration.
```rust
pub fn config(&self) -> &GigaThinkConfig
```
Returns: `&GigaThinkConfig` - Reference to current configuration.
Example:
```rust
let module = GigaThink::new();
let config = module.config();
assert_eq!(config.min_perspectives, 10);
```
## Usage Examples
### Basic Usage
```rust
use reasonkit::thinktool::modules::{GigaThink, ThinkToolContext, ThinkToolModule};
// Create module with default settings
let module = GigaThink::new();
// Prepare context
let context = ThinkToolContext::new("What are the implications of remote work?");
// Execute analysis
let result = module.execute(&context)?;
// Access perspectives
let perspectives = result.get_array("perspectives").unwrap();
println!("Generated {} perspectives", perspectives.len());
// Access synthesis
let synthesis = result.get_str("synthesis").unwrap();
println!("Synthesis: {}", synthesis);
```
### Custom Configuration
```rust
use reasonkit::thinktool::modules::{GigaThink, GigaThinkConfig, ThinkToolContext};
// Create custom configuration
let config = GigaThinkConfig {
min_perspectives: 15,
max_perspectives: 25,
analysis_depth: 4,
timeout_ms: 45000,
..Default::default()
};
// Create module with custom config
let module = GigaThink::with_config(config);
// Execute with complex query
let context = ThinkToolContext::new(
"Analyze the strategic implications of quantum computing for cybersecurity"
);
let result = module.execute(&context)?;
```
### Fluent Builder Pattern
```rust
use reasonkit::thinktool::modules::{GigaThink, ThinkToolContext};
// Use builder for fluent configuration
let module = GigaThink::builder()
.min_perspectives(20)
.max_perspectives(30)
.analysis_depth(5)
.timeout_ms(60000)
.enable_synthesis(true)
.build();
// Execute comprehensive analysis
let context = ThinkToolContext::new("Evaluate the future of sustainable energy");
let result = module.execute(&context)?;
```
## Error Handling
GigaThink defines specific error types for various failure modes:
### GigaThinkError
Enumeration of all possible module-specific errors.
```rust
#[derive(Error, Debug, Clone)]
pub enum GigaThinkError {
InsufficientPerspectives { generated: usize, required: usize },
InvalidDimension { dimension: String },
QueryTooShort { length: usize, minimum: usize },
QueryTooLong { length: usize, maximum: usize },
LowConfidence { confidence: f64, threshold: f64 },
CrossValidationFailed { reason: String },
SynthesisFailed { reason: String },
ExecutionTimeout { duration_ms: u64 },
}
```
### Error Descriptions
| `InsufficientPerspectives` | `generated`, `required` | Generated fewer perspectives than required minimum |
| `InvalidDimension` | `dimension` | Specified analytical dimension is not recognized |
| `QueryTooShort` | `length`, `minimum` | Input query is too brief for meaningful analysis |
| `QueryTooLong` | `length`, `maximum` | Input query exceeds maximum allowed length |
| `LowConfidence` | `confidence`, `threshold` | Overall confidence falls below threshold |
| `CrossValidationFailed` | `reason` | Perspective coherence validation failed |
| `SynthesisFailed` | `reason` | Unable to synthesize perspectives |
| `ExecutionTimeout` | `duration_ms` | Operation exceeded timeout limit |
### Error Conversion
All GigaThinkError variants are automatically converted to the standard Error type:
```rust
impl From<GigaThinkError> for Error {
fn from(err: GigaThinkError) -> Self {
Error::ThinkToolExecutionError(err.to_string())
}
}
```
### Handling Errors
```rust
use reasonkit::thinktool::modules::{GigaThink, ThinkToolContext, GigaThinkError};
let module = GigaThink::new();
let context = ThinkToolContext::new(""); // Empty query
match module.execute(&context) {
Ok(result) => {
// Process successful result
println!("Analysis completed with confidence: {}", result.confidence);
}
Err(e) => {
// Handle specific GigaThink errors
if let Some(gt_err) = e.downcast_ref::<GigaThinkError>() {
match gt_err {
GigaThinkError::QueryTooShort { length, minimum } => {
eprintln!("Query too short: {} chars, minimum {}", length, minimum);
}
GigaThinkError::ExecutionTimeout { duration_ms } => {
eprintln!("Timed out after {}ms", duration_ms);
}
_ => eprintln!("GigaThink error: {}", gt_err),
}
} else {
// Handle other errors
eprintln!("Other error: {}", e);
}
}
}
```
## Performance Considerations
1. **Timeout Management**: Set appropriate timeouts based on analysis depth
2. **Perspective Count**: Balance comprehensiveness with performance
3. **Cross-Validation**: Disable for faster execution when quality is less critical
4. **Synthesis Generation**: Can be disabled for speed-focused applications
5. **Dimensional Analysis**: Reduce analysis_depth for quicker results
## Integration Notes
When using GigaThink in protocol execution:
```rust
use reasonkit::thinktool::{ProtocolExecutor, ProtocolInput};
// ProtocolExecutor handles LLM integration automatically
let executor = ProtocolExecutor::new()?;
let result = executor.execute(
"gigathink",
ProtocolInput::query("Complex strategic question")
).await?;
```
The protocol-based approach provides:
- Automatic LLM selection and configuration
- Streaming output for real-time progress
- Built-in retry logic for failed steps
- Comprehensive execution tracing