Skip to content

feat(app,backend): RAG pipeline improvements and token estimation - #31

Merged
comppaz merged 1 commit into
mainfrom
feat/rag-improvements-and-token-estimation
Dec 15, 2025
Merged

feat(app,backend): RAG pipeline improvements and token estimation#31
comppaz merged 1 commit into
mainfrom
feat/rag-improvements-and-token-estimation

Conversation

@comppaz

@comppaz comppaz commented Dec 15, 2025

Copy link
Copy Markdown
Collaborator

Summary

This PR introduces improvements to the RAG pipeline and replaces API-provided token counts with client-side estimation for a more stable UI experience.

Frontend Changes

  • Token Estimation: Replaced API-provided token counts with client-side estimation (~4 chars/token)
  • Context Indicator: Shows approximate values with ~ prefix, more stable without flickering
  • Model Selector: Added provider tracking to prevent unnecessary re-fetches during polling

Backend Changes

  • Dynamic Memory Filtering: Threshold-based filtering adapts to match quality (tiered: excellent/good/marginal)
  • Enhanced Search Pipeline: Added match type tracking (vector/keyword/hybrid) and RRF scores
  • Embedding Safety: Model-specific context windows with intelligent text chunking
  • Logging: Comprehensive logging throughout search and query processing
  • Other: Blocked all-minilm model, removed conversation history limit

Files Changed

  • app/src/components/ContextUsageIndicator.tsx
  • app/src/components/ModelSelector.tsx
  • app/src/contexts/ConversationContext.tsx
  • app/src/pages/ChatPage.tsx
  • backend/app/db/search.py
  • backend/app/main.py
  • backend/app/native_messaging.py
  • backend/app/routes/chat.py
  • backend/app/routes/settings.py
  • backend/app/services/ai.py
  • backend/app/services/embeddings.py
  • backend/app/services/query_processing.py

Test Plan

  • Verify context usage indicator shows approximate tokens with ~ prefix
  • Verify model selector doesn't flicker during polling
  • Test RAG retrieval with various query lengths
  • Verify logging output in backend for search operations
  • Test with long documents to verify embedding chunking works

Frontend:
- Replace API token counts with client-side estimation (~4 chars/token)
- Add ~ prefix to context indicator for approximate values
- Optimize ModelSelector to prevent unnecessary re-fetches

Backend:
- Add dynamic threshold-based memory filtering
- Add match type tracking (vector/keyword/hybrid) and RRF scores
- Add model-specific embedding context windows with chunking
- Add comprehensive logging throughout search pipeline
- Block all-minilm embedding model (context too small)
- Remove conversation history limit for fuller context
@comppaz
comppaz force-pushed the feat/rag-improvements-and-token-estimation branch from a6b4bc8 to 180351a Compare December 15, 2025 20:11
@comppaz
comppaz merged commit dcda806 into main Dec 15, 2025
@comppaz
comppaz deleted the feat/rag-improvements-and-token-estimation branch December 15, 2025 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant