nexus-ai / API_DOCUMENTATION.md
Wasim0606's picture
Upload 9 files
41d8176 verified

A newer version of the Streamlit SDK is available: 1.54.0

Upgrade

Neuromorphic Quantum Cognitive Task System πŸ§ βœ¨πŸ’»

Overview 🌌

The Neuromorphic Quantum Cognitive Task System provides a state-of-the-art API that leverages quantum-inspired algorithms, neuromorphic computing principles, and LangChain/Groq integration to revolutionize task management. This system combines cutting-edge visualization with powerful quantum-inspired algorithms to create an innovative approach to managing complex tasks and their interdependencies.

Base URL πŸ”—

API base URL: http://localhost:8000/

System Architecture πŸ—οΈ

The system consists of two main components:

  1. FastAPI Backend: Quantum-inspired task management engine with LangChain and Groq LLM integration
  2. Streamlit Frontend: Interactive visualization interface with advanced animations and quantum state displays

Key Technologies

  • LangChain + Groq: Efficient LLM integration with optimized token usage
  • ChromaDB: Vector storage for semantic search capabilities
  • SQLiteDict: Persistent data storage for tasks and entanglements
  • DiskCache: Performance optimization for repeated operations
  • Streamlit: Modern web interface with reactive components
  • Plotly/Matplotlib: Advanced data visualization
  • NetworkX: Quantum entanglement network visualization

Authentication πŸ”

Currently, access is open for development. Production deployments will implement OAuth2 with JWT tokens and quantum-enhanced cryptography.

Task Quantum Properties βš›οΈ

Every task in the system leverages quantum-inspired properties:

  • Entropy (0-1): Represents task uncertainty and cognitive complexity
  • Superposition: Tasks exist in multiple potential states simultaneously
  • Probability Distribution: Likelihood across possible states (PENDING, IN_PROGRESS, COMPLETED, BLOCKED)
  • Entanglement: Bi-directional influence between coupled tasks
  • Quantum State Vector: Complex representation with amplitudes and phase information
  • Coherence Time: Duration before entropy naturally increases
  • Quantum Visualization: Bloch sphere representation of task state

Endpoints 🌐

Core API Health & System Information

GET /

System health and operational status

Response:

{
  "name": "Quantum Nexus - Neuromorphic Task Management System",
  "version": "2.3.0",
  "status": "operational",
  "uptime": "14d 7h 23m",
  "quantum_capabilities": ["simulation", "entanglement", "superposition", "optimization"],
  "timestamp": "2025-04-15T21:34:56.789Z"
}

GET /metrics

System-wide quantum metrics and analytics

Response:

{
  "total_entropy": 42.5,
  "quantum_coherence": 0.87,
  "task_count": 48,
  "completion_rate": 0.68,
  "entanglement_density": 0.45,
  "average_cognitive_load": 3.2,
  "entanglement_network_diameter": 6,
  "quantum_state_fidelity": 0.92,
  "system_phase": "coherent",
  "anomaly_detection": {
    "anomalies_detected": false,
    "confidence": 0.97
  },
  "decoherence_rate": 0.002
}

GET /health-check

Extended health check with component status

Response:

{
  "status": "healthy",
  "components": {
    "database": "operational",
    "quantum_simulator": "operational",
    "vector_store": "operational",
    "llm_integration": "operational"
  },
  "resource_utilization": {
    "cpu": 32,
    "memory": 47,
    "storage": 28
  },
  "latency_ms": 42
}

Task Management πŸ“‹

GET /tasks

Retrieve tasks with advanced filtering, sorting, and quantum state analysis.

Parameters:

  • state: Filter by task state
  • assignee: Filter by assignee
  • tags: Filter by tags (comma-separated)
  • sort_by: Sort field (priority, entropy, due_date, created_at, etc.)
  • sort_order: asc/desc
  • limit: Results limit (1-500)
  • entropy_range: Filter by entropy range (e.g., "0.2,0.8")
  • entanglement_count: Filter by number of entanglements
  • coherence_threshold: Minimum coherence value
  • quantum_phase: Filter by quantum phase

Response: Array of task objects with full quantum properties

POST /tasks

Create a task with quantum initialization.

Request:

{
  "title": "Develop quantum machine learning algorithm",
  "description": "Implement tensor network for quantum state representation",
  "assignee": "Dr. Emma Chen",
  "due_date": "2025-05-10T17:00:00Z",
  "tags": ["quantum", "algorithm", "ML", "priority"],
  "priority": 5,
  "initial_state": "PENDING",
  "quantum_properties": {
    "initial_entropy": 0.8,
    "coherence_preference": "high"
  }
}

Response: Complete task object with initialized quantum state

GET /tasks/{task_id}

Retrieve a specific task with full quantum state information.

Response:

{
  "id": "task-uuid-1",
  "title": "Develop quantum machine learning algorithm",
  "description": "Implement tensor network for quantum state representation",
  "assignee": "Dr. Emma Chen",
  "created_at": "2025-04-10T09:00:00Z",
  "updated_at": "2025-04-11T14:30:00Z",
  "due_date": "2025-05-10T17:00:00Z",
  "state": "IN_PROGRESS",
  "tags": ["quantum", "algorithm", "ML", "priority"],
  "priority": 5,
  "entropy": 0.68,
  "probability_distribution": {
    "PENDING": 0.15,
    "IN_PROGRESS": 0.75,
    "COMPLETED": 0.05,
    "BLOCKED": 0.05
  },
  "embedding": [0.23, 0.45, 0.12, ...],
  "entangled_tasks": ["task-uuid-2", "task-uuid-3"],
  "quantum_state": {
    "amplitudes": {
      "PENDING": {"real": 0.387, "imag": 0.0},
      "IN_PROGRESS": {"real": 0.866, "imag": 0.0},
      "COMPLETED": {"real": 0.224, "imag": 0.0},
      "BLOCKED": {"real": 0.224, "imag": 0.0}
    },
    "fidelity": 0.98,
    "coherence_time": 14.3,
    "phase": 0.25,
    "visualization_data": [0.15, 0.75, 0.05, 0.05]
  },
  "category": "Algorithm Development",
  "ml_summary": "High-priority ML algorithm development requiring quantum computing expertise",
  "cognitive_load": 4.2,
  "complexity_rating": "high",
  "task_phase": "implementation",
  "progress_percentage": 35
}

PUT /tasks/{task_id}

Update a task, triggering quantum state changes and entanglement propagation.

Request:

{
  "state": "IN_PROGRESS",
  "assignee": "Dr. Emma Chen",
  "priority": 5,
  "tags": ["quantum", "algorithm", "ML", "priority", "active"]
}

Response: Updated task with recalculated quantum properties

DELETE /tasks/{task_id}

Delete a task, handling entanglement collapse.

Response:

{
  "message": "Task deleted successfully with quantum state collapse",
  "id": "deleted-task-uuid",
  "affected_entanglements": ["entanglement-uuid-1", "entanglement-uuid-2"],
  "propagation_results": {
    "tasks_affected": 3,
    "entropy_increases": 2,
    "state_changes": 0
  }
}

Quantum Entanglements πŸ”€

POST /entanglements

Create a quantum entanglement between tasks.

Request:

{
  "task_id_1": "task-uuid-1",
  "task_id_2": "task-uuid-2",
  "strength": 0.85,
  "entanglement_type": "CNOT"
}

Response:

{
  "id": "entanglement-uuid",
  "task_id_1": "task-uuid-1",
  "task_id_2": "task-uuid-2",
  "strength": 0.85,
  "entanglement_type": "CNOT",
  "created_at": "2025-04-15T12:34:56Z",
  "updated_at": "2025-04-15T12:34:56Z",
  "quantum_correlation": 0.77,
  "entanglement_stability": "high",
  "phase_relationship": "coherent"
}

GET /entanglements

Retrieve all entanglements with filtering options.

Parameters:

  • task_id: Filter by task involvement
  • entanglement_type: Filter by type
  • min_strength: Minimum entanglement strength
  • phase_aligned: Filter by phase alignment

Response: Array of entanglement objects

GET /entanglements/{entanglement_id}

Retrieve a specific entanglement with detailed quantum metrics.

Response: Detailed entanglement object

PUT /entanglements/{entanglement_id}

Update an entanglement's properties.

Request:

{
  "strength": 0.95,
  "entanglement_type": "SWAP"
}

Response: Updated entanglement object

DELETE /entanglements/{entanglement_id}

Remove an entanglement, triggering quantum state adjustments.

Response:

{
  "message": "Entanglement dissolved successfully",
  "id": "entanglement-uuid",
  "affected_tasks": ["task-uuid-1", "task-uuid-2"],
  "decoherence_effects": {
    "entropy_changes": [0.05, 0.07],
    "probability_shifts": true
  }
}

Advanced Quantum Features πŸ§ͺ

POST /quantum-simulation

Run advanced quantum circuit simulation on selected tasks.

Request:

{
  "task_ids": ["task-uuid-1", "task-uuid-2", "task-uuid-3"],
  "simulation_steps": 10,
  "decoherence_rate": 0.03,
  "measurement_type": "projective",
  "noise_model": "realistic",
  "circuit_depth": "medium",
  "collapse_threshold": 0.75
}

Response:

{
  "simulation_id": "sim-uuid",
  "tasks": [
    // Array of task objects with initial states
  ],
  "entanglement_matrix": [
    [1.0, 0.85, 0.4],
    [0.85, 1.0, 0.2],
    [0.4, 0.2, 1.0]
  ],
  "simulation_steps": [
    // Array of step data showing quantum state evolution
  ],
  "coherence_evolution": [0.98, 0.95, 0.92, 0.89, 0.86, 0.83, 0.81, 0.78, 0.76, 0.74],
  "measurement_results": {
    "collapsed_states": {
      "task-uuid-1": "IN_PROGRESS",
      "task-uuid-2": "IN_PROGRESS",
      "task-uuid-3": "PENDING"
    },
    "probability_distributions": {
      // Final probability distributions
    },
    "uncertainty_principle_metrics": {
      "position_momentum_product": 0.54,
      "energy_time_product": 0.49
    }
  },
  "quantum_circuit_visualization": {
    "circuit_depth": 12,
    "gate_count": 28,
    "qubit_count": 3,
    "diagram_data": "..."
  },
  "decoherence_analysis": {
    "critical_points": [2, 7],
    "stable_configurations": [
      {
        "states": ["IN_PROGRESS", "IN_PROGRESS", "COMPLETED"],
        "stability_score": 0.82
      }
    ]
  }
}

GET /optimize-assignments

Run quantum-inspired optimization algorithm for task assignments.

Parameters:

  • algorithm: Optimization algorithm to use
  • constraints: Additional constraints
  • objective: Optimization objective

Response:

{
  "optimization_id": "opt-uuid",
  "optimization_score": 0.92,
  "task_count": 18,
  "algorithm_used": "quantum_annealing",
  "iterations": 1024,
  "convergence_threshold": 0.001,
  "assignments": {
    "task-uuid-1": "Dr. Emma Chen",
    "task-uuid-2": "Dr. James Wong",
    // Additional assignments
  },
  "workload_distribution": {
    "Dr. Emma Chen": {
      "task_count": 4,
      "total_priority": 17,
      "entropy_sum": 2.84,
      "cognitive_load": 3.7,
      "expertise_match": 0.94
    },
    // Additional team members
  },
  "optimization_visualization": {
    "energy_landscape": [...],
    "convergence_path": [...],
    "local_minima_count": 5
  },
  "expected_completion_improvements": {
    "time_saved_hours": 28.4,
    "quality_improvement": 0.15,
    "cognitive_load_reduction": 0.23
  }
}

POST /search

Semantic vector search enhanced with quantum algorithms.

Request:

{
  "query": "machine learning algorithms for quantum computing",
  "limit": 10,
  "use_quantum": true,
  "search_mode": "semantic",
  "threshold": 0.7,
  "include_context": true,
  "rank_by": "relevance"
}

Response:

{
  "search_id": "search-uuid",
  "query": "machine learning algorithms for quantum computing",
  "results_count": 5,
  "search_time_ms": 127,
  "quantum_acceleration_used": true,
  "results": [
    {
      "task_id": "task-uuid-1",
      "title": "Develop quantum machine learning algorithm",
      "description": "Implement tensor network for quantum state representation",
      "relevance_score": 0.94,
      "matched_terms": ["quantum", "machine learning", "algorithm"],
      "state": "IN_PROGRESS",
      "priority": 5,
      "similarity_vector": [0.94, 0.87, 0.92]
    },
    // Additional results
  ],
  "facets": {
    "state": {
      "PENDING": 2,
      "IN_PROGRESS": 3
    },
    "priority": {
      "5": 3,
      "4": 2
    },
    "tags": {
      "quantum": 5,
      "ML": 4,
      "algorithm": 3
    }
  },
  "query_expansion": [
    "tensor networks",
    "variational quantum circuits",
    "QSVM"
  ]
}

GET /suggest-related/{task_id}

Suggest quantum-entangled tasks based on similarity metrics.

Parameters:

  • threshold: Similarity threshold (0.1-1.0)
  • max_results: Maximum number of suggestions
  • algorithm: "quantum" or "classical"

Response:

{
  "task_id": "source-task-uuid",
  "suggestions_count": 3,
  "quantum_algorithm_used": true,
  "threshold_applied": 0.75,
  "suggestions": [
    {
      "task_id": "suggested-task-uuid-1",
      "title": "Implement quantum feature map for classification",
      "similarity": 0.92,
      "similarity_dimensions": {
        "content": 0.95,
        "semantic": 0.89,
        "quantum_state": 0.87
      },
      "entanglement_potential": 0.88,
      "expected_benefit": "high"
    },
    // Additional suggestions
  ],
  "entanglement_graph": {
    // Graph representation of suggested entanglements
  }
}

POST /generate-task

AI-powered task generation with quantum computing expertise.

Request:

{
  "description": "Create a task for implementing a quantum ML algorithm",
  "context": "We need to integrate quantum computing with our ML pipeline for enhanced optimization capabilities.",
  "creator": "Dr. Li",
  "expected_complexity": "high",
  "project_area": "quantum_computing",
  "desired_format": "detailed"
}

Response:

{
  "generation_id": "gen-uuid",
  "generated_task": {
    "title": "Implement QSVM Classifier with Tensor Network Acceleration",
    "description": "Develop a Quantum Support Vector Machine classifier using tensor network representations for dimensionality reduction. The implementation should leverage our existing ML pipeline and support input from classical data sources while utilizing quantum circuit simulations for the kernel computation.",
    "suggested_assignee": "Dr. Emma Chen",
    "estimated_complexity": 4.7,
    "suggested_priority": 5,
    "suggested_tags": ["quantum", "ML", "SVM", "tensor-networks", "classification"],
    "prerequisites": ["Quantum SDK setup", "ML pipeline access"],
    "estimated_duration_days": 7,
    "suggested_subtasks": [
      "Research optimal tensor network structures",
      "Implement quantum feature map",
      "Develop classical-quantum interface",
      "Create evaluation framework"
    ]
  },
  "llm_metrics": {
    "tokens_used": 1245,
    "model": "llama3-8b-8192",
    "confidence": 0.92,
    "alternative_count": 3
  },
  "ready_to_create": true
}

POST /ask-task/{task_id}

Ask questions about a task using LLM integration.

Request:

{
  "question": "What are the main technical challenges for this quantum ML task?",
  "analysis_depth": "detailed",
  "context_window": "broad"
}

Response:

{
  "task_id": "task-uuid",
  "question": "What are the main technical challenges for this quantum ML task?",
  "answer": "Based on the task description and current state, the main technical challenges for the QSVM classifier implementation are:\n\n1. **Tensor Network Optimization**: Finding the optimal tensor network structure that balances expressivity and computational efficiency.\n\n2. **Quantum-Classical Interface**: Designing an efficient data loading scheme from classical sources into quantum feature maps.\n\n3. **Decoherence Management**: Implementing error mitigation techniques to handle noise in the quantum simulation.\n\n4. **Kernel Optimization**: Determining the optimal quantum kernel for the specific classification task.\n\n5. **Integration Complexity**: Ensuring seamless integration with the existing ML pipeline while maintaining quantum advantage.\n\nThe most critical bottleneck appears to be the tensor network optimization, as indicated by the high entropy (0.82) in this area of the task.",
  "confidence_score": 0.94,
  "referenced_sources": [
    "task description",
    "attached documentation",
    "team expertise profiles"
  ],
  "relevant_tasks": [
    "task-uuid-related-1",
    "task-uuid-related-2"
  ],
  "suggested_actions": [
    "Consult with quantum expert Dr. Wong",
    "Review recent paper on tensor network optimization"
  ]
}

GET /system-graph

Get quantum-enhanced visualization of the task network.

Parameters:

  • layout: Graph layout algorithm
  • include_metrics: Include additional metrics
  • depth: Graph depth
  • highlight_entanglements: Highlight strong entanglements

Response:

{
  "graph_id": "graph-uuid",
  "timestamp": "2025-04-15T12:34:56Z",
  "nodes_count": 32,
  "edges_count": 47,
  "graph_density": 0.42,
  "quantum_coherence": 0.78,
  "average_path_length": 2.3,
  "nodes": [
    {
      "id": "task-uuid-1",
      "title": "Implement QSVM Classifier",
      "state": "IN_PROGRESS",
      "assignee": "Dr. Emma Chen",
      "priority": 5,
      "entropy": 0.68,
      "size": 15,
      "color": "#4a86e8",
      "position": {"x": 0.3, "y": 0.7, "z": 0.2},
      "cluster": "quantum_ml"
    },
    // Additional nodes
  ],
  "edges": [
    {
      "source": "task-uuid-1",
      "target": "task-uuid-2",
      "strength": 0.85,
      "type": "CNOT",
      "width": 3,
      "color": "#db4437",
      "bidirectional": true
    },
    // Additional edges
  ],
  "clusters": [
    {
      "id": "quantum_ml",
      "name": "Quantum Machine Learning",
      "task_count": 7,
      "centroid": {"x": 0.2, "y": 0.6, "z": 0.1},
      "density": 0.75,
      "total_entropy": 4.32
    },
    // Additional clusters
  ],
  "visualization_hints": {
    "focus_nodes": ["task-uuid-1", "task-uuid-2"],
    "critical_paths": [
      ["task-uuid-4", "task-uuid-7", "task-uuid-12"]
    ],
    "bottlenecks": ["task-uuid-7"],
    "color_scheme": "quantum_state"
  },
  "quantum_field_simulation": {
    "field_strength": [...],
    "interference_patterns": [...],
    "energy_distribution": [...]
  }
}

User Interface Components πŸ’«

The Streamlit frontend provides a rich, interactive experience with advanced animations and visualizations.

Advanced UI Features

  1. Animated Title Component

    • Vibrant, colorful CSS animations with 3D effects
    • Dynamic "shining" overlay animations
    • Quantum-themed gradient backgrounds
  2. Task Cards with Quantum Visualization

    • Animated task cards with particle effects
    • Quantum state indicators with dynamic color coding
    • Probability distribution visualizations
  3. Bloch Sphere Visualization

    • Interactive 3D visualization of quantum state
    • Animated vector representation for state transitions
    • Color-coded quantum axes
  4. Entanglement Network Graph

    • Force-directed graph visualization of task relationships
    • Animated entanglement connections with strength indicators
    • Node size representing task entropy
    • Color coding for different task states
  5. Quantum Simulation Dashboard

    • Step-by-step visualization of quantum state evolution
    • Animated probability distribution changes
    • Coherence time visualization

CSS Animation Classes

The interface includes custom CSS animations:

/* Quantum animation */
@keyframes quantum-pulse {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}
.quantum-pulse {
    animation: quantum-pulse 2s infinite;
}

Advanced Quantum Concepts πŸ“Š

Task Quantum State

Tasks exist in a quantum-inspired state with complex amplitudes for each possible task state:

"quantum_state": {
  "amplitudes": {
    "PENDING": {"real": 0.387, "imag": 0.0},
    "IN_PROGRESS": {"real": 0.866, "imag": 0.0},
    "COMPLETED": {"real": 0.224, "imag": 0.0},
    "BLOCKED": {"real": 0.224, "imag": 0.0}
  },
  "fidelity": 0.98,
  "coherence_time": 14.3,
  "phase": 0.25,
  "visualization_data": [0.15, 0.75, 0.05, 0.05]
}

The probability for each state is the squared magnitude of its amplitude.

Entanglement Types

  • Standard: General bidirectional influence
  • SWAP: Exchange of quantum properties
  • CNOT: Control-target relationship where one task's state influences another
  • Hadamard: Superposition-inducing entanglement
  • Phase: Affects the phase relationship between tasks

Quantum Visualization

Task states can be visualized on a Bloch sphere representation, with:

  • X-axis: Progress dimension
  • Y-axis: Complexity dimension
  • Z-axis: Priority dimension

Error Handling πŸ”§

Response error codes follow HTTP standards with quantum-specific information:

{
  "error_code": 400,
  "message": "Invalid quantum state specification",
  "details": "Amplitude values must satisfy normalization constraint",
  "correlation_id": "err-uuid",
  "quantum_state_validity": {
    "normalization_sum": 1.23,
    "expected": 1.0,
    "correction_suggestion": "Scale amplitudes by factor of 0.813"
  },
  "timestamp": "2025-04-15T12:34:56.789Z"
}

Extended Capabilities πŸš€

AI Integration

The system leverages LangChain with Groq integration for:

  • Task analysis and categorization
  • Intelligent summarization
  • Natural language querying
  • Task generation
  • Semantic search enhancement

Persistence Layer

  • ChromaDB vector storage for embeddings
  • SQLiteDict for structured data
  • DiskCache for performance optimization

Real-time Processing

The system supports real-time updates through entanglement propagation:

  • When a task state changes, entangled tasks receive quantum influence
  • Probability distributions shift according to entanglement types and strengths
  • Entropy changes propagate through the network

Example Usage Patterns πŸ’‘

Advanced Task Creation

# Python client example
task = {
  "title": "Quantum Feature Selection Algorithm",
  "description": "Develop a quantum algorithm for feature selection in high-dimensional datasets",
  "assignee": "Dr. Emma Chen",
  "tags": ["quantum", "algorithm", "feature-selection", "ML"],
  "priority": 5,
  "quantum_properties": {
    "initial_entropy": 0.7,
    "coherence_preference": "high"
  }
}

response = api.create_task(task)
task_id = response["id"]

Quantum Simulation Workflow

# Select tasks for simulation
task_ids = ["task-1", "task-2", "task-3"]

# Run quantum simulation
simulation = api.run_quantum_simulation({
  "task_ids": task_ids,
  "simulation_steps": 10,
  "decoherence_rate": 0.05,
  "measurement_type": "projective"
})

# Analyze results
for step in simulation["simulation_steps"]:
  print(f"Step {step['step_number']}:")
  for task_id, state in step["quantum_states"].items():
    print(f"  Task {task_id}: Entropy = {state['entropy']}")
    print(f"    Probabilities: {state['probability_distribution']}")

AI-Powered Task Generation

# Generate a quantum computing task
new_task = api.generate_task({
  "description": "We need a quantum algorithm for portfolio optimization",
  "context": "Finance team needs better optimization for risk management",
  "expected_complexity": "high"
})

# Create the generated task
task_id = api.create_task(new_task["generated_task"])

Performance Considerations πŸ”

  • Quantum simulations are computationally intensive for large task networks
  • Real-time entanglement propagation scales with O(nΒ²) complexity
  • Vector search performance depends on embedding dimension and database size
  • LLM integration has latency dependent on token count and model size

Advanced Security πŸ”’

  • Quantum-resistant cryptography for data protection
  • Role-based access control for production environments
  • Audit logging for all quantum state changes