Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

refactor(userMemories): should use MemorySourceType (#10921)

Nekoa6be1a7f750b
diff --git a/src/app/(backend)/api/workflows/memory-user-memory/pipelines/chat-topic/process-topic/route.ts b/src/app/(backend)/api/workflows/memory-user-memory/pipelines/chat-topic/process-topic/route.ts
index afdd7f22040..f0a88e24ac9 100644
--- a/src/app/(backend)/api/workflows/memory-user-memory/pipelines/chat-topic/process-topic/route.ts
+++ b/src/app/(backend)/api/workflows/memory-user-memory/pipelines/chat-topic/process-topic/route.ts
@@ -5,6 +5,7 @@ import {
MemoryExtractionPayloadInput,
normalizeMemoryExtractionPayload,
} from '@/server/services/memory/userMemory/extract';
+import { MemorySourceType } from '@lobechat/types';
export const { POST } = serve<MemoryExtractionPayloadInput>(async (context) => {
const params = normalizeMemoryExtractionPayload(context.requestPayload || {});
@@ -14,7 +15,7 @@ export const { POST } = serve<MemoryExtractionPayloadInput>(async (context) => {
if (!params.topicIds.length) {
return { message: 'No topic ids provided for extraction.' };
}
- if (!params.sources.includes('chat_topic')) {
+ if (!params.sources.includes(MemorySourceType.ChatTopic)) {
return { message: 'Source not supported in topic batch.' };
}
@@ -32,7 +33,7 @@ export const { POST } = serve<MemoryExtractionPayloadInput>(async (context) => {
forceTopics: params.forceTopics,
from: params.from,
layers: params.layers,
- source: 'chat_topic',
+ source: MemorySourceType.ChatTopic,
to: params.to,
topicId,
userId,
diff --git a/src/app/(backend)/api/workflows/memory-user-memory/pipelines/chat-topic/process-user-topics/route.ts b/src/app/(backend)/api/workflows/memory-user-memory/pipelines/chat-topic/process-user-topics/route.ts
index 026489914ab..444e0058c5d 100644
--- a/src/app/(backend)/api/workflows/memory-user-memory/pipelines/chat-topic/process-user-topics/route.ts
+++ b/src/app/(backend)/api/workflows/memory-user-memory/pipelines/chat-topic/process-user-topics/route.ts
@@ -9,6 +9,7 @@ import {
buildWorkflowPayloadInput,
normalizeMemoryExtractionPayload,
} from '@/server/services/memory/userMemory/extract';
+import { MemorySourceType } from '@lobechat/types';
const TOPIC_PAGE_SIZE = 50;
const TOPIC_BATCH_SIZE = 10;
@@ -18,7 +19,7 @@ export const { POST } = serve<MemoryExtractionPayloadInput>(async (context) => {
if (!params.userIds.length) {
return { message: 'No user ids provided for topic processing.' };
}
- if (!params.sources.includes('chat_topic')) {
+ if (!params.sources.includes(MemorySourceType.ChatTopic)) {
return { message: 'No supported sources requested, skip topic processing.' };
}
diff --git a/src/app/(backend)/api/workflows/memory-user-memory/pipelines/chat-topic/process-users/route.ts b/src/app/(backend)/api/workflows/memory-user-memory/pipelines/chat-topic/process-users/route.ts
index 1bd596ccacc..8c06e2e7c8e 100644
--- a/src/app/(backend)/api/workflows/memory-user-memory/pipelines/chat-topic/process-users/route.ts
+++ b/src/app/(backend)/api/workflows/memory-user-memory/pipelines/chat-topic/process-users/route.ts
@@ -8,6 +8,7 @@ import {
buildWorkflowPayloadInput,
normalizeMemoryExtractionPayload,
} from '@/server/services/memory/userMemory/extract';
+import { MemorySourceType } from '@lobechat/types';
const USER_PAGE_SIZE = 50;
const USER_BATCH_SIZE = 10;