Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
freem
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Openai/691c325a-b61c-8003-b613-87e7ee20e0bf
(section)
Add languages
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== ต่อไปนี้เป็น cheat-sheet ตั้งค่าขั้นต่ำที่ทำงานได้ — ผมใส่ลิงก์ของ A (โพสต์ JP Hwang) และ B (repo ตัวอย่าง) เอาไว้ในข้อที่เกี่ยวข้องเพื่อให้คลิกตรวจสอบต่อได้ === ==== - A — JP Hwang — LinkedIn post (experiment: agentic memory layer with Weaviate). LinkedIn<ref>{{cite web|title=LinkedIn|url=https://www.linkedin.com/posts/jphwang_i-tried-building-an-agentic-memory-layer-activity-7395784323339243520-p4XB|publisher=linkedin.com|access-date=2025-11-19}}</ref> ==== * B — Repo / projects ที่เป็นตัวอย่าง memory-layer: - Mem0 (Universal memory layer) — GitHub: mem0ai/mem0. GitHub<ref>{{cite web|title=GitHub|url=https://github.com/mem0ai/mem0|publisher=github.com|access-date=2025-11-19}}</ref> - memlayer (plug-and-play memory layer) — GitHub: divagr18/memlayer. GitHub<ref>{{cite web|title=GitHub|url=https://github.com/divagr18/memlayer|publisher=github.com|access-date=2025-11-19}}</ref> - JP Hwang’s GitHub (profile / examples): databyjp. (อาจมีตัวอย่าง Weaviate/recipes). GitHub<ref>{{cite web|title=GitHub|url=https://github.com/databyjp|publisher=github.com|access-date=2025-11-19}}</ref> ==== ### ==== * ติดตั้ง/รัน Weaviate (local/docker หรือ Weaviate Cloud). ตัวอย่าง Docker Compose ใน docs. แนะนำเวอร์ชันล่าสุดและ schema ที่มี fields: text, summary, embedding (Weaviate เก็บ embedding ให้โดยตรง), user_id, tags, importance, timestamp. ดูเอกสารตัวอย่าง Weaviate. docs.weaviate.io<ref>{{cite web|title=docs.weaviate.io|url=https://docs.weaviate.io/integrations/llm-agent-frameworks/mem0|publisher=docs.weaviate.io|access-date=2025-11-19}}</ref> ===== - เลือก model: Weaviate built-in encoders (บางเวอร์ชัน) หรือ external (OpenAI embeddings / other). ต้องตั้งค่า encoder หรือส่ง embedding เข้า Weaviate ด้วย client. แนะนำทดสอบหลาย model เพื่อหา tradeoff speed/quality. docs.weaviate.io<ref>{{cite web|title=docs.weaviate.io|url=https://docs.weaviate.io/weaviate/best-practices/code-generation|publisher=docs.weaviate.io|access-date=2025-11-19}}</ref> ===== ===== - mem0: clone / อ่าน README เพื่อ setup (SDK, DB adapters — Weaviate supported). mem0 ออกแบบเป็น memory service ที่ให้ CRUD + retrieval + policy. GitHub<ref>{{cite web|title=GitHub|url=https://github.com/mem0ai/mem0|publisher=github.com|access-date=2025-11-19}}</ref> ===== * หรือใช้ memlayer เป็นตัวแพ็กเกจสำเร็จรูปที่ให้ API plug-and-play. GitHub<ref>{{cite web|title=GitHub|url=https://github.com/divagr18/memlayer|publisher=github.com|access-date=2025-11-19}}</ref> ===== - หากต้องการ integration กับ Claude Desktop/Code ให้ทำเป็น MCP-compatible endpoint (Model Context Protocol) ที่รับ read / write จาก tool calls — ชุมชนทดลองการแชร์ long-term memory ผ่าน MCP. Reddit<ref>{{cite web|title=Reddit|url=https://www.reddit.com/r/claude/comments/1owx8ry/testing_a_shared_longterm_memory_layer_for_claude/|publisher=reddit.com|access-date=2025-11-19}}</ref> ===== * ถ้า Claude ไม่ได้เปิด public API สำหรับ MCP ที่คุณใช้ ให้เชื่อมผ่าน middleware/adapter ที่รับ webhook/calls จาก agent และแปลงเป็น calls ไปที่ mem0/weaviate. ===== - เขียน logic สำหรับ: what → store, when → summarize, how → rank/retrieve, how long → retention, who → ACL. ตัวอย่าง: store user preferences แยกจาก conversation snippets; สรุป weekly/after-N-chats. ===== ===== - เมื่อ memory objects เกินขีด ให้เรียก LLM เพื่อสรุปเป็น compact memory (summary object) แล้ว merge/replace older objects. ===== ==== : ==== <syntaxhighlight lang="python"># prerequisites: pip install weaviate-client sentence-transformers import weaviate from sentence_transformers import SentenceTransformer from datetime import datetime === 1) connect weaviate === client = weaviate.Client("http://localhost:8080") === 2) choose encoder === encoder = SentenceTransformer("all-MiniLM-L6-v2") # replace with chosen model def store_memory(user_id: str, text: str, tags=None, importance=1): embedding = encoder.encode(text).tolist() obj = { "text": text, "summary": None, "user_id": user_id, "tags": tags or [], "importance": importance, "timestamp": datetime.utcnow().isoformat() } client.data_object.create(obj, "Memory", vector=embedding) def query_memory(query_text: str, top_k=5, filters=None): q_emb = encoder.encode(query_text).tolist() res = client.query.get("Memory", ["text", "summary", "user_id", "importance", "_additional { id distance }"]) \ .with_near_vector({"vector": q_emb}) \ .with_limit(top_k) \ .do() return res === Example usage === store_memory("user123", "User likes monthly budgets and prefers email updates.") hits = query_memory("user preference for updates", top_k=3) print(hits) </syntaxhighlight> หมายเหตุ: ถ้าใช้ mem0 หรือ memlayer ให้ดู README ใน repo เหล่านั้นเพื่อ API/SDK calls ที่เหมาะสม — mem0 มักจะมี helper สำหรับ extract/store/retrieval ที่รวม summarization และ metadata management. GitHub<ref>{{cite web|title=GitHub|url=https://github.com/mem0ai/mem0|publisher=github.com|access-date=2025-11-19}}</ref> ==== 1. Setup Weaviate (Docker/Cloud) + schema for Memory class. GitHub<ref>{{cite web|title=GitHub|url=https://github.com/weaviate/weaviate-examples|publisher=github.com|access-date=2025-11-19}}</ref> ==== # เลือก embedding & test recall quality (semantic search). docs.weaviate.io<ref>{{cite web|title=docs.weaviate.io|url=https://docs.weaviate.io/weaviate/best-practices/code-generation|publisher=docs.weaviate.io|access-date=2025-11-19}}</ref> # ติดตั้ง mem0 / memlayer (หรือ implement memory API) — ทดสอบ CRUD + retrieval. GitHub<ref>{{cite web|title=GitHub|url=https://github.com/mem0ai/mem0|publisher=github.com|access-date=2025-11-19}}</ref> # Connect Agent (Claude) — ผ่าน MCP adapter / middleware; implement read-before-response hook and write-after-response hook. (ชุมชนมีตัวอย่าง testing MCP + shared memory). Reddit<ref>{{cite web|title=Reddit|url=https://www.reddit.com/r/claude/comments/1owx8ry/testing_a_shared_longterm_memory_layer_for_claude/|publisher=reddit.com|access-date=2025-11-19}}</ref> # Policy: privacy, retention, summarization frequency, cost monitoring. # Monitoring: query latency, memory growth, relevance metrics. ==== - Quality of embeddings สำคัญ — ทดสอบหลายโมเดลและ tuning (Weaviate มีคู่มือเลือก embedding). weaviate.io<ref>{{cite web|title=weaviate.io|url=https://weaviate.io/blog/how-to-choose-an-embedding-model|publisher=weaviate.io|access-date=2025-11-19}}</ref> ==== * Avoid hallucination from memory — ระบุ source + timestamp ให้ชัดเมื่อนำ memory มาใช้ใน prompt. * Retention / GDPR / privacy — กำหนดวิธีลบ/export memory ตามข้อกฎหมาย/นโยบาย. * Summarize aggressively เพื่อลด token and noise. * Shared memory & MCP — ดี แต่ต้องระวัง concurrency, race conditions, และการอนุญาตเข้าถึง (ACL). Reddit<ref>{{cite web|title=Reddit|url=https://www.reddit.com/r/claude/comments/1owx8ry/testing_a_shared_longterm_memory_layer_for_claude/|publisher=reddit.com|access-date=2025-11-19}}</ref>
Summary:
Please note that all contributions to freem are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 (see
Freem:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)