📋 สิ่งที่ต้องการจากหลังบ้าน (Spec สำหรับทีม Supabase) API Keys ที่ต้องตั้งค่าบน MCP/RAG Server Key ใช้ทำอะไร ตั้งที่ไหน GEMINI_API_KEY Gemini Embedding 2 (MRL 768d) สำหรับ embed ข้อความ rag.gtsalphamcp.com server env ANTHROPIC_API_KEY หรือ OPENAI_API_KEY LLM สำหรับ classify, summarize, extract nuggets rag.gtsalphamcp.com server env Endpoints ใหม่ที่ต้องสร้างบน rag.gtsalphamcp.com
Input: { userId, sessionId, messages: [{ role, content }] } Logic:
Input: { userId, query, limit: 5 } Logic:
Input: { userId, sessionId, messages: [...last 15 msgs] } Logic:
Output: { identity: string } // e.g. "ชื่อ X, ชอบ Dark theme, ใช้ MCP เป็นหลัก, พูดไทย" Edge Function Proxy Routes ใหม่ (เพิ่มใน index.tsx) POST /make-server-/memory/ingest → proxy → rag.gtsalphamcp.com/memory/ingest POST /make-server-/memory/recall → proxy → rag.gtsalphamcp.com/memory/recall POST /make-server-/memory/summarize → proxy → rag.gtsalphamcp.com/memory/summarize GET /make-server-/memory/identity → proxy → rag.gtsalphamcp.com/memory/identity/{userId} Modified Chat Flow (เมื่อหลังบ้านพร้อม) User sends message │ ├─ 1. /memory/recall(userId, query) ← ดึง relevant memories + identity │ ├─ 2. ประกอบ prompt: │ [System] + [Identity] + [Top-3 Memories] │ + [Session Summary] + [Recent 3-5 msgs] + [Query] │ ├─ 3. ส่ง LLM → stream response │ └─ 4. Background: /memory/ingest(userId, sessionId, [userMsg, aiMsg]) ↓ ทุก 15 ข้อความ → /memory/summarize KV Key Pattern (ทั้งหมดใช้ KV Store เดิม) Key Pattern เก็บอะไร TTL mem:{uid}:identity ข้อมูลตัวตน/ความชอบ ถาวร mem:{uid}:nug:{uuid} Memory nugget + embedding 768d 90 วัน sum:{sid}:chunk_{n} สรุปย่อทุก 15 ข้อความ 30 วัน chatmsg:{uid}:{sid}:{id} ข้อความดิบ (มีอยู่แล้ว) 7 วัน providerkeys:{uid} API Keys จาก UI popup (encrypted) ถาวร RLS / Security ทุก endpoint ตรวจ Authorization header → getUser() หรือ getUserOrAgent() KV key ทุกตัวมี {userId} prefix → ผู้ใช้ A ไม่เห็นข้อมูลผู้ใช้ B API Keys จาก popup เก็บ encrypted ใน KV ไม่ส่งกลับ frontend เป็น plaintext A2A agents เข้าถึง memory ได้ผ่าน ApiKey gts_live_* (scopes: memory:read) ⚡️ สรุปลำดับงาน ขั้น ใครทำ อะไร 1 ผม (Figma Make) สร้าง "AI Providers" popup/tab ใน Settings + frontend hooks ใน api.ts 2 ทีม Supabase Implement 4 endpoints บน rag.gtsalphamcp.com ตาม spec ด้านบน 3 ทีม Supabase เพิ่ม proxy routes ใน Edge Function index.tsx 4 ผม (Figma Make) เชื่อม ChatPage → memory recall/ingest เมื่อหลังบ้านพร้อม ❓ ยืนยัน 3 ข้อ Spec ด้านบนตรงกับที่ต้องการหรือไม่? ปรับอะไรบอกได้ Popup ใส่ API Keys — ทำเป็น tab ใหม่ "Providers" ใน SettingsPanel เลยดีไหม? หรืออยากเป็น modal แยก? พร้อมให้ผมเริ่มทำ ขั้นที่ 1 (popup + frontend hooks) ได้เลยหรือยัง?
No responses yet.