Some checks failed
CI/CD Pipeline / Backend - Lint & Test (push) Has been cancelled
CI/CD Pipeline / Frontend - Lint & Test (push) Has been cancelled
CI/CD Pipeline / Security Scan (push) Has been cancelled
CI/CD Pipeline / Build Backend (push) Has been cancelled
CI/CD Pipeline / Build Frontend (push) Has been cancelled
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Performance Tests (push) Has been cancelled
CI/CD Pipeline / Dependency Updates (push) Has been cancelled
- Updated Anthropic API to latest version (2024-01-01) - Set Claude 3.7 Sonnet Latest as primary model - Removed deprecated Opus 3.5 references - Fixed LLM response validation and JSON parsing - Improved error handling and logging - Updated model configurations and pricing - Enhanced document processing reliability - Fixed TypeScript type issues - Updated environment configuration
64 lines
2.1 KiB
JavaScript
64 lines
2.1 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
const { createClient } = require('@supabase/supabase-js');
|
|
require('dotenv').config();
|
|
|
|
const supabaseUrl = process.env.SUPABASE_URL;
|
|
const supabaseServiceKey = process.env.SUPABASE_SERVICE_KEY;
|
|
|
|
const supabase = createClient(supabaseUrl, supabaseServiceKey);
|
|
|
|
async function createVectorFunctions() {
|
|
console.log('🔧 Creating vector similarity search functions...\n');
|
|
|
|
try {
|
|
// Create the match_document_chunks function
|
|
console.log('📋 Creating match_document_chunks function...');
|
|
const { error: functionError } = await supabase.rpc('exec_sql', {
|
|
sql: `
|
|
CREATE OR REPLACE FUNCTION match_document_chunks(
|
|
query_embedding vector(1536),
|
|
match_threshold float,
|
|
match_count int
|
|
)
|
|
RETURNS TABLE (
|
|
id uuid,
|
|
document_id uuid,
|
|
content text,
|
|
metadata jsonb,
|
|
similarity float
|
|
)
|
|
LANGUAGE plpgsql
|
|
AS $$
|
|
BEGIN
|
|
RETURN QUERY
|
|
SELECT
|
|
dc.id,
|
|
dc.document_id,
|
|
dc.content,
|
|
dc.metadata,
|
|
1 - (dc.embedding <=> query_embedding) as similarity
|
|
FROM document_chunks dc
|
|
WHERE 1 - (dc.embedding <=> query_embedding) > match_threshold
|
|
ORDER BY dc.embedding <=> query_embedding
|
|
LIMIT match_count;
|
|
END;
|
|
$$;
|
|
`
|
|
});
|
|
|
|
if (functionError) {
|
|
console.log(`❌ Function creation error: ${functionError.message}`);
|
|
} else {
|
|
console.log('✅ match_document_chunks function created successfully');
|
|
}
|
|
|
|
console.log('\n🎉 Vector functions created successfully!');
|
|
|
|
} catch (error) {
|
|
console.log('❌ Error creating vector functions:', error.message);
|
|
}
|
|
}
|
|
|
|
createVectorFunctions();
|