OxiRS Chat
AI-powered conversational interface for RDF data with RAG and natural language to SPARQL
Status: Production Release (v0.1.0) - Released January 7, 2026
✨ Production Release: Production-ready with API stability guarantees and comprehensive testing.
Overview
oxirs-chat provides an intelligent conversational interface for querying and exploring RDF datasets. It combines Large Language Models (LLMs) with Retrieval-Augmented Generation (RAG) to enable natural language queries over semantic data, automatic SPARQL generation, and contextual explanations.
Features
- Natural Language to SPARQL: Convert natural language questions to SPARQL queries
- RAG Integration: Retrieve relevant context from RDF data to enhance LLM responses
- Multi-Model Support: OpenAI, Anthropic, local models via Ollama, and Hugging Face
- Context Management: Maintain conversation history and query context
- Explanation Engine: Explain query results and reasoning in natural language
- Vector Search: Semantic similarity search over RDF data
- Interactive Chat: Web-based chat interface with syntax highlighting
- Query Suggestions: Intelligent query suggestions based on data schema
- Data Exploration: Guided exploration of unfamiliar datasets
- Custom Prompts: Configurable prompts for domain-specific use cases
Installation
Add to your Cargo.toml:
# Experimental feature
[]
= "0.1.0"
# Enable specific LLM providers
= { = "0.1.0", = ["openai", "anthropic", "ollama"] }
Quick Start
Basic Chat Server
use ;
use Dataset;
async
Natural Language Queries
use ;
let mut chatbot = new;
// Natural language query
let response = chatbot.query.await?;
match response
Natural Language to SPARQL
Query Generation
use ;
let nl2sparql = NL2SPARQLnew
.with_schema_context
.with_examples_from_file?;
// Convert natural language to SPARQL
let question = "What movies did Christopher Nolan direct?";
let result = nl2sparql.convert.await?;
println!;
println!;
println!;
Custom Prompts
use ;
let prompt = builder
.system_message
.few_shot_examples
.build;
let nl2sparql = NL2SPARQLwith_prompt;
RAG (Retrieval-Augmented Generation)
Vector Search Integration
use ;
use HNSWIndex;
// Create vector store with embeddings
let embedding_model = OpenAI;
let vector_store = new
.with_embedding_model;
// Index RDF data
vector_store.index_dataset.await?;
// Create RAG engine
let rag = new
.with_vector_store
.with_retrieval_count
.with_similarity_threshold;
// Use in chat
let chatbot = new
.with_rag_engine;
Context Retrieval
use ;
let retriever = new
.strategy
.max_context_length
.include_schema_info;
// Retrieve relevant context for a question
let context = retriever.retrieve.await?;
println!;
for doc in context.documents
Conversation Management
Session Handling
use ;
let mut session = new
.with_memory_limit // Keep last 50 messages
.with_context_window; // 4k token context
// Maintain conversation
session.add_message;
let response1 = chatbot.chat.await?;
session.add_message;
session.add_message;
let response2 = chatbot.chat.await?; // Uses previous context
Context Compression
use ;
let compressor = new
.strategy
.compression_ratio;
// Compress conversation history when context gets too long
if session.context_length > 3000
Web Interface
Chat UI
use ;
let web_server = new
.with_chat_ui
.with_syntax_highlighting
.with_query_visualization
.with_result_tables;
// Access at http://localhost:3000
web_server.serve.await?;
REST API
POST /api/chat
Content-Type: application/json
{
"message": "What are the most popular movies of 2023?",
"session_id": "user123",
"include_sparql": true,
"explain_results": true
}
Response:
Advanced Features
Multi-Modal Responses
use ;
let chatbot = new
.response_format;
// Generate rich responses with visualizations
let response = chatbot.query.await?;
match response
Custom Function Integration
use ;
// Define custom function
// Register with chatbot
let mut chatbot = new;
chatbot.register_function;
// Use in conversation
// User: "Recommend some movies for me"
// Assistant: Let me find some movie recommendations based on your preferences...
Schema-Aware Suggestions
use ;
let analyzer = new;
let schema_info = analyzer.analyze.await?;
let suggestion_engine = new
.with_schema_info
.with_query_patterns
.with_user_history;
// Generate contextual suggestions
let suggestions = suggestion_engine.suggest.await?;
// Returns: ["movies by director", "popular movies", "recent movies", ...]
Configuration
Chat Configuration
chat:
llm:
provider: "openai"
model: "gpt-4"
api_key: "${OPENAI_API_KEY}"
temperature: 0.1
max_tokens: 2000
rag:
enabled: true
retrieval_count: 5
similarity_threshold: 0.7
embedding_model: "text-embedding-ada-002"
conversation:
max_history: 50
context_window: 4000
compression_enabled: true
features:
explain_queries: true
show_sparql: true
generate_charts: true
suggestion_engine: true
web_interface:
enabled: true
port: 3000
syntax_highlighting: true
query_visualization: true
Model Configuration
use ;
let config = builder
.llm_config
.embedding_config
.build;
Performance
Benchmarks
| Operation | Latency (p95) | Throughput | Memory |
|---|---|---|---|
| NL to SPARQL | 800ms | 75 q/min | 45MB |
| RAG retrieval | 200ms | 300 q/min | 120MB |
| Simple chat | 600ms | 100 q/min | 35MB |
| Complex reasoning | 1.5s | 40 q/min | 85MB |
Optimization
use ;
let config = builder
.cache_config
.performance_config
.build;
Deployment
Docker
FROM rust:1.70 as builder
WORKDIR /app
COPY . .
RUN cargo build --release --bin oxirs-chat
FROM debian:bookworm-slim
COPY --from=builder /app/target/release/oxirs-chat /usr/local/bin/
EXPOSE 3000
CMD ["oxirs-chat", "--config", "/config.yaml"]
Environment Variables
Related Crates
oxirs-core: RDF data modeloxirs-vec: Vector search and embeddingsoxirs-arq: SPARQL query engineoxirs-fuseki: SPARQL server
Contributing
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Status
🚀 Production Release (v0.1.0) – January 7, 2026
Implementation Status:
- ✅ Chat Infrastructure: Session management, persistence, expiration handling
- ✅ Multi-LLM Support: OpenAI, Anthropic Claude, Ollama/local with intelligent routing
- ✅ RAG System: Vector search, context assembly, knowledge retrieval integrated with persisted datasets
- ✅ Natural Language to SPARQL: Query generation with validation, optimization, and federation-aware prompts
- ✅ Advanced Caching: Multi-tier caching with LRU/LFU eviction policies
- ✅ Performance Monitoring: Real-time metrics, slow-query tracing, and SciRS2 telemetry dashboards
- ✅ Analytics System: Conversation tracking, pattern detection, quality analysis
- ✅ HTTP/WebSocket Server: REST API and real-time WebSocket communication
- ✅ Session Recovery: Backup/restore mechanisms with corruption handling
- ✅ Message Threading: Reply chains and conversation threads
- ✅ Context Management: Sliding window with summarization and topic tracking
- ✅ CLI & Fuseki Integration: Seamless dataset bootstrapping and persistence hand-off
Test Coverage: 12/12 tests passing with comprehensive integration tests
APIs follow semantic versioning. See CHANGELOG.md for details.