feat(supabase): added vector search tool and updated docs#1707
feat(supabase): added vector search tool and updated docs#1707waleedlatif1 merged 3 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Greptile Overview
Summary
Added a new vector search tool for Supabase that enables similarity search using pgvector through PostgreSQL RPC functions.
Key Changes:
- Created
vector_search.tsimplementing the tool with proper request/response handling - Added TypeScript interfaces for params and response types
- Integrated vector search as a new operation in the Supabase block UI
- Added 'array' type support to block parameter types for embedding vectors
- Registered the tool in the global registry
- Updated documentation with comprehensive parameter descriptions
- Fixed doc generation to exclude webhook blocks and updated meta.json structure
Implementation Approach:
The tool uses Supabase's RPC endpoint to call custom PostgreSQL functions that perform vector similarity searches. It accepts a query embedding (number array), function name, and optional parameters for match threshold and count. The block integration includes JSON parsing for string-formatted embeddings with helpful error messages.
Confidence Score: 4/5
- This PR is safe to merge with one minor type safety improvement needed
- The implementation is well-structured and follows existing patterns in the codebase. The main issue is the use of
Record<string, any>on line 69 which violates the project's type safety guidelines. All other aspects - integration, documentation, type definitions, and error handling - are properly implemented. - Fix the type assertion in
apps/sim/tools/supabase/vector_search.tsline 69
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/tools/supabase/vector_search.ts | 4/5 | New vector search tool implementation with proper structure, though uses any type on line 69 |
| apps/sim/tools/supabase/types.ts | 5/5 | Added proper TypeScript interfaces for vector search params and response |
| apps/sim/blocks/blocks/supabase.ts | 5/5 | Added vector search operation with proper UI fields and parameter parsing logic |
| apps/sim/tools/registry.ts | 5/5 | Registered the new vector search tool in the global registry |
| apps/sim/blocks/types.ts | 5/5 | Added 'array' to ParamType union to support vector embeddings |
Sequence Diagram
sequenceDiagram
participant User
participant Block as Supabase Block
participant Tool as Vector Search Tool
participant Supabase as Supabase RPC API
User->>Block: Configure vector search operation
User->>Block: Provide functionName, queryEmbedding, optional params
Block->>Block: Parse queryEmbedding (JSON if string)
Block->>Tool: Call supabase_vector_search with params
Tool->>Tool: Build RPC endpoint URL
Tool->>Tool: Prepare request body with query_embedding
Tool->>Supabase: POST /rest/v1/rpc/{functionName}
Supabase->>Supabase: Execute pgvector similarity search
Supabase-->>Tool: Return matching vectors with scores
Tool->>Tool: Transform response
Tool->>Tool: Count results and format message
Tool-->>Block: Return success with results array
Block-->>User: Display similar vectors with scores
18 files reviewed, 1 comment
| }), | ||
| body: (params) => { | ||
| // Build the RPC call parameters | ||
| const rpcParams: Record<string, any> = { |
There was a problem hiding this comment.
syntax: Using Record<string, any> violates type safety principles. Define a proper interface for RPC parameters.
| const rpcParams: Record<string, any> = { | |
| const rpcParams: { query_embedding: number[]; match_threshold?: number; match_count?: number } = { |
Context Used: Context from dashboard - Avoid using type assertions to 'any' in TypeScript. Instead, ensure proper type definitions are used... (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/tools/supabase/vector_search.ts
Line: 69:69
Comment:
**syntax:** Using `Record<string, any>` violates type safety principles. Define a proper interface for RPC parameters.
```suggestion
const rpcParams: { query_embedding: number[]; match_threshold?: number; match_count?: number } = {
```
**Context Used:** Context from `dashboard` - Avoid using type assertions to 'any' in TypeScript. Instead, ensure proper type definitions are used... ([source](https://app.greptile.com/review/custom-context?memory=c63aedff-69e6-48d8-81cf-9763416ee01c))
How can I resolve this? If you propose a fix, please make it concise.
Summary
Type of Change
Testing
Tested manually.
Checklist