Spaces:
Runtime error
Runtime error
Download apps/webapp/app/trigger/chat/memory-utils.ts from BTankut/Context-Store-LLM: direct link, hf CLI and curl.
- Browser
- Download file 1.28 kB
-
https://huggingface.co/spaces/BTankut/Context-Store-LLM/resolve/main/apps/webapp/app/trigger/chat/memory-utils.ts
- Command line
-
hf download hf://spaces/BTankut/Context-Store-LLM/apps/webapp/app/trigger/chat/memory-utils.ts
-
curl -L -o memory-utils.ts https://huggingface.co/spaces/BTankut/Context-Store-LLM/resolve/main/apps/webapp/app/trigger/chat/memory-utils.ts
1.28 kB
| import { logger } from "@trigger.dev/sdk/v3"; | |
| import axios from "axios"; | |
| // Memory API functions using axios interceptor | |
| export interface SearchMemoryParams { | |
| query: string; | |
| validAt?: string; | |
| startTime?: string; | |
| endTime?: string; | |
| } | |
| export interface AddMemoryParams { | |
| message: string; | |
| referenceTime?: string; | |
| spaceId?: string; | |
| sessionId?: string; | |
| metadata?: any; | |
| } | |
| export const searchMemory = async (params: SearchMemoryParams) => { | |
| try { | |
| const response = await axios.post( | |
| "https://core::memory/api/v1/search", | |
| params, | |
| ); | |
| return response.data; | |
| } catch (error) { | |
| logger.error("Memory search failed", { error, params }); | |
| return { error: "Memory search failed" }; | |
| } | |
| }; | |
| export const addMemory = async (params: AddMemoryParams) => { | |
| try { | |
| // Set defaults for required fields | |
| const memoryInput = { | |
| ...params, | |
| episodeBody: params.message, | |
| referenceTime: params.referenceTime || new Date().toISOString(), | |
| source: "CORE", | |
| }; | |
| const response = await axios.post( | |
| "https://core::memory/api/v1/add", | |
| memoryInput, | |
| ); | |
| return response.data; | |
| } catch (error) { | |
| logger.error("Memory storage failed", { error, params }); | |
| return { error: "Memory storage failed" }; | |
| } | |
| }; | |