Chat Memory Manager node#
Chat Memory Manager node เอาไว้จัดการ message ที่เป็น memory สำหรับแชทใน workflow ของคุณ ใช้ node นี้เพื่อโหลด, แทรก, และลบข้อความแชทใน vector store ที่อยู่ในหน่วยความจำ (in-memory)
Node นี้มีประโยชน์เมื่อคุณ:
- ไม่สามารถเพิ่ม memory node ได้โดยตรง
- ต้องการจัดการ memory ที่ซับซ้อนกว่าที่ memory node ทั่วไปมีให้ ตัวอย่างเช่น คุณสามารถเพิ่ม node นี้เพื่อตรวจสอบขนาด memory ของ response จาก Agent node และลดขนาดหากจำเป็น
- ต้องการแทรกข้อความไปยัง AI ที่ดูเหมือนข้อความจากผู้ใช้ เพื่อให้ AI มี context มากขึ้น
ในหน้านี้จะมีรายการ operations ที่ Chat Memory Manager node รองรับ พร้อมลิงก์ไปยัง resource อื่นๆ ที่เกี่ยวข้อง
Parameter resolution in sub-nodes (การประมวลผล Parameter ใน sub-nodes)
Sub-nodes มีพฤติกรรมแตกต่างจาก node อื่นๆ เมื่อประมวลผลหลายรายการโดยใช้ expression
Node ส่วนใหญ่ รวมถึง root node จะรับ input กี่รายการก็ได้ ประมวลผลรายการเหล่านี้ และส่ง output ออกมา คุณสามารถใช้ expression เพื่ออ้างอิงถึง input item และ node จะประมวลผล expression สำหรับแต่ละ item ตามลำดับ ตัวอย่างเช่น หากมี input เป็นค่า name
ห้ารายการ expression {{ $json.name }}
จะถูกประมวลผลเป็นแต่ละชื่อตามลำดับ
ใน sub-nodes expression จะถูกประมวลผลเป็น item แรกเสมอ ตัวอย่างเช่น หากมี input เป็นค่า name
ห้ารายการ expression {{ $json.name }}
จะถูกประมวลผลเป็นชื่อแรกเสมอ
Node parameters#
- Operation Mode: เลือกว่าจะใช้โหมด Get Many Messages, Insert Messages หรือ Delete Messages
- Insert Mode: ใช้ได้ในโหมด Insert Messages เลือกได้ระหว่าง:
- Insert Messages: แทรกข้อความใหม่เข้าไปพร้อมกับข้อความเดิม
- Override All Messages: แทนที่ข้อความทั้งหมดใน memory
- Delete Mode: ใช้ได้ในโหมด Delete Messages เลือกได้ระหว่าง:
- Last N: ลบข้อความล่าสุด N ข้อความ
- All Messages: ลบข้อความทั้งหมดใน memory
- Chat Messages: ใช้ได้ในโหมด Insert Messages กำหนดข้อความแชทที่จะใส่เข้าไปใน memory โดยมี:
- Type Name or ID: กำหนดประเภทของข้อความ เลือกได้ระหว่าง:
- AI: สำหรับข้อความที่มาจาก AI
- System: สำหรับข้อความที่เป็นคำสั่งหรือ instruction ให้ AI
- User: สำหรับข้อความที่มาจากผู้ใช้ (บางทีเรียกว่า 'human' ในเครื่องมือ AI อื่นๆ)
- Message: ใส่เนื้อหาข้อความ
- Hide Message in Chat: เลือกว่าจะให้ n8n แสดงข้อความนี้ใน chat UI ให้ user เห็นหรือไม่ (ถ้าเปิดจะไม่แสดง)
- Type Name or ID: กำหนดประเภทของข้อความ เลือกได้ระหว่าง:
- Messages Count: ใช้ได้ในโหมด Delete Messages เมื่อเลือก Last N ใส่จำนวนข้อความล่าสุดที่จะลบ
- Simplify Output: ใช้ได้ในโหมด Get Many Messages ถ้าเปิดจะให้ output เฉพาะ sender (AI, user, หรือ system) และข้อความ
Templates and examples#
Related resources#
ดูข้อมูลเพิ่มเติมได้ที่ LangChain's Memory documentation
ดูเอกสาร Advanced AI ของ n8n
AI glossary#
- completion: Completions are the responses generated by a model like GPT.
- hallucinations: Hallucination in AI is when an LLM (large language model) mistakenly perceives patterns or objects that don't exist.
- vector database: A vector database stores mathematical representations of information. Use with embeddings and retrievers to create a database that your AI can access when answering questions.
- vector store: A vector store, or vector database, stores mathematical representations of information. Use with embeddings and retrievers to create a database that your AI can access when answering questions.