Agentic RAG Supabase icon

Agentic RAG Supabase

Handle RAG operations with Supabase pgvector for PDF/TXT files

Overview

The Upsert Vector operation of the Vector resource in this node is designed to insert or update vector embeddings into a Supabase database table optimized for vector similarity search. This operation is useful in scenarios where you have precomputed text chunks with their corresponding embeddings and want to store them efficiently for later retrieval, such as building a semantic search engine, recommendation system, or any application leveraging vector similarity.

For example, after processing and embedding chunks of a document, you can upsert these vectors into the database to enable fast similarity searches later on. This is particularly beneficial when working with large-scale document collections or knowledge bases that require quick semantic lookups.

Properties

Name Meaning
Chunks with Embeddings (JSON) A JSON array of objects representing text chunks along with their embeddings and metadata. Each object typically includes:
- content or chunk: The text chunk content.
- embedding: An array of numbers representing the vector embedding.
- metadata: Optional additional information about the chunk.
This property is required and must be provided as a JSON string.

Output

The output JSON object from the Upsert Vector operation contains:

  • status: A string indicating the completion status of the upsert operation (e.g., "Upsert complete").
  • successCount: Number of chunks successfully upserted into the database.
  • errorCount: Number of chunks that failed during the upsert process.
  • totalChunks: Total number of chunks attempted to be upserted.

This output helps users understand how many chunks were processed successfully and if any errors occurred during the operation.

Dependencies

  • Supabase PostgreSQL Database with the pgvector extension enabled. The node uses Supabase client libraries to connect and perform operations on the database.
  • An API key credential for authenticating with the Supabase project.
  • The database table rag_documents must exist with the appropriate schema to store vectors, content, and metadata. The node provides an operation to set up this table if needed.
  • No direct external API calls are made during the upsert operation itself, but the node depends on the Supabase service being accessible and properly configured.

Troubleshooting

  • Common Issues:

    • Invalid JSON input: If the "Chunks with Embeddings" JSON is malformed or incorrectly formatted, the node will fail parsing it. Ensure the JSON is valid and matches the expected structure.
    • Database connection errors: If the Supabase credentials are incorrect or the service is unreachable, the node will throw connection errors.
    • Schema mismatch: If the target table does not exist or lacks the required columns/indexes, upsert operations will fail.
    • Embedding format issues: Embeddings must be arrays of numbers; incorrect formats may cause errors.
  • Error Messages and Resolutions:

    • "Chunk processing error": Indicates failure while inserting a specific chunk. Check the chunk data for correctness and ensure the database schema supports the data.
    • "Upsert error": Returned by Supabase RPC call if the upsert fails. Verify the database permissions and schema.
    • "Unknown error": Generic fallback error; check logs for more details.

To resolve these issues:

  • Validate the JSON input before running the node.
  • Confirm Supabase credentials and network connectivity.
  • Use the "Setup Table" operation to create the necessary table and indexes.
  • Inspect individual chunk data for anomalies.

Links and References


This summary focuses exclusively on the Vector > Upsert Vector operation as requested.

Discussion