mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-08 06:19:05 +08:00
feat: improve memory service logging and per-assistant configuration
- Enhance memory search logging with structured context in MemoryProcessor - Add per-assistant memory configuration support in MemoryService - Reduce log verbosity in StreamProcessingService (debug to silly) - Fix memory search to use assistant's memoryUserId when available 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
7328664edf
commit
3aec08d650
@ -238,12 +238,10 @@ export class MemoryProcessor {
|
|||||||
limit
|
limit
|
||||||
})
|
})
|
||||||
|
|
||||||
logger.debug(
|
logger.debug('Searching memories successful', { query, userId, assistantId, result })
|
||||||
`Searching memories with query: ${query} for user: ${userId} and assistant: ${assistantId} result: ${result}`
|
|
||||||
)
|
|
||||||
return result.results
|
return result.results
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('Error searching memories:', error as Error)
|
logger.error('Searching memories error:', { error })
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,8 @@ import {
|
|||||||
MemorySearchResult
|
MemorySearchResult
|
||||||
} from '@types'
|
} from '@types'
|
||||||
|
|
||||||
|
import { getAssistantById } from './AssistantService'
|
||||||
|
|
||||||
const logger = loggerService.withContext('MemoryService')
|
const logger = loggerService.withContext('MemoryService')
|
||||||
|
|
||||||
// Main process SearchResult type (matches what the IPC actually returns)
|
// Main process SearchResult type (matches what the IPC actually returns)
|
||||||
@ -186,6 +188,16 @@ class MemoryService {
|
|||||||
userId: this.currentUserId
|
userId: this.currentUserId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If agentId is provided, resolve userId from assistant's memoryUserId
|
||||||
|
if (optionsWithUser.agentId) {
|
||||||
|
const assistant = getAssistantById(optionsWithUser.agentId)
|
||||||
|
if (assistant) {
|
||||||
|
optionsWithUser.userId = assistant.memoryUserId || this.currentUserId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug('Searching memories start with options', { query: query, options: optionsWithUser })
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result: SearchResult = await window.api.memory.search(query, optionsWithUser)
|
const result: SearchResult = await window.api.memory.search(query, optionsWithUser)
|
||||||
|
|
||||||
|
|||||||
@ -51,7 +51,7 @@ export function createStreamProcessor(callbacks: StreamProcessorCallbacks = {})
|
|||||||
return (chunk: Chunk) => {
|
return (chunk: Chunk) => {
|
||||||
try {
|
try {
|
||||||
const data = chunk
|
const data = chunk
|
||||||
logger.debug('data: ', data)
|
logger.silly('data: ', data)
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case ChunkType.BLOCK_COMPLETE: {
|
case ChunkType.BLOCK_COMPLETE: {
|
||||||
if (callbacks.onComplete) callbacks.onComplete(AssistantMessageStatus.SUCCESS, data?.response)
|
if (callbacks.onComplete) callbacks.onComplete(AssistantMessageStatus.SUCCESS, data?.response)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user