Skip to content

Services

LLMxRay has 36 service modules in src/services/. Services encapsulate business logic, API communication, and data processing.

API Layer

ServiceFileResponsibility
OllamaClientollama-client.tsHTTP client for all Ollama endpoints: /api/tags, /api/show, /api/chat, /api/generate, /api/embed, /v1/chat/completions
Chat Servicechat-service.tsMulti-turn chat with tool calling loop (max 5 rounds), agent graph recording
Generate Servicegenerate-service.tsSingle prompt generation with streaming, prompt analysis, metrics
Model Servicemodel-service.tsModel listing, architecture parsing, capability detection

Streaming

ServiceFileResponsibility
Stream Handlerstream-handler.tsNDJSON and SSE parsing, token extraction, reasoning detection, tool call processing
Reasoning Parserreasoning-parser.tsParses <think> blocks from DeepSeek-R1, pattern-based reasoning detection fallback
Metrics Calculatormetrics-calculator.tsComputes TTFT, tokens-per-second, throughput from streaming chunks

Storage (IndexedDB)

ServiceFileResponsibility
Conversation DBconversation-db.tsCRUD for conversations, messages, sessions, tokens with lazy-loading
Benchmark DBbenchmark-db.tsPersistence for benchmark results and custom suites
Vector DBvector-db.tsRAG chunk storage and similarity search
Canvas AI DBcanvas-ai-db.tsTraining pair storage
Message Memory DBmessage-memory-db.tsConversation summaries and memory
Storage Estimatorstorage-estimator.tsEstimates IndexedDB and origin storage usage

Document Processing

ServiceFileResponsibility
Document Parserdocument-parser.tsFormat detection and text extraction (PDF via pdfjs, DOCX via mammoth)
Document Chunkerdocument-chunker.tsSemantic chunking with configurable size/overlap and metadata
RAG Pipelinerag-pipeline.tsEnd-to-end ingestion (parse → chunk → embed → store) and search

Tool System

ServiceFileResponsibility
Tool Executortool-executor.tsExecutes tool calls, validates parameters
Tool Canvas Adaptertool-canvas-adapter.tsConverts canvas tool definitions to Ollama format
AST Parserast-parser.tsRecast-based code analysis for bidirectional sync
OpenAPI Parseropenapi-parser.tsParses OpenAPI/Swagger specs into tool definitions
Code to Blockscode-to-blocks.tsConverts TypeScript code into executable blocks
Path to Codepath-to-code.tsExtracts code from JSON paths
Optimize Tool Codeoptimize-tool-code.tsAI-assisted code optimization
Probeprobe.tsAPI endpoint probing and response inspection
Slash Command Registryslash-command-registry.tsRegisters and dispatches slash commands

AI & Analysis

ServiceFileResponsibility
Canvas AIcanvas-ai.tsAI-powered tool drafting and improvement suggestions
Introspection Serviceintrospection-service.tsGenerates illustrative layer/attention data from model architecture
Prompt Analyzerprompt-analyzer.tsIdentifies prompt sections (system, user, context, tools, examples)
Context Managercontext-manager.tsBuilds context from RAG documents, memory, and conversation history
Benchmark Runnerbenchmark-runner.tsOrchestrates benchmark execution with progress tracking

External

ServiceFileResponsibility
Google Authgoogle-auth.tsOAuth2 flow with token refresh for Google API access
Feedback Servicefeedback-service.tsCollects and submits user feedback via GitHub Issues
System Info Clientsystem-info-client.tsReads hardware information from the Vite plugin virtual module

Released under the Apache 2.0 License.