Files
cherry-studio/packages
LiuVaayne 29af30b8d2 Feat/memory (#6454)
* feat(Memory): add memory management functionality with settings modal and integration into sidebar

* Add user memory search to chat completion flow

Enable assistants to use memory search results for more personalized
responses when enableMemory is true. Add enableMemory flag to Assistant
type.

* Add MemoryService and memory types interfaces

* Add memory settings tab to AssistantSettings

* feat(memory): implement Phase 1 core backend infrastructure

- Add Memory IPC channels for full CRUD operations
- Create main process MemoryService with LibSQL storage
- Implement memory database schema with history tracking
- Add IPC handlers for all memory operations
- Update preload API to expose memory functionality
- Update renderer MemoryService to use IPC instead of mock data
- Add comprehensive error handling and logging
- Support memory deduplication using SHA256 hashes
- Implement audit trail for all memory changes

Core features:
- Memory add/search/list/delete/update operations
- Full history tracking for changes
- User/agent/run filtering support
- Prepared for vector embeddings (Phase 2)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

*  feat: Implement memory vector search and hybrid search with LibSQL native vector support

- Implemented native vector support using `F32_BLOB` for storing embeddings directly in LibSQL.
- Created vector index using `libsql_vector_idx()` for efficient similarity search.
- Implemented `vectorSearch()` using `vector_top_k()` for fast nearest neighbor search based on cosine similarity.
- Implemented `hybridSearch()` combining text search and vector similarity search.
- Added `addBatchMemories()` to efficiently add multiple memories with embeddings.
- Added embedding model configuration via `setEmbeddingModel()`.
- Integrated embedding generation using `EmbeddingService`.
- Updated database schema with vector column and index.
- Added methods for embedding conversion and similarity calculations.
- Updated documentation with vector search details and schema changes.
- Improved memory management with embedding caching and clearing.
- Added `findSimilarMemories` to avoid duplicates
- Added embedding stats and cache methods

* feat(memory): add EmbeddingService and VectorSearch for memory embedding and search functionality

* fix(memory): update vector operations to match libsql documentation

- Fix vector32() function usage by removing quotes from embedding parameters
- Replace vector_top_k with standard queries to avoid index dependency
- Make embedding dimensions flexible by removing fixed 1536 dimension
- Add NULL checks for embeddings in all vector operations
- Update memory update method to regenerate embeddings
- Use parameterized queries to prevent SQL injection

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* update implement plan

* feat(memory): implement Phase 3 - UI and integration components

- Create Memory Page UI with full CRUD operations
  - Add, delete, search, and filter memories
  - User and date range filtering
  - Bulk operations support

- Implement Memory Processing Pipeline
  - Automatic fact extraction from conversations
  - Intelligent memory updates (add/update/delete)
  - Background processing for non-blocking UI

- Integrate memory search into ApiService
  - Inject relevant memories into conversation context
  - Post-conversation memory processing
  - Assistant-specific memory isolation

- Add Assistant Memory Settings
  - Toggle memory per assistant
  - View memory statistics
  - Configure from assistant settings panel

- Complete memory feature integration
  - Redux store already implemented
  - Memory service backend ready
  - Full end-to-end functionality

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* docs: update memory feature implementation plan to reflect Phase 3 completion

- Mark Phase 3 (UI and Integration) as completed
- Update implementation progress to 90%
- Document all completed components and features
- Add usage instructions for the memory feature
- List key implementation files for reference

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Revert "feat(memory): implement Phase 3 - UI and integration components"

This reverts commit 422463d0f7.

*  feat: Implement memory management for assistants

- Introduced `MemoryProcessor` to handle fact extraction, memory updates, and searches.
- Added `AssistantMemorySettings` component to allow enabling/disabling memory and viewing memory statistics.
- Integrated memory functionality with assistant settings.
- Implemented memory-related prompts and schema validation.
- Added memory service calls for adding, updating, deleting, and searching memories.

* fix: Update memory settings form handling in AssistantMemorySettings component

* feat(memory): implement Phase 3 - UI and integration components

- Create Memory Page UI with full CRUD operations
  - Add, delete, search, and filter memories
  - User and date range filtering
  - Bulk operations support

- Implement Memory Processing Pipeline
  - Automatic fact extraction from conversations
  - Intelligent memory updates (add/update/delete)
  - Background processing for non-blocking UI

- Integrate memory search into ApiService
  - Inject relevant memories into conversation context
  - Post-conversation memory processing
  - Assistant-specific memory isolation

- Add Assistant Memory Settings
  - Toggle memory per assistant
  - View memory statistics
  - Configure from assistant settings panel

- Complete memory feature integration
  - Redux store already implemented
  - Memory service backend ready
  - Full end-to-end functionality

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: update memory search method and integrate form handling in AssistantMemorySettings

* feat(memory): enhance memory service with new IPC channels and configuration updates

* refactor: remove VectorSearch service and update memory configuration methods

- Deleted the VectorSearch service implementation from the memory services.
- Updated the memory configuration method in the preload index from `updateConfig` to `setConfig`.
- Adjusted the corresponding call in the MemoryService to reflect the new method name.

* refactor(memory): remove embedding cache and related methods from MemoryService

* feat(memory): update MemoryService initialization to handle configuration updates and errors

* feat(memory): centralize SQL queries for MemoryService to improve maintainability

* feat: Enhance memory management with user context and CRUD operations

- Updated memory feature analysis with current implementation status and new functionalities.
- Added user context management, allowing automatic filtering based on selected user.
- Implemented full CRUD operations for memories, including add, edit, and delete functionalities.
- Introduced user management system with validation rules for user IDs.
- Enhanced internationalization support for memory features across multiple languages.
- Improved UI components for memory management, including user switching and memory editing modals.
- Updated MemoryService and MemoryProcessor to handle user-specific memory operations.
- Added comprehensive testing and documentation for new features.

* feat(memory): enhance UI components and user interactions in MemoriesPage

* feat(memory): integrate user context into memory operations and enhance user management

* feat(memory): add user deletion and reset functionality for specific users

* feat(memory): enhance localization for user management and memory operations in multiple languages

* feat(memory): remove reset functionality and add user listing feature in memory service

* feat(memory): enhance memory processing by adding fallback models and improving configuration handling

* feat(memory): refactor fact extraction and memory update logic to use fetchGenerate for LLM calls

* feat(memory): iinject memory to chat

* feat(memory): enhance memory handling by ensuring fallback to empty array and improving logging in memory search

* feat(memory): implement pagination for memory list operations

- Add offset parameter to MemoryListOptions interface for pagination support
- Update MemoryService.list() method to properly handle offset parameter
- Implement client-side pagination with 50 items per page default
- Add pagination controls with page size options (20, 50, 100, 200)
- Include pagination state management (currentPage, pageSize)
- Load all memories at once and paginate on client side for better search performance
- Reset pagination when switching users or performing searches
- Update memory CRUD operations to maintain current pagination state
- Add styled pagination component with consistent design

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(memory): correct state variable name in user switch handler

* feat(memory): add comprehensive memory feature guide in Chinese

* feat: Enhance memory management and citation handling

- Updated BaseApiClient to retrieve memory references from cache and format them for use.
- Modified CitationBlock to include memory references in rendering logic.
- Enhanced CitationsList to display memory citations with appropriate formatting.
- Improved MemoriesPage layout and functionality, including debounced search and user management.
- Refactored MemoryProcessor to handle memory updates and search queries more effectively.
- Updated API service to include memory in external tool results.
- Adjusted memory-related types and schemas for better integration.
- Enhanced createCitationBlock utility to accommodate memory data.

* feat(memory): update memory localization keys and descriptions for improved clarity

* feat(memory): add descriptions to memory localization files and improve error handling in MemoryService

*  style: Remove blank lines and fix typo in settings

- Removed blank lines in README files.
- Fixed a typo in the assistant settings label for the memory tab.

revert: revert format changes

revert: revert format changes

* feat(memory): enhance memory update logic and improve prompt clarity

* feat(memory): implement global memory toggle and enhance memory settings UI

* feat(memory): refine hybrid search to focus on vector similarity and update localization files

* feat(i18n): add memory configuration prompts in multiple languages

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-06-23 21:32:04 +08:00
..
2025-06-23 21:32:04 +08:00