Semantic search engine + LLM integration for AI image generation workflows
Retrieve-Augmented Generation (RAG) system specialized in photorealistic prompts, LoRA training, and Instagram authenticity. Works with any OpenAI-compatible LLM (Grok, OpenAI, Ollama, LM Studio, etc.).
Before starting, ensure you have:
For Docker/container users:
# Install Node.js and git
apt-get update && apt-get install -y nodejs npm git
# Or for newer Node.js (recommended):
curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
apt-get install -y nodejs git
git clone https://github.com/ROI-DANINO/RAG-image-expert.git
cd RAG-image-expert
npm install
Note: npm install will download:
node_modules/ (~85 packages)cp .env.example .env
# Edit .env with your API key or local LLM settings
For Grok API:
XAI_API_KEY=your-key-here
AI_MODEL=grok-4-1-thinking
For Local LLM (Ollama):
# Install Ollama first: curl -fsSL https://ollama.com/install.sh | sh
ollama pull llama3.2
# In .env:
AI_BASE_URL=http://localhost:11434/v1
AI_MODEL=llama3.2
# No API key needed!
# CLI chat
npm run chat
# OR start REST API server
npm start
npm run chat
Interactive terminal chat with RAG-enhanced responses.
npm start
# Server runs on http://localhost:3000
# Open http://localhost:3000 in your browser for the web UI
Web Interface Features:
Health Check:
curl http://localhost:3000/health
Search (RAG only, no LLM):
curl -X POST http://localhost:3000/search \
-H "Content-Type: application/json" \
-d '{"query": "Instagram selfie techniques", "topK": 5}'
Chat (Stateless):
curl -X POST http://localhost:3000/chat \
-H "Content-Type: application/json" \
-d '{"message": "How do I train a LoRA?"}'
Conversation (Stateful with history):
curl -X POST http://localhost:3000/conversation \
-H "Content-Type: application/json" \
-d '{
"sessionId": "user123",
"message": "What are the best practices for Instagram prompts?"
}'
The system works with any OpenAI-compatible API:
| Provider | Configuration |
|---|---|
| xAI Grok | Default, API key required |
| OpenAI | Set AI_BASE_URL=https://api.openai.com/v1 |
| Ollama (local) | Set AI_BASE_URL=http://localhost:11434/v1 |
| LM Studio (local) | Set AI_BASE_URL=http://localhost:1234/v1 |
| Custom | Any OpenAI-compatible endpoint |
See docs/LLM_INTEGRATION.md for detailed setup instructions.
# 1. Pull and run Node.js container
docker run -it node:18 bash
# 2. Inside container - install git (if needed)
apt-get update && apt-get install -y git
# 3. Clone and setup
git clone https://github.com/ROI-DANINO/RAG-image-expert.git
cd RAG-image-expert
npm install
# 4. Configure for Grok API
cp .env.example .env
nano .env # or vi .env
# Add your XAI_API_KEY=your-key-here
# Save and exit (Ctrl+X, Y, Enter for nano)
# 5. Start chatting!
npm run chat
# 1. Install Ollama on RunPod
curl -fsSL https://ollama.com/install.sh | sh
# 2. Pull a model
ollama pull llama3.2
# 3. Clone and setup
git clone https://github.com/ROI-DANINO/RAG-image-expert.git
cd RAG-image-expert
npm install
# 4. Configure for local LLM
cp .env.example .env
nano .env
# Set: AI_BASE_URL=http://localhost:11434/v1
# Set: AI_MODEL=llama3.2
# No API key needed!
# 5. Start chatting
npm run chat
RAG-image-expert/
├── rag-chat.js # CLI chat interface
├── rag-server.js # REST API server
├── rag/
│ ├── simple-rag.js # Core RAG implementation
│ └── knowledge.db # SQLite + embeddings
├── docs/
│ └── LLM_INTEGRATION.md # Detailed LLM setup guide
├── .env.example # Configuration template
└── package.json # Dependencies & scripts
| Variable | Required | Default | Description |
|---|---|---|---|
XAI_API_KEY | Yes* | - | API key for LLM (*not needed for localhost) |
AI_BASE_URL | No | https://api.x.ai/v1 | LLM API endpoint |
AI_MODEL | No | grok-beta | Model name |
PORT | No | 3000 | Server port |
USE_DB_SESSIONS | No | false | Enable persistent session storage (52% token savings) |
ENABLE_INTENT_DETECTION | No | true | Enable intelligent context gathering (v0.6+) |
The system includes comprehensive, pre-indexed knowledge across 18 files organized in two categories:
knowledge/core/)knowledge/business/)Total Coverage: 729 indexed chunks from 19 files for precise RAG retrieval
Add your own knowledge by placing .md files in knowledge/core/ or knowledge/business/ and rebuilding the index:
npm run build-index
# Or run directly:
node rag/simple-rag.js build-index
The system collects user feedback to improve over time and build training datasets.
After each AI response, you can:
Feedback is saved in SQLite database (rag/feedback.db) with:
Collected feedback will be used to:
See ROADMAP.md for detailed learning system plans.
Conversations are now persistent:
rag/sessions.db)Coming Soon (Phase 2+):
"git: command not found"
apt-get update && apt-get install -y git
"npm: command not found" or old Node.js version
# Install newer Node.js
curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
apt-get install -y nodejs
node --version # Should show v18.x or higher
"Cannot find module" errors
# Make sure you're in the project root
cd RAG-image-expert
npm install
"No API key found"
.env file from .env.example: cp .env.example .envls -la .env"Connection refused" (local LLM)
ollama list to verify models are installed"Module 'simple-rag.js' not found"
# The RAG files are in the rag/ subdirectory
cd rag
ls simple-rag.js # Should exist
Slow responses
llama3.2 not llama3.2:70b)topK for less contextDNS Resolution Failures (WSL2)
If you see errors like getaddrinfo EAI_AGAIN api.x.ai:
# Temporary fix (resets on WSL restart)
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
# Or restart WSL (from Windows PowerShell as admin)
wsl --shutdown
The server now includes automatic retry logic (3 attempts with exponential backoff) to handle temporary network issues.
Context7 MCP Connection Issues
The server uses @upstash/context7-mcp for live documentation fetching. If you see connection errors:
npx -y @upstash/context7-mcp (auto-installed on first run)Memory Bank MCP
Memory recall is temporarily disabled due to SDK compatibility:
this.enableRecall = true in services/memory-service.js:19BSD-3-Clause
Issues and PRs welcome! See CONTRIBUTING.md for guidelines.
With Docker (fresh environment):
npm install.env.example to .envnpm run chatWith RunPod (local LLM):
ollama pull llama3.2.env: Set AI_BASE_URL=http://localhost:11434/v1npm run chat - no API key needed!Ready to test? Let me know if you hit any issues!
27 commits
8 commits
JavaScript
81.9%
HTML
18.1%
Semantic search engine + LLM integration for AI image generation workflows
Retrieve-Augmented Generation (RAG) system specialized in photorealistic prompts, LoRA training, and Instagram authenticity. Works with any OpenAI-compatible LLM (Grok, OpenAI, Ollama, LM Studio, etc.).
Before starting, ensure you have:
For Docker/container users:
# Install Node.js and git
apt-get update && apt-get install -y nodejs npm git
# Or for newer Node.js (recommended):
curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
apt-get install -y nodejs git
git clone https://github.com/ROI-DANINO/RAG-image-expert.git
cd RAG-image-expert
npm install
Note: npm install will download:
node_modules/ (~85 packages)cp .env.example .env
# Edit .env with your API key or local LLM settings
For Grok API:
XAI_API_KEY=your-key-here
AI_MODEL=grok-4-1-thinking
For Local LLM (Ollama):
# Install Ollama first: curl -fsSL https://ollama.com/install.sh | sh
ollama pull llama3.2
# In .env:
AI_BASE_URL=http://localhost:11434/v1
AI_MODEL=llama3.2
# No API key needed!
# CLI chat
npm run chat
# OR start REST API server
npm start
npm run chat
Interactive terminal chat with RAG-enhanced responses.
npm start
# Server runs on http://localhost:3000
# Open http://localhost:3000 in your browser for the web UI
Web Interface Features:
Health Check:
curl http://localhost:3000/health
Search (RAG only, no LLM):
curl -X POST http://localhost:3000/search \
-H "Content-Type: application/json" \
-d '{"query": "Instagram selfie techniques", "topK": 5}'
Chat (Stateless):
curl -X POST http://localhost:3000/chat \
-H "Content-Type: application/json" \
-d '{"message": "How do I train a LoRA?"}'
Conversation (Stateful with history):
curl -X POST http://localhost:3000/conversation \
-H "Content-Type: application/json" \
-d '{
"sessionId": "user123",
"message": "What are the best practices for Instagram prompts?"
}'
The system works with any OpenAI-compatible API:
| Provider | Configuration |
|---|---|
| xAI Grok | Default, API key required |
| OpenAI | Set AI_BASE_URL=https://api.openai.com/v1 |
| Ollama (local) | Set AI_BASE_URL=http://localhost:11434/v1 |
| LM Studio (local) | Set AI_BASE_URL=http://localhost:1234/v1 |
| Custom | Any OpenAI-compatible endpoint |
See docs/LLM_INTEGRATION.md for detailed setup instructions.
# 1. Pull and run Node.js container
docker run -it node:18 bash
# 2. Inside container - install git (if needed)
apt-get update && apt-get install -y git
# 3. Clone and setup
git clone https://github.com/ROI-DANINO/RAG-image-expert.git
cd RAG-image-expert
npm install
# 4. Configure for Grok API
cp .env.example .env
nano .env # or vi .env
# Add your XAI_API_KEY=your-key-here
# Save and exit (Ctrl+X, Y, Enter for nano)
# 5. Start chatting!
npm run chat
# 1. Install Ollama on RunPod
curl -fsSL https://ollama.com/install.sh | sh
# 2. Pull a model
ollama pull llama3.2
# 3. Clone and setup
git clone https://github.com/ROI-DANINO/RAG-image-expert.git
cd RAG-image-expert
npm install
# 4. Configure for local LLM
cp .env.example .env
nano .env
# Set: AI_BASE_URL=http://localhost:11434/v1
# Set: AI_MODEL=llama3.2
# No API key needed!
# 5. Start chatting
npm run chat
RAG-image-expert/
├── rag-chat.js # CLI chat interface
├── rag-server.js # REST API server
├── rag/
│ ├── simple-rag.js # Core RAG implementation
│ └── knowledge.db # SQLite + embeddings
├── docs/
│ └── LLM_INTEGRATION.md # Detailed LLM setup guide
├── .env.example # Configuration template
└── package.json # Dependencies & scripts
| Variable | Required | Default | Description |
|---|---|---|---|
XAI_API_KEY | Yes* | - | API key for LLM (*not needed for localhost) |
AI_BASE_URL | No | https://api.x.ai/v1 | LLM API endpoint |
AI_MODEL | No | grok-beta | Model name |
PORT | No | 3000 | Server port |
USE_DB_SESSIONS | No | false | Enable persistent session storage (52% token savings) |
ENABLE_INTENT_DETECTION | No | true | Enable intelligent context gathering (v0.6+) |
The system includes comprehensive, pre-indexed knowledge across 18 files organized in two categories:
knowledge/core/)knowledge/business/)Total Coverage: 729 indexed chunks from 19 files for precise RAG retrieval
Add your own knowledge by placing .md files in knowledge/core/ or knowledge/business/ and rebuilding the index:
npm run build-index
# Or run directly:
node rag/simple-rag.js build-index
The system collects user feedback to improve over time and build training datasets.
After each AI response, you can:
Feedback is saved in SQLite database (rag/feedback.db) with:
Collected feedback will be used to:
See ROADMAP.md for detailed learning system plans.
Conversations are now persistent:
rag/sessions.db)Coming Soon (Phase 2+):
"git: command not found"
apt-get update && apt-get install -y git
"npm: command not found" or old Node.js version
# Install newer Node.js
curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
apt-get install -y nodejs
node --version # Should show v18.x or higher
"Cannot find module" errors
# Make sure you're in the project root
cd RAG-image-expert
npm install
"No API key found"
.env file from .env.example: cp .env.example .envls -la .env"Connection refused" (local LLM)
ollama list to verify models are installed"Module 'simple-rag.js' not found"
# The RAG files are in the rag/ subdirectory
cd rag
ls simple-rag.js # Should exist
Slow responses
llama3.2 not llama3.2:70b)topK for less contextDNS Resolution Failures (WSL2)
If you see errors like getaddrinfo EAI_AGAIN api.x.ai:
# Temporary fix (resets on WSL restart)
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
# Or restart WSL (from Windows PowerShell as admin)
wsl --shutdown
The server now includes automatic retry logic (3 attempts with exponential backoff) to handle temporary network issues.
Context7 MCP Connection Issues
The server uses @upstash/context7-mcp for live documentation fetching. If you see connection errors:
npx -y @upstash/context7-mcp (auto-installed on first run)Memory Bank MCP
Memory recall is temporarily disabled due to SDK compatibility:
this.enableRecall = true in services/memory-service.js:19BSD-3-Clause
Issues and PRs welcome! See CONTRIBUTING.md for guidelines.
With Docker (fresh environment):
npm install.env.example to .envnpm run chatWith RunPod (local LLM):
ollama pull llama3.2.env: Set AI_BASE_URL=http://localhost:11434/v1npm run chat - no API key needed!Ready to test? Let me know if you hit any issues!
27 commits
8 commits
JavaScript
81.9%
HTML
18.1%