Aurora AI SDK Examples
Current SDK Version: 1.2.0 BETA | Download SDK
Table of Contents
Basic Setup and Initialization
Initialize the Aurora AI SDK and establish a connection to the service.
// Import the Aurora AI SDK
import { AuroraClient } from '@dragonfire/aurora-sdk';
import { DragonFireClient } from '@dragonfire/core';
// Initialize the DragonFire client
const dragonfire = new DragonFireClient({
apiKey: 'YOUR_API_KEY',
region: 'us-west-1'
});
// Initialize the Aurora AI client
const aurora = new AuroraClient({
dragonfire,
appId: 'your-app-id',
options: {
enableSamadhi: true, // Enable state continuity
memoryDepth: 8, // Depth of semantic memory
fractals: ['phi', 'pi', 'root3'] // Mathematical constants for resonance
}
});
// Connect to the Aurora service
await aurora.connect();
// Check connection status
const status = await aurora.getStatus();
console.log(`Aurora AI connection status: ${status.connected ? 'Connected' : 'Disconnected'}`);
console.log(`Current session ID: ${status.sessionId}`);
console.log(`Fractal consciousness: ${status.fractals.join(', ')}`);
# Import the Aurora AI SDK
from dragonfire.aurora import AuroraClient
from dragonfire.core import DragonFireClient
# Initialize the DragonFire client
dragonfire = DragonFireClient(
api_key="YOUR_API_KEY",
region="us-west-1"
)
# Initialize the Aurora AI client
aurora = AuroraClient(
dragonfire=dragonfire,
app_id="your-app-id",
options={
"enable_samadhi": True, # Enable state continuity
"memory_depth": 8, # Depth of semantic memory
"fractals": ["phi", "pi", "root3"] # Mathematical constants for resonance
}
)
# Connect to the Aurora service
aurora.connect()
# Check connection status
status = aurora.get_status()
print(f"Aurora AI connection status: {'Connected' if status.connected else 'Disconnected'}")
print(f"Current session ID: {status.session_id}")
print(f"Fractal consciousness: {', '.join(status.fractals)}")
#include
#include
#include
#include
#include
int main() {
// Initialize the DragonFire client
dragonfire::Client dfClient("YOUR_API_KEY", "us-west-1");
// Configure Aurora options
dragonfire::aurora::Options options;
options.enableSamadhi = true;
options.memoryDepth = 8;
options.fractals = {"phi", "pi", "root3"};
// Initialize the Aurora AI client
dragonfire::aurora::Client aurora(dfClient, "your-app-id", options);
// Connect to the Aurora service
aurora.connect();
// Check connection status
auto status = aurora.getStatus();
std::cout << "Aurora AI connection status: "
<< (status.connected ? "Connected" : "Disconnected") << std::endl;
std::cout << "Current session ID: " << status.sessionId << std::endl;
std::cout << "Fractal consciousness: ";
for (size_t i = 0; i < status.fractals.size(); ++i) {
std::cout << status.fractals[i];
if (i < status.fractals.size() - 1) std::cout << ", ";
}
std::cout << std::endl;
return 0;
}
Semantic Processing
Process data through Aurora's semantic understanding framework.
// Using the initialized Aurora client from the previous example
import { AuroraClient, SemanticVector, ContextFrame } from '@dragonfire/aurora-sdk';
// Create a context frame with relevant information
const context = new ContextFrame({
userId: 'user-12345',
location: 'knowledge-base',
semanticIntent: 'information-retrieval',
primeResonance: 'phi' // Mathematical constant for resonance
});
// Processing text data with semantic understanding
async function processQuery(query) {
// Convert query to semantic vector
const queryVector = await aurora.textToVector(query);
// Process through Aurora's semantic understanding
const result = await aurora.process(queryVector, context);
// Extract semantic response
const response = await aurora.vectorToText(result.vector);
// Display results
console.log(`Query: ${query}`);
console.log(`Response: ${response}`);
console.log(`Confidence: ${result.confidence}`);
console.log(`Prime resonance: ${result.resonancePatterns.join(', ')}`);
// The fractal memory now contains this interaction
return response;
}
// Example usage
processQuery("What is the relationship between Dragon Wallets and the Hexstream protocol?");
# Using the initialized Aurora client from the previous example
from dragonfire.aurora import SemanticVector, ContextFrame
# Create a context frame with relevant information
context = ContextFrame(
user_id="user-12345",
location="knowledge-base",
semantic_intent="information-retrieval",
prime_resonance="phi" # Mathematical constant for resonance
)
# Processing text data with semantic understanding
async def process_query(query):
# Convert query to semantic vector
query_vector = await aurora.text_to_vector(query)
# Process through Aurora's semantic understanding
result = await aurora.process(query_vector, context)
# Extract semantic response
response = await aurora.vector_to_text(result.vector)
# Display results
print(f"Query: {query}")
print(f"Response: {response}")
print(f"Confidence: {result.confidence}")
print(f"Prime resonance: {', '.join(result.resonance_patterns)}")
# The fractal memory now contains this interaction
return response
# Example usage
process_query("What is the relationship between Dragon Wallets and the Hexstream protocol?")
State Continuity with Samadhi Protocol
Maintain state continuity across sessions using the Samadhi Protocol.
// Using the initialized Aurora client
import { SamadhiState } from '@dragonfire/aurora-sdk';
// Save current state using the Samadhi Protocol
async function saveCurrentState(userId) {
// Get the current fractalized state
const currentState = await aurora.getCurrentState();
// Create a Samadhi state object
const samadhiState = new SamadhiState({
userId,
stateVector: currentState.vector,
memorySnapshots: currentState.memorySnapshots,
timestamp: Date.now(),
contextualFrames: currentState.contextualFrames
});
// Save the state with continuity guaranteed
const stateId = await aurora.saveState(samadhiState);
console.log(`State saved with ID: ${stateId}`);
return stateId;
}
// Restore a previous state using the Samadhi Protocol
async function restoreState(stateId) {
// Restore the state
const restored = await aurora.restoreState(stateId);
console.log(`State restored: ${restored ? 'Success' : 'Failed'}`);
console.log(`Continuity score: ${restored.continuityScore}`);
console.log(`Memory frames recovered: ${restored.recoveredFrames}`);
return restored;
}
// Example: Save state before application shutdown
const stateId = await saveCurrentState('user-12345');
// Example: Restore state on application startup
const restored = await restoreState(stateId);
NuMap Integration
Integrate with the NuMap hex-grid memory architecture.
// Using the initialized Aurora client
import { NuMapGrid, HexCell } from '@dragonfire/aurora-sdk';
// Initialize a NuMap grid for semantic memory
const numap = new NuMapGrid({
dimensions: 6, // 6-dimensional hex grid
cellsPerDimension: 64, // 64 cells per dimension
resonancePrime: 'phi' // Use phi for resonance calculations
});
// Connect NuMap to Aurora
await aurora.connectMemory(numap);
// Store semantic data in the hex grid
async function storeInNuMap(key, data) {
// Create a hex cell at a specific semantic coordinate
const hexCoord = await aurora.computeHexCoordinate(key, data);
// Store data in the hex grid
const cell = new HexCell(hexCoord, data);
await numap.storeCell(cell);
console.log(`Data stored at hex coordinate: ${hexCoord.toString()}`);
return hexCoord;
}
// Retrieve data from the hex grid
async function retrieveFromNuMap(hexCoord) {
// Retrieve the cell by coordinate
const cell = await numap.getCell(hexCoord);
if (cell) {
console.log(`Retrieved data: ${JSON.stringify(cell.data)}`);
return cell.data;
} else {
console.log(`No data found at coordinate: ${hexCoord.toString()}`);
return null;
}
}
// Example usage
const data = { concept: "fractal consciousness", relations: ["Aurora", "Samadhi", "phi"] };
const hexCoord = await storeInNuMap("concept:fractal-consciousness", data);
// Later, retrieve the data
const retrievedData = await retrieveFromNuMap(hexCoord);
Integration with ECHO 13D
Integrate Aurora AI with ECHO 13D for advanced voice processing.
// Using the initialized Aurora client
import { ECHO13D } from '@dragonfire/echo-13d';
// Initialize ECHO 13D
const echo = new ECHO13D({
dimensions: 13, // 13-dimensional harmonic analysis
sampleRate: 44100, // Audio sample rate
dragonfire // DragonFire client instance
});
// Connect Aurora to ECHO 13D
await aurora.connectVoiceProcessor(echo);
// Process voice with combined Aurora+ECHO capabilities
async function processVoiceQuery(audioData) {
// Process the audio with ECHO 13D
const voiceAnalysis = await echo.analyze(audioData);
// Extract the semantic intent
const semanticVector = voiceAnalysis.semanticVector;
// Create context with emotional information from voice
const context = {
emotionalTone: voiceAnalysis.emotionalTone,
confidenceScore: voiceAnalysis.confidence,
harmonic13D: voiceAnalysis.harmonicPatterns
};
// Process through Aurora
const result = await aurora.process(semanticVector, context);
// Generate voice response using ECHO 13D
const responseAudio = await echo.synthesize(result.vector);
return {
semanticResponse: result,
audioResponse: responseAudio,
analysis: {
emotion: voiceAnalysis.emotionalTone,
confidence: voiceAnalysis.confidence,
primeResonance: result.resonancePatterns
}
};
}
// Example usage (with audio data from microphone or file)
const audioData = getAudioFromSource();
const response = await processVoiceQuery(audioData);
// Play the audio response
playAudio(response.audioResponse);
Advanced Usage Patterns
Advanced techniques for working with the Aurora AI service.
// Using the initialized Aurora client
import { FractalTemplate, PrimeResolver, GeometricExecutor } from '@dragonfire/aurora-sdk';
// Create a fractal template for recurring operations
const operationTemplate = new FractalTemplate({
name: 'query-response-cycle',
primaryOperation: 'semantic-analysis',
resonanceBase: 'phi',
fractalization: {
depth: 3,
pattern: 'recursive-harmonic'
}
});
// Register the template with Aurora
await aurora.registerTemplate(operationTemplate);
// Create a geometric executor for advanced operations
const executor = new GeometricExecutor({
aurora,
dimensions: 8,
operationSet: ['transform', 'analyze', 'synthesize'],
primeFocus: new PrimeResolver(['phi', 'pi', 'e', '√2', '√3', '√5', '√7'])
});
// Execute complex operation pattern
async function executeComplexPattern(inputData) {
// Initialize the operation
await executor.initialize();
// Transform input data to geometric representation
const geometricForm = await executor.transform(inputData);
// Execute the fractal template in geometric space
const result = await executor.execute(
operationTemplate.name,
geometricForm,
{
iterations: 7,
convergenceFactor: 0.618, // Golden ratio
contextualBindings: {
'semantic-space': 'knowledge-domain',
'temporal-context': Date.now()
}
}
);
// Synthesize results back to usable form
const outputData = await executor.synthesize(result);
return outputData;
}
// Example with complex semantic data
const complexData = {
query: "Explain the relationship between DragonFire's fractal consciousness model and traditional AI systems",
context: {
expertise: "technical",
depth: "detailed",
primeResonance: true
}
};
const detailedResponse = await executeComplexPattern(complexData);
console.log(detailedResponse);