Skip to content

Supabase Vector Store node#

ใช้ Supabase Vector Store เพื่อโต้ตอบกับ Supabase database ของคุณในฐานะ vector store คุณสามารถใส่ documents เข้าไปใน vector database, ดึง documents จาก vector database, เรียกดู documents เพื่อส่งต่อไปยัง retriever ที่เชื่อมต่อกับ chain หรือเชื่อมต่อโดยตรงกับ agent เพื่อใช้เป็น tool

ในหน้านี้ คุณจะพบ node parameters สำหรับ Supabase node และลิงก์ไปยังแหล่งข้อมูลเพิ่มเติม

Credentials

คุณสามารถดูข้อมูล authentication สำหรับ node นี้ได้ ที่นี่

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 }} จะถูกประมวลผลเป็นชื่อแรกเสมอ

Supabase มี quickstart สำหรับการตั้งค่า vector store ของคุณ หากคุณใช้การตั้งค่าอื่นนอกเหนือจากค่าเริ่มต้นใน quickstart อาจส่งผลต่อการตั้งค่า parameter ใน n8n โปรดตรวจสอบให้แน่ใจว่าคุณเข้าใจสิ่งที่คุณกำลังทำ

Node usage patterns#

คุณสามารถใช้ Supabase Vector Store node ในรูปแบบต่อไปนี้

Use as a regular node to insert, update, and retrieve documents#

คุณสามารถใช้ Supabase Vector Store เป็น node ปกติเพื่อ insert, update หรือ get documents รูปแบบนี้จะวาง Supabase Vector Store ไว้ใน flow การเชื่อมต่อปกติโดยไม่ต้องใช้ agent

คุณสามารถดูตัวอย่างได้ใน scenario 1 ของ template นี้

Connect directly to an AI agent as a tool#

คุณสามารถเชื่อมต่อ Supabase Vector Store node โดยตรงกับ tool connector ของ AI agent เพื่อใช้ vector store เป็น resource เมื่อตอบคำถาม

ในกรณีนี้ การเชื่อมต่อจะเป็น: AI agent (tools connector) -> Supabase Vector Store node

Use a retriever to fetch documents#

คุณสามารถใช้ Vector Store Retriever node ร่วมกับ Supabase Vector Store node เพื่อดึง documents จาก Supabase Vector Store node ซึ่งมักใช้กับ Question and Answer Chain node เพื่อดึง documents จาก vector store ที่ตรงกับ input ของ chat ที่กำหนด

ตัวอย่างของ flow การเชื่อมต่อ (ตัวอย่างใช้ Pinecone แต่รูปแบบเหมือนกัน) จะเป็น: Question and Answer Chain (Retriever connector) -> Vector Store Retriever (Vector Store connector) -> Supabase Vector Store

Use the Vector Store Question Answer Tool to answer questions#

อีกรูปแบบหนึ่งคือการใช้ Vector Store Question Answer Tool เพื่อสรุปผลลัพธ์และตอบคำถามจาก Supabase Vector Store node แทนที่จะเชื่อมต่อ Supabase Vector Store โดยตรงในฐานะ tool รูปแบบนี้จะใช้ tool ที่ออกแบบมาโดยเฉพาะเพื่อสรุปข้อมูลใน vector store

flow การเชื่อมต่อ ในกรณีนี้จะมีลักษณะดังนี้: AI agent (tools connector) -> Vector Store Question Answer Tool (Vector Store connector) -> Supabase Vector store

Node parameters#

Operation Mode (โหมดการทำงาน)#

Vector Store node นี้มีห้าโหมด: Get Many, Insert Documents, Retrieve Documents (As Vector Store for Chain/Tool), Retrieve Documents (As Tool for AI Agent), และ Update Documents โหมดที่คุณเลือกจะกำหนดการดำเนินการที่คุณสามารถทำได้ด้วย node และ input/output ที่มีให้ใช้งาน

Get Many (ดึงข้อมูลหลายรายการ)#

ในโหมดนี้ คุณสามารถดึงเอกสารหลายรายการจาก vector database ของคุณโดยการระบุ prompt ตัว prompt จะถูกแปลงเป็น embedding และใช้สำหรับการค้นหาความคล้ายคลึง (similarity search) node จะส่งคืนเอกสารที่คล้ายกับ prompt มากที่สุดพร้อมกับคะแนนความคล้ายคลึง (similarity score) ซึ่งมีประโยชน์หากคุณต้องการดึงรายการเอกสารที่คล้ายกันและส่งต่อไปยัง agent เพื่อใช้เป็น context เพิ่มเติม

Insert Documents (แทรกเอกสาร)#

ใช้โหมด Insert Documents เพื่อแทรกเอกสารใหม่เข้าไปใน vector database ของคุณ

Retrieve Documents (As Vector Store for Chain/Tool) (ดึงเอกสาร - เป็น Vector Store สำหรับ Chain/Tool)#

ใช้โหมด Retrieve Documents (As Vector Store for Chain/Tool) กับ vector-store retriever เพื่อดึงเอกสารจาก vector database และส่งต่อไปยัง retriever ที่เชื่อมต่อกับ chain ในโหมดนี้ คุณต้องเชื่อมต่อ node เข้ากับ retriever node หรือ root node

Retrieve Documents (As Tool for AI Agent) (ดึงเอกสาร - เป็น Tool สำหรับ AI Agent)#

ใช้โหมด Retrieve Documents (As Tool for AI Agent) เพื่อใช้ vector store เป็น tool resource ในการตอบคำถาม เมื่อสร้างคำตอบ agent จะใช้ vector store เมื่อชื่อและคำอธิบายของ vector store ตรงกับรายละเอียดของคำถาม

Update Documents (อัปเดตเอกสาร)#

ใช้โหมด Update Documents เพื่ออัปเดตเอกสารใน vector database โดยใช้ ID กรอก ID ด้วย ID ของ embedding entry ที่ต้องการอัปเดต

Get Many parameters#

  • Table Name: ป้อนตาราง Supabase ที่จะใช้
  • Prompt: ป้อนคำค้นหา (search query)
  • Limit: ป้อนจำนวนผลลัพธ์ที่ต้องการดึงจาก vector store ตัวอย่างเช่น ตั้งค่าเป็น 10 เพื่อรับผลลัพธ์ที่ดีที่สุดสิบรายการ

Insert Documents parameters#

  • Table Name: ป้อนตาราง Supabase ที่จะใช้

Retrieve Documents (As Vector Store for Chain/Tool) parameters#

  • Table Name: ป้อนตาราง Supabase ที่จะใช้

Retrieve Documents (As Tool for AI Agent) parameters#

  • Name: ชื่อของ vector store
  • Description: อธิบายให้ LLM ทราบว่า tool นี้ทำอะไร คำอธิบายที่ดีและเฉพาะเจาะจงช่วยให้ LLM สร้างผลลัพธ์ที่คาดหวังได้บ่อยขึ้น
  • Table Name: ป้อนตาราง Supabase ที่จะใช้
  • Limit: ป้อนจำนวนผลลัพธ์ที่ต้องการดึงจาก vector store ตัวอย่างเช่น ตั้งค่าเป็น 10 เพื่อรับผลลัพธ์ที่ดีที่สุดสิบรายการ

Update Documents#

  • Table Name: ป้อนตาราง Supabase ที่จะใช้
  • ID: ID ของรายการ embedding

Node options#

Query Name#

ชื่อของ matching function ที่คุณตั้งค่าใน Supabase หากคุณทำตาม Supabase quickstart ชื่อนี้จะเป็น match_documents

Metadata Filter#

Metadata Filter (ตัวกรอง Metadata)#

มีให้ใช้งานในโหมด Get Many เมื่อค้นหาข้อมูล ใช้ตัวเลือกนี้เพื่อจับคู่กับ metadata ที่เกี่ยวข้องกับเอกสาร

นี่คือการ query แบบ AND หากคุณระบุฟิลด์ตัวกรอง metadata มากกว่าหนึ่งฟิลด์ ทุกฟิลด์จะต้องตรงกันทั้งหมด

เมื่อแทรกข้อมูล metadata จะถูกตั้งค่าโดยใช้ document loader อ้างอิง Default Data Loader สำหรับข้อมูลเพิ่มเติมเกี่ยวกับการโหลดเอกสาร

Templates and examples#

AI Agent To Chat With Files In Supabase Storage

by Mark Shcherbakov

View template details
Supabase Insertion & Upsertion & Retrieval

by Ria

View template details
Document Q&A Chatbot with Gemini AI and Supabase Vector Search for Telegram

by Mohammad Ghaffarifar

View template details
Browse Supabase Vector Store integration templates, or search all templates

อ้างอิง เอกสาร Supabase ของ LangChain สำหรับข้อมูลเพิ่มเติมเกี่ยวกับบริการ

ดูเอกสาร 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.