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:
@@ -4,11 +4,10 @@ import "maps"
|
||||
|
||||
// PipelineRequest holds immutable configuration set once at the request entry point.
|
||||
type PipelineRequest struct {
|
||||
SessionID string `json:"session_id"`
|
||||
UserID string `json:"user_id"`
|
||||
Query string `json:"query,omitempty"`
|
||||
EnableMemory bool `json:"enable_memory"`
|
||||
MaxRounds int `json:"max_rounds"`
|
||||
SessionID string `json:"session_id"`
|
||||
UserID string `json:"user_id"`
|
||||
Query string `json:"query,omitempty"`
|
||||
MaxRounds int `json:"max_rounds"`
|
||||
|
||||
// Knowledge base retrieval parameters
|
||||
KnowledgeBaseIDs []string `json:"knowledge_base_ids"`
|
||||
@@ -204,7 +203,6 @@ func (c *ChatManage) Clone() *ChatManage {
|
||||
Query: c.Query,
|
||||
SessionID: c.SessionID,
|
||||
UserID: c.UserID,
|
||||
EnableMemory: c.EnableMemory,
|
||||
MaxRounds: c.MaxRounds,
|
||||
KnowledgeBaseIDs: knowledgeBaseIDs,
|
||||
KnowledgeIDs: knowledgeIDs,
|
||||
@@ -275,8 +273,6 @@ const (
|
||||
CHAT_COMPLETION EventType = "chat_completion"
|
||||
CHAT_COMPLETION_STREAM EventType = "chat_completion_stream"
|
||||
FILTER_TOP_K EventType = "filter_top_k"
|
||||
MEMORY_RETRIEVAL EventType = "memory_retrieval"
|
||||
MEMORY_STORAGE EventType = "memory_storage"
|
||||
)
|
||||
|
||||
// PipelineBuilder dynamically assembles a pipeline as an ordered list of EventTypes.
|
||||
@@ -321,9 +317,7 @@ var Pipeline = map[string][]EventType{
|
||||
},
|
||||
"chat_history_stream": {
|
||||
LOAD_HISTORY,
|
||||
MEMORY_RETRIEVAL,
|
||||
CHAT_COMPLETION_STREAM,
|
||||
MEMORY_STORAGE,
|
||||
},
|
||||
"rag": {
|
||||
CHUNK_SEARCH,
|
||||
|
||||
@@ -27,7 +27,6 @@ type EmbedChannel struct {
|
||||
ShowSuggestedQuestions bool `json:"show_suggested_questions" gorm:"not null;default:true"`
|
||||
WidgetPosition string `json:"widget_position" gorm:"type:varchar(32);not null;default:'bottom-right'"`
|
||||
AllowWebSearch bool `json:"allow_web_search" gorm:"not null;default:false"`
|
||||
AllowMemory bool `json:"allow_memory" gorm:"not null;default:false"`
|
||||
AllowFileUpload bool `json:"allow_file_upload" gorm:"not null;default:false"`
|
||||
DefaultLocale string `json:"default_locale" gorm:"type:varchar(16);not null;default:''"`
|
||||
WebhookURL string `json:"webhook_url" gorm:"type:varchar(512);not null;default:''"`
|
||||
@@ -119,7 +118,6 @@ type EmbedChannelPublicConfig struct {
|
||||
AllowedOrigins []string `json:"allowed_origins,omitempty"`
|
||||
WidgetPosition string `json:"widget_position,omitempty"`
|
||||
AllowWebSearch bool `json:"allow_web_search"`
|
||||
AllowMemory bool `json:"allow_memory"`
|
||||
AllowFileUpload bool `json:"allow_file_upload"`
|
||||
// AgentWebSearchEnabled reflects whether the bound agent has web search configured.
|
||||
AgentWebSearchEnabled bool `json:"agent_web_search_enabled"`
|
||||
|
||||
@@ -22,7 +22,7 @@ type EmbedChannelService interface {
|
||||
Create(ctx context.Context, tenantID uint64, agentID string, req *types.EmbedChannel) (*types.EmbedChannel, string, error)
|
||||
ListByAgent(ctx context.Context, tenantID uint64, agentID string) ([]*types.EmbedChannel, error)
|
||||
ListByTenant(ctx context.Context, tenantID uint64) ([]*types.EmbedChannel, error)
|
||||
Update(ctx context.Context, tenantID uint64, id string, req *types.EmbedChannel, enabled *bool, showSuggested *bool, allowWebSearch *bool, allowMemory *bool, allowFileUpload *bool, defaultLocale *string, webhookURL *string, webhookSecret *string) (*types.EmbedChannel, error)
|
||||
Update(ctx context.Context, tenantID uint64, id string, req *types.EmbedChannel, enabled *bool, showSuggested *bool, allowWebSearch *bool, allowFileUpload *bool, defaultLocale *string, webhookURL *string, webhookSecret *string) (*types.EmbedChannel, error)
|
||||
Delete(ctx context.Context, tenantID uint64, id string) error
|
||||
RotateToken(ctx context.Context, tenantID uint64, id string) (*types.EmbedChannel, string, error)
|
||||
LookupForEmbed(ctx context.Context, channelID, token string) (*types.EmbedChannel, error)
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
package interfaces
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
)
|
||||
|
||||
// MemoryService defines the interface for the memory system
|
||||
type MemoryService interface {
|
||||
// AddEpisode processes a conversation session and adds it as an episode to the memory graph
|
||||
AddEpisode(ctx context.Context, userID string, sessionID string, messages []types.Message) error
|
||||
|
||||
// RetrieveMemory retrieves relevant memory context based on the current query and user
|
||||
RetrieveMemory(ctx context.Context, userID string, query string) (*types.MemoryContext, error)
|
||||
}
|
||||
|
||||
// MemoryRepository defines the interface for storing and retrieving memory data
|
||||
type MemoryRepository interface {
|
||||
// SaveEpisode saves an episode and its associated entities and relationships to the graph
|
||||
SaveEpisode(ctx context.Context, episode *types.Episode, entities []*types.Entity, relations []*types.Relationship) error
|
||||
|
||||
// FindRelatedEpisodes finds episodes related to the given keywords for a specific user
|
||||
FindRelatedEpisodes(ctx context.Context, userID string, keywords []string, limit int) ([]*types.Episode, error)
|
||||
|
||||
// IsAvailable checks if the memory repository is available
|
||||
IsAvailable(ctx context.Context) bool
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package types
|
||||
|
||||
import "time"
|
||||
|
||||
// Episode represents a conversation episode or a distinct interaction event
|
||||
type Episode struct {
|
||||
ID string `json:"id"`
|
||||
UserID string `json:"user_id"`
|
||||
SessionID string `json:"session_id"`
|
||||
Summary string `json:"summary"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// MemoryContext represents the retrieved memory context for a conversation
|
||||
type MemoryContext struct {
|
||||
RelatedEpisodes []Episode `json:"related_episodes"`
|
||||
RelatedEntities []Entity `json:"related_entities"`
|
||||
RelatedRelations []Relationship `json:"related_relations"`
|
||||
}
|
||||
@@ -18,7 +18,6 @@ type QARequest struct {
|
||||
ImageDescription string // VLM-generated image description (fallback for non-vision models)
|
||||
UserMessageID string // Created user message ID
|
||||
WebSearchEnabled bool // Whether web search is enabled for this request
|
||||
EnableMemory bool // Whether memory feature is enabled
|
||||
QuotedContext string // Quoted message content from IM quote-reply (appended at LLM prompt stage, not used for retrieval)
|
||||
Attachments MessageAttachments // File attachments (processed and ready for prompt injection)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// UserPreferences holds per-user UI/feature preferences persisted server-side
|
||||
// UserPreferences holds per-user preferences persisted server-side
|
||||
// so they sync across devices/browsers. Fields are pointers so we can
|
||||
// distinguish "client didn't send this key" (leave existing value alone)
|
||||
// from "client explicitly set false" — the partial-update merge in
|
||||
@@ -22,11 +22,6 @@ import (
|
||||
//
|
||||
// No DB DDL is required — preferences is a single jsonb column.
|
||||
type UserPreferences struct {
|
||||
// EnableMemory mirrors the "开启记忆功能" switch in General Settings.
|
||||
// nil = preference never set (treat as feature default = false)
|
||||
// *false / *true = user explicitly set the toggle.
|
||||
EnableMemory *bool `json:"enable_memory,omitempty"`
|
||||
|
||||
// LastActiveTenantID remembers the last workspace the user actively
|
||||
// switched into, so a fresh login (new device, cleared browser, new
|
||||
// refresh token) lands them back in that workspace instead of always
|
||||
@@ -95,7 +90,7 @@ type User struct {
|
||||
CanAccessAllTenants bool `json:"can_access_all_tenants" gorm:"default:false"`
|
||||
// Whether the user is a system administrator (independent of workspace roles)
|
||||
IsSystemAdmin bool `json:"is_system_admin" gorm:"default:false;index"`
|
||||
// Per-user UI/feature preferences (memory toggle, future knobs).
|
||||
// Per-user UI/feature preferences.
|
||||
// Stored as JSON (jsonb on Postgres, TEXT on SQLite) via the
|
||||
// driver.Valuer / sql.Scanner methods on UserPreferences.
|
||||
Preferences UserPreferences `json:"preferences" gorm:"type:jsonb;not null;default:'{}'"`
|
||||
|
||||
Reference in New Issue
Block a user