The HTTP backend was receiving [object Object] because:
- The
ragContextwasn't being properly included in the request body - The data structure from Tauri (snake_case) didn't match backend expectations (camelCase)
File: src/lib/aiHttpApi.ts
- Explicitly included
ragContextin the request body - Added logging to track context transmission
body: JSON.stringify({
...request,
ragContext: request.ragContext, // Explicitly include
stream: false
})File: src/lib/aiApiSelector.ts
- Transform Tauri's snake_case format to backend's camelCase format
- Convert contexts from array of objects to array of strings
Transformation:
// From Tauri (snake_case)
{
contexts: [{ content: "...", note_id: "..." }],
citations: [{
note_id: "...",
note_title: "...",
chunk_preview: "...",
relevance_score: 0.95
}]
}
// To Backend (camelCase)
{
contexts: ["..."], // Just the content strings
citations: [{
noteId: "...",
title: "...",
excerpt: "...",
relevance: 0.95
}]
}- Detects
/askcommand - Sets activeRagRequestId (prevents duplicates)
- Calls aiApi.chatStreamRag
- Detects cloud model (e.g., gpt-4o-mini)
- Calls ragSearchOnly for local search (NO Ollama)
- Transforms data structure for backend
- Sends to HTTP backend
[timestamp] [INFO] [ai::rag::search] π RAG search-only request
[timestamp] [INFO] [ai::rag] RAG search complete - Found 6 contexts
- Performs semantic search using embeddings
- Returns contexts WITHOUT generation
- No Ollama call
- Receives properly formatted context
- Enhances messages with context
- Generates response using cloud model
- Returns single response
β
No more [object Object] errors
β
No Ollama calls for cloud models
β
Single response (no duplicates)
β
Proper context transformation
β
Citations preserved and displayed
β
Comprehensive logging throughout
- Configure gpt-4o-mini (or any cloud model)
- Type:
/ask hi - Check console for proper flow
- Verify single response with citations
src-tauri/src/commands/ai.rs- Added ai_rag_search_onlysrc-tauri/src/logging.rs- New logging modulesrc/lib/aiApiSelector.ts- Fixed hybrid RAG & data transformationsrc/lib/aiHttpApi.ts- Fixed context inclusionsrc/lib/aiApi.ts- Added ragSearchOnly methodsrc/stores/aiStore.ts- Added deduplication
β Privacy: Notes stay local, only context sent to cloud β Performance: No unnecessary Ollama calls β Correctness: Proper model routing β Reliability: No duplicate requests β Debugging: Comprehensive timestamped logs