Expand description
§OxiRS Chat
Status: Production Release (v0.1.0) Stability: Public APIs are stable. Production-ready with comprehensive testing.
Advanced RAG chat API with LLM integration, natural language to SPARQL translation, streaming responses, self-healing capabilities, and consciousness-inspired computing.
This crate provides a production-ready conversational interface for knowledge graphs, combining retrieval-augmented generation (RAG) with SPARQL querying, vector search, and advanced AI features including temporal reasoning and consciousness-guided processing.
§Key Features
§🧠 Consciousness-Inspired Computing
- Temporal memory bank with event tracking
- Pattern recognition for conversation understanding
- Future projection and implication analysis
- Emotional context awareness and sentiment analysis
- Multi-level consciousness integration
§⚡ Real-Time Streaming
- Progressive response streaming with status updates
- Context delivery during processing
- Word-by-word response generation
- Asynchronous processing with tokio integration
- Configurable chunk sizes and delays
§🔧 Self-Healing System
- Automated health monitoring and issue detection
- 8 different healing action types for comprehensive recovery
- Recovery statistics tracking with success rate monitoring
- Cooldown management and attempt limiting
- Component-specific healing actions
§🔍 Advanced Query Processing
- Natural language to SPARQL translation
- Vector similarity search integration
- Context-aware query understanding
- Multi-modal reasoning capabilities
- Enterprise security and authentication
§Quick Start Example
use oxirs_chat::{ChatSession, Message, MessageRole, OxiRSChat, ChatConfig};
use oxirs_core::ConcreteStore;
use std::sync::Arc;
// Initialize the store and chat system
let store = Arc::new(ConcreteStore::new()?);
let config = ChatConfig::default();
let chat_system = OxiRSChat::new(config, store as Arc<dyn oxirs_core::Store>).await?;
// Create a chat session
let session = chat_system.create_session("user123".to_string()).await?;
// Process with integrated RAG
let response = chat_system.process_message(
"user123",
"What genes are associated with breast cancer?".to_string()
).await?;
println!("Response: {:?}", response);§Streaming Response Example
use oxirs_chat::{OxiRSChat, ChatConfig};
use oxirs_core::ConcreteStore;
use std::sync::Arc;
// Process message with streaming (feature under development)
let response = chat_system.process_message(
"user123",
"Explain the relationship between BRCA1 and cancer".to_string()
).await?;
println!("Response: {:?}", response);
// Note: Streaming API is available through internal components
// Future versions will expose streaming API directly
// Original streaming code for reference:
/*
while let Some(chunk) = stream.next().await {
match chunk? {
StreamResponseChunk::Status { stage, progress } => {
println!("Stage: {:?}, Progress: {:.1}%", stage, progress * 100.0);
}
StreamResponseChunk::Context { facts, sparql_results } => {
println!("Found {} facts", facts.len());
}
StreamResponseChunk::Content { text } => {
print!("{}", text); // Stream text word by word
}
StreamResponseChunk::Complete { total_time } => {
println!("\nCompleted in {:.2}s", total_time.as_secs_f64());
break;
}
_ => {}
}
}
*/§Self-Healing System Example
use oxirs_chat::health_monitoring::{HealthMonitor, HealthMonitoringConfig, HealthStatus};
let config = HealthMonitoringConfig::default();
let health_monitor = HealthMonitor::new(config);
// Generate health report
let health_report = health_monitor.generate_health_report().await?;
match health_report.overall_status {
HealthStatus::Healthy => println!("System is healthy"),
HealthStatus::Degraded => println!("System performance is degraded"),
HealthStatus::Unhealthy => println!("System has health issues"),
HealthStatus::Critical => println!("System is in critical state"),
}
println!("System uptime: {:?}", health_report.uptime);§Advanced Configuration
use oxirs_chat::{ChatConfig};
use std::time::Duration;
let chat_config = ChatConfig {
max_context_tokens: 16000,
sliding_window_size: 50,
enable_context_compression: true,
temperature: 0.8,
max_tokens: 4000,
timeout_seconds: 60,
enable_topic_tracking: true,
enable_sentiment_analysis: true,
enable_intent_detection: true,
};
// Use the configuration to create a chat system
// let store = Arc::new(ConcreteStore::new());
// let chat_system = OxiRSChat::new(chat_config, store).await?;
println!("Chat system configured with advanced features");Re-exports§
pub use chat_session::ChatSession;pub use chat_session::SessionStatistics;pub use messages::Message;pub use messages::MessageAttachment;pub use messages::MessageContent;pub use messages::MessageRole;pub use messages::RichContentElement;pub use session_manager::ChatConfig;pub use session_manager::ContextWindow;pub use session_manager::SessionData;pub use session_manager::SessionMetrics;pub use session_manager::SessionState;pub use session_manager::TopicTracker;pub use types::SessionStats;pub use types::ThreadInfo;pub use rag::AssembledContext;pub use rag::QueryContext;pub use rag::RAGConfig;pub use rag::RAGSystem;pub use schema_introspection::DiscoveredSchema;pub use schema_introspection::IntrospectionConfig;pub use schema_introspection::RdfClass;pub use schema_introspection::RdfProperty;pub use schema_introspection::SchemaIntrospector;pub use llm::CircuitBreakerConfig;pub use llm::CircuitBreakerState;pub use llm::CircuitBreakerStats;pub use llm::LLMConfig;pub use llm::LLMResponse;pub use collaboration::AccessControl;pub use collaboration::CollaborationConfig;pub use collaboration::CollaborationManager;pub use collaboration::CollaborationStats;pub use collaboration::CollaborationUpdate;pub use collaboration::CursorPosition;pub use collaboration::Participant;pub use collaboration::ParticipantRole;pub use collaboration::ParticipantStatus;pub use collaboration::TextRange;pub use voice::AudioFormat;pub use voice::SpeechToTextProvider;pub use voice::SttProviderType;pub use voice::SttResult;pub use voice::SttStreamResult;pub use voice::TextToSpeechProvider;pub use voice::TtsProviderType;pub use voice::TtsResult;pub use voice::VoiceConfig;pub use voice::VoiceInterface;pub use voice::WordTimestamp;pub use dashboard::ActivityDataPoint;pub use dashboard::DashboardAnalytics;pub use dashboard::DashboardConfig;pub use dashboard::DashboardOverview;pub use dashboard::ExportFormat;pub use dashboard::HealthAnalytics;pub use dashboard::HealthDataPoint;pub use dashboard::QueryAnalytics;pub use dashboard::QueryRecord;pub use dashboard::QueryType;pub use dashboard::SystemHealthMetrics;pub use dashboard::TimeRange;pub use dashboard::UserActivity;pub use dashboard::UserActivityTracker;pub use dashboard::UserAnalytics;pub use session::*;pub use types::*;
Modules§
- analytics
- Analytics module for conversation analysis
- cache
- Advanced Caching System for OxiRS Chat
- chat
- Personalized chat module with adaptive responses
- chat_
session - Chat session implementation with message history and statistics
- collaboration
- Real-Time Collaboration Module
- collaboration_
server - Collaboration Server Endpoints
- context
- custom_
prompts - Custom Prompts System
- custom_
tools - Custom Tools Framework
- dashboard
- Analytics Dashboard Backend API
- dashboard_
server - Dashboard Server Endpoints
- enterprise_
integration - Enterprise Integration Module for OxiRS Chat
- error
- Error types for oxirs-chat
- explanation
- Explanation and transparency module for OxiRS Chat
- exploration_
guidance - Data Exploration Guidance System
- export
- Export Module
- external_
services - External Services Integration for OxiRS Chat
- features
- Feature flags for optional functionality
- graph_
exploration - Graph exploration module for dynamic knowledge graph navigation
- health_
monitoring - Health monitoring module for comprehensive system health tracking
- i18n
- Internationalization (i18n) and Localization Support
- knowledge_
bases - External Knowledge Base Integrations
- llm
- LLM Integration Module for OxiRS Chat
- message_
analytics - Message analytics module for OxiRS Chat
- messages
- Message types and rich content support for chat interface
- nl2sparql
- Natural Language to SPARQL Translation System
- nlp
- Natural Language Processing Module
- performance
- Performance Monitoring and Optimization for OxiRS Chat
- persistence
- Session Persistence and Recovery System for OxiRS Chat
- plugins
- Plugin System
- query_
refinement - Query Refinement System
- rag
- RAG (Retrieval-Augmented Generation) System for OxiRS Chat
- rich_
content - Rich content support for oxirs-chat
- schema_
introspection - Schema Introspection Module
- server
- HTTP Server and WebSocket Implementation for OxiRS Chat
- session
- Session management re-exports
- session_
manager - Session management and chat functionality
- sparql_
optimizer - Advanced SPARQL Query Optimization for OxiRS Chat
- suggestions
- Query Suggestions System
- types
- Core types for OxiRS Chat
- utils
- Utility modules for oxirs-chat
- visualization
- Result Visualization Helpers
- voice
- Voice Interface Module
- webhooks
- Webhook System
- workflow
- Workflow Integration for OxiRS Chat
Structs§
- OxiRS
Chat - Main chat interface for OxiRS with advanced AI capabilities