Download packages/data-schemas/src/app/memory.ts from helloya20/chat: direct link, hf CLI and curl.
- Browser
- Download file 1.02 kB
-
https://huggingface.co/spaces/helloya20/chat/resolve/main/packages/data-schemas/src/app/memory.ts
- Command line
-
hf download hf://spaces/helloya20/chat/packages/data-schemas/src/app/memory.ts
-
curl -L -o memory.ts https://huggingface.co/spaces/helloya20/chat/resolve/main/packages/data-schemas/src/app/memory.ts
1.02 kB
| import { memorySchema } from 'librechat-data-provider'; | |
| import type { TCustomConfig, TMemoryConfig } from 'librechat-data-provider'; | |
| const hasValidAgent = (agent: TMemoryConfig['agent']) => | |
| !!agent && | |
| (('id' in agent && !!agent.id) || | |
| ('provider' in agent && 'model' in agent && !!agent.provider && !!agent.model)); | |
| const isDisabled = (config?: TMemoryConfig | TCustomConfig['memory']) => | |
| !config || config.disabled === true; | |
| export function loadMemoryConfig(config: TCustomConfig['memory']): TMemoryConfig | undefined { | |
| if (!config) return undefined; | |
| if (isDisabled(config)) return config as TMemoryConfig; | |
| if (!hasValidAgent(config.agent)) { | |
| return { ...config, disabled: true } as TMemoryConfig; | |
| } | |
| const charLimit = memorySchema.shape.charLimit.safeParse(config.charLimit).data ?? 10000; | |
| return { ...config, charLimit }; | |
| } | |
| export function isMemoryEnabled(config: TMemoryConfig | undefined): boolean { | |
| if (isDisabled(config)) return false; | |
| return hasValidAgent(config!.agent); | |
| } | |