refactor: remove Neo4j-based conversation memory feature
Drop the memory pipeline, API fields, settings UI, and embed toggles so chat no longer depends on Neo4j graph storage for episodic recall.
This commit is contained in:
@@ -29,7 +29,6 @@ type Handler struct {
|
||||
fileService interfaces.FileService // Service for file storage (image uploads)
|
||||
storageResolver interfaces.StorageBackendResolver
|
||||
modelService interfaces.ModelService // Service for model management (VLM access)
|
||||
userService interfaces.UserService // Service for resolving per-user preferences (e.g. enable_memory default)
|
||||
attachmentProcessor *AttachmentProcessor // Processor for file attachments
|
||||
temporaryDocuments interfaces.TemporaryDocumentService
|
||||
}
|
||||
@@ -49,7 +48,6 @@ func NewHandler(
|
||||
fileService interfaces.FileService,
|
||||
storageResolver interfaces.StorageBackendResolver,
|
||||
modelService interfaces.ModelService,
|
||||
userService interfaces.UserService,
|
||||
documentReader interfaces.DocumentReader,
|
||||
imageResolver *docparser.ImageResolver,
|
||||
temporaryDocuments interfaces.TemporaryDocumentService,
|
||||
@@ -68,7 +66,6 @@ func NewHandler(
|
||||
fileService: fileService,
|
||||
storageResolver: storageResolver,
|
||||
modelService: modelService,
|
||||
userService: userService,
|
||||
temporaryDocuments: temporaryDocuments,
|
||||
attachmentProcessor: NewAttachmentProcessor(
|
||||
fileService,
|
||||
|
||||
@@ -41,7 +41,6 @@ type qaRequestContext struct {
|
||||
skillNames []string
|
||||
summaryModelID string
|
||||
webSearchEnabled bool
|
||||
enableMemory bool // Whether memory feature is enabled
|
||||
mentionedItems types.MentionedItems
|
||||
effectiveTenantID uint64 // when using shared agent, tenant ID for model/KB/MCP resolution; 0 = use context tenant
|
||||
images []ImageAttachment // Uploaded images with analysis text
|
||||
@@ -77,7 +76,6 @@ func (rc *qaRequestContext) buildQARequest() *types.QARequest {
|
||||
ImageDescription: imageDescription,
|
||||
UserMessageID: rc.userMessageID,
|
||||
WebSearchEnabled: rc.webSearchEnabled,
|
||||
EnableMemory: rc.enableMemory,
|
||||
Attachments: rc.attachments,
|
||||
}
|
||||
}
|
||||
@@ -286,17 +284,6 @@ func (h *Handler) parseQARequest(c *gin.Context, logPrefix string) (*qaRequestCo
|
||||
attachmentIDs = normalizedIDs
|
||||
}
|
||||
|
||||
// Resolve enable_memory:
|
||||
// 1. Explicit value in request → honour it. Used by embedded mode
|
||||
// (force false) and by older clients still sending the literal bool.
|
||||
// 2. Not set → fall back to the calling user's stored preference.
|
||||
// The toggle is persisted server-side per user (see PUT
|
||||
// /auth/me/preferences); this is the canonical path for the
|
||||
// normal logged-in web UI now that it no longer sends the field.
|
||||
// 3. No user / no preference → false. API-key-only callers never
|
||||
// had memory enabled in practice, keep that behaviour.
|
||||
enableMemory := h.resolveEnableMemory(ctx, request.EnableMemory)
|
||||
|
||||
mentionScopes := tagScopesFromMentionedItems(request.MentionedItems)
|
||||
requestTagIDs := dedupRequestStrings(request.TagIDs)
|
||||
if err := validateUnscopedTagIDs(orphanTagIDsForScope(requestTagIDs, mentionScopes), secutils.SanitizeForLogArray(kbIDs)); err != nil {
|
||||
@@ -349,7 +336,6 @@ func (h *Handler) parseQARequest(c *gin.Context, logPrefix string) (*qaRequestCo
|
||||
skillNames: secutils.SanitizeForLogArray(skillNames),
|
||||
summaryModelID: secutils.SanitizeForLog(request.SummaryModelID),
|
||||
webSearchEnabled: request.WebSearchEnabled,
|
||||
enableMemory: enableMemory,
|
||||
mentionedItems: convertMentionedItems(request.MentionedItems),
|
||||
effectiveTenantID: effectiveTenantID,
|
||||
images: request.Images,
|
||||
@@ -456,32 +442,6 @@ func cloneTagScopes(scopes []types.TagScope) []types.TagScope {
|
||||
return cloned
|
||||
}
|
||||
|
||||
// resolveEnableMemory decides whether the memory pipeline runs for this
|
||||
// request. See the call-site comment in parseQARequest for the resolution
|
||||
// order. Lookup errors are logged but never propagate — a failure to read
|
||||
// the user's preference shouldn't break the chat request itself, we just
|
||||
// fall back to false (the safe default).
|
||||
func (h *Handler) resolveEnableMemory(ctx context.Context, override *bool) bool {
|
||||
if override != nil {
|
||||
return *override
|
||||
}
|
||||
if h.userService == nil {
|
||||
return false
|
||||
}
|
||||
user, err := h.userService.GetCurrentUser(ctx)
|
||||
if err != nil {
|
||||
// API-key-only callers or revoked sessions land here; the chat
|
||||
// request itself stays authorised via the middleware that already
|
||||
// ran, we just have nobody to look preferences up for.
|
||||
logger.Debugf(ctx, "enable_memory: no user in context, defaulting to false: %v", err)
|
||||
return false
|
||||
}
|
||||
if user.Preferences.EnableMemory != nil {
|
||||
return *user.Preferences.EnableMemory
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// resolveAgent resolves the custom agent by ID, trying shared agent first, then own agent.
|
||||
// Returns (nil, 0) if agentID is empty or not found.
|
||||
func (h *Handler) resolveAgent(ctx context.Context, c *gin.Context, agentID string) (*types.CustomAgent, uint64) {
|
||||
|
||||
@@ -42,34 +42,22 @@ type ImageAttachment struct {
|
||||
|
||||
// CreateKnowledgeQARequest defines the request structure for knowledge QA
|
||||
type CreateKnowledgeQARequest struct {
|
||||
Query string `json:"query" binding:"required"` // Query text for knowledge base search
|
||||
KnowledgeBaseIDs []string `json:"knowledge_base_ids"` // Selected knowledge base ID for this request
|
||||
KnowledgeIds []string `json:"knowledge_ids"` // Selected knowledge ID for this request
|
||||
AgentEnabled bool `json:"agent_enabled"` // Whether agent mode is enabled for this request
|
||||
AgentID string `json:"agent_id"` // Selected custom agent ID (backend resolves shared agent and its workspace from share relation)
|
||||
WebSearchEnabled bool `json:"web_search_enabled"` // Whether web search is enabled for this request
|
||||
SummaryModelID string `json:"summary_model_id"` // Optional summary model ID for this request (overrides session default)
|
||||
MCPServiceIDs []string `json:"mcp_service_ids"` // Per-request MCP services selected via @mention
|
||||
SkillNames []string `json:"skill_names"` // Per-request Skills selected via @mention
|
||||
TagIDs []string `json:"tag_ids"` // @mentioned tag IDs (display/debug; scoped via MentionedItems)
|
||||
MentionedItems []MentionedItemRequest `json:"mentioned_items"` // @mentioned knowledge bases and files
|
||||
DisableTitle bool `json:"disable_title"` // Whether to disable auto title generation
|
||||
// EnableMemory is the per-request override for the memory feature.
|
||||
// Pointer + omitempty so the request can distinguish three states:
|
||||
// nil = client did not specify; backend falls back to the calling
|
||||
// user's persisted preference (user.preferences.enable_memory),
|
||||
// defaulting to false if that's also unset. This is the path
|
||||
// used by the normal logged-in chat UI now that the toggle is
|
||||
// stored server-side per user.
|
||||
// *true / *false = explicit override. Embedded mode forces *false so a
|
||||
// user's personal memory setting doesn't leak into a widget
|
||||
// context; older clients that still send a literal bool also
|
||||
// land here (back-compat).
|
||||
EnableMemory *bool `json:"enable_memory,omitempty"`
|
||||
Images []ImageAttachment `json:"images"` // Attached images for multimodal chat
|
||||
AttachmentUploads []AttachmentUpload `json:"attachment_uploads,omitempty"` // Attached files (documents, audio, etc.)
|
||||
AttachmentIDs []string `json:"attachment_ids,omitempty"` // Pre-uploaded session-scoped document IDs
|
||||
Channel string `json:"channel"` // Source channel: "web", "api", "im", etc.
|
||||
Query string `json:"query" binding:"required"` // Query text for knowledge base search
|
||||
KnowledgeBaseIDs []string `json:"knowledge_base_ids"` // Selected knowledge base ID for this request
|
||||
KnowledgeIds []string `json:"knowledge_ids"` // Selected knowledge ID for this request
|
||||
AgentEnabled bool `json:"agent_enabled"` // Whether agent mode is enabled for this request
|
||||
AgentID string `json:"agent_id"` // Selected custom agent ID (backend resolves shared agent and its workspace from share relation)
|
||||
WebSearchEnabled bool `json:"web_search_enabled"` // Whether web search is enabled for this request
|
||||
SummaryModelID string `json:"summary_model_id"` // Optional summary model ID for this request (overrides session default)
|
||||
MCPServiceIDs []string `json:"mcp_service_ids"` // Per-request MCP services selected via @mention
|
||||
SkillNames []string `json:"skill_names"` // Per-request Skills selected via @mention
|
||||
TagIDs []string `json:"tag_ids"` // @mentioned tag IDs (display/debug; scoped via MentionedItems)
|
||||
MentionedItems []MentionedItemRequest `json:"mentioned_items"` // @mentioned knowledge bases and files
|
||||
DisableTitle bool `json:"disable_title"` // Whether to disable auto title generation
|
||||
Images []ImageAttachment `json:"images"` // Attached images for multimodal chat
|
||||
AttachmentUploads []AttachmentUpload `json:"attachment_uploads,omitempty"` // Attached files (documents, audio, etc.)
|
||||
AttachmentIDs []string `json:"attachment_ids,omitempty"` // Pre-uploaded session-scoped document IDs
|
||||
Channel string `json:"channel"` // Source channel: "web", "api", "im", etc.
|
||||
SuggestionAttribution *types.SuggestionAttribution `json:"suggestion_attribution,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user