mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-17 11:44:44 +08:00
feat: add memory settings page
This commit is contained in:
9
frontend/src/core/memory/api.ts
Normal file
9
frontend/src/core/memory/api.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { getBackendBaseURL } from "../config";
|
||||
|
||||
import type { UserMemory } from "./types";
|
||||
|
||||
export async function loadMemory() {
|
||||
const memory = await fetch(`${getBackendBaseURL()}/api/memory`);
|
||||
const json = await memory.json();
|
||||
return json as UserMemory;
|
||||
}
|
||||
11
frontend/src/core/memory/hooks.ts
Normal file
11
frontend/src/core/memory/hooks.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { loadMemory } from "./api";
|
||||
|
||||
export function useMemory() {
|
||||
const { data, isLoading, error } = useQuery({
|
||||
queryKey: ["memory"],
|
||||
queryFn: () => loadMemory(),
|
||||
});
|
||||
return { memory: data ?? null, isLoading, error };
|
||||
}
|
||||
2
frontend/src/core/memory/index.ts
Normal file
2
frontend/src/core/memory/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./api";
|
||||
export * from "./types";
|
||||
40
frontend/src/core/memory/types.ts
Normal file
40
frontend/src/core/memory/types.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
export interface UserMemory {
|
||||
version: string;
|
||||
lastUpdated: string;
|
||||
user: {
|
||||
workContext: {
|
||||
summary: string;
|
||||
updatedAt: string;
|
||||
};
|
||||
personalContext: {
|
||||
summary: string;
|
||||
updatedAt: string;
|
||||
};
|
||||
topOfMind: {
|
||||
summary: string;
|
||||
updatedAt: string;
|
||||
};
|
||||
};
|
||||
history: {
|
||||
recentMonths: {
|
||||
summary: string;
|
||||
updatedAt: string;
|
||||
};
|
||||
earlierContext: {
|
||||
summary: string;
|
||||
updatedAt: string;
|
||||
};
|
||||
longTermBackground: {
|
||||
summary: string;
|
||||
updatedAt: string;
|
||||
};
|
||||
};
|
||||
facts: {
|
||||
id: string;
|
||||
content: string;
|
||||
category: string;
|
||||
confidence: number;
|
||||
createdAt: string;
|
||||
source: string;
|
||||
}[];
|
||||
}
|
||||
Reference in New Issue
Block a user