UNPKG

agentis

Version:

A TypeScript framework for building sophisticated multi-agent systems

41 lines (40 loc) 1.38 kB
"use strict"; // src/memory/MemoryClient.ts Object.defineProperty(exports, "__esModule", { value: true }); exports.MemoryClient = void 0; const SupabaseClient_1 = require("../utils/SupabaseClient"); class MemoryClient { static async saveMemory(agentId, content, embedding) { const { error } = await SupabaseClient_1.supabase .from('agent_memory') .insert([{ agent_id: agentId, content, embedding }]); if (error) { console.error("Error saving memory:", error); } } static async getMemory(agentId) { const { data, error } = await SupabaseClient_1.supabase .from('agent_memory') .select('*') .eq('agent_id', agentId); if (error) { console.error("Error fetching memory:", error); return []; } return data || []; } static async searchSimilarMemories(agentId, query, embedding, limit = 5) { const { data, error } = await SupabaseClient_1.supabase.rpc('match_memories', { query_embedding: embedding, match_threshold: 0.8, match_count: limit, p_agent_id: agentId }); if (error) { console.error("Error searching memories:", error); return []; } return data || []; } } exports.MemoryClient = MemoryClient;