Add opt-in use_conversation_context flag for chat history (#33) #73

Merged
westfarn merged 1 commits from feat/33-conversation-context-rag into master 2026-08-04 06:27:44 -07:00
Owner

Summary

  • Closes #33 — per-user use_conversation_context boolean on CustomUser (default false, opt-in).
  • Migration 0034_customuser_use_conversation_context.
  • GET/POST /api/conversation_preferences reads/writes the flag; POST sets absolute boolean without toggling conversation_order when only this field is sent.
  • Chat + document RAG paths skip prior-turn history when the flag is off (AsyncLLMService, AsyncRAGService, both WS consumers).

Frontend contract

  • Field: use_conversation_context (boolean, default false)
  • Read: GET /api/conversation_preferences{ order, use_conversation_context }
  • Write: POST /api/conversation_preferences with { "use_conversation_context": true|false }
  • Tooltip copy: use previous conversations to better customize the experience
  • Counterpart: chat_web_app#66

Test plan

  • manage.py test chat_backend.tests.test_models chat_backend.tests.test_views_conversations.ConversationPreferencesTestCase chat_backend.tests.test_services_llm chat_backend.tests.test_services_rag
  • New user / unset flag → use_conversation_context is false; history empty in LLM/RAG prompts
  • Enable via preferences API → prior turns appear in history
  • Disable again → history skipped; order preference unchanged when posting only the context flag
## Summary - Closes [#33](https://git.aimloperations.com/ai_ml_operations/chat_backend/issues/33) — per-user `use_conversation_context` boolean on `CustomUser` (default `false`, opt-in). - Migration `0034_customuser_use_conversation_context`. - `GET/POST /api/conversation_preferences` reads/writes the flag; POST sets absolute boolean without toggling `conversation_order` when only this field is sent. - Chat + document RAG paths skip prior-turn history when the flag is off (`AsyncLLMService`, `AsyncRAGService`, both WS consumers). ## Frontend contract - Field: `use_conversation_context` (boolean, default false) - Read: `GET /api/conversation_preferences` → `{ order, use_conversation_context }` - Write: `POST /api/conversation_preferences` with `{ "use_conversation_context": true|false }` - Tooltip copy: use previous conversations to better customize the experience - Counterpart: [chat_web_app#66](https://git.aimloperations.com/ai_ml_operations/chat_web_app/issues/66) ## Test plan - [ ] `manage.py test chat_backend.tests.test_models chat_backend.tests.test_views_conversations.ConversationPreferencesTestCase chat_backend.tests.test_services_llm chat_backend.tests.test_services_rag` - [ ] New user / unset flag → `use_conversation_context` is false; history empty in LLM/RAG prompts - [ ] Enable via preferences API → prior turns appear in history - [ ] Disable again → history skipped; order preference unchanged when posting only the context flag
westfarn added 1 commit 2026-08-04 06:26:41 -07:00
Add opt-in use_conversation_context flag for chat history (#33).
CI / test (pull_request) Successful in 11s
Unit Tests / test (pull_request) Successful in 11s
35ffd590ba
Default-off user preference gates prior-turn history in LLM/RAG prompts;
expose via conversation_preferences GET/POST for the frontend toggle.
westfarn force-pushed feat/33-conversation-context-rag from 55b615bb5b to 35ffd590ba 2026-08-04 06:26:41 -07:00 Compare
westfarn merged commit ab3dfffa6b into master 2026-08-04 06:27:44 -07:00
westfarn deleted branch feat/33-conversation-context-rag 2026-08-04 06:27:45 -07:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ai_ml_operations/chat_backend#73