parrot-api / test-vector.ts
Jrine's picture
second base
1257299
raw
history blame contribute delete
961 Bytes
async function testAddDocument() {
const response = await fetch('http://localhost:3000/api/embeddings', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
content: 'Next.js is a React framework for building web applications.',
title: 'Next.js Introduction',
metadata: { category: 'web development' }
})
})
const result = await response.json()
console.log('Document added:', result)
}
async function testSearch() {
const response = await fetch('http://localhost:3000/api/search', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
query: 'What is Next.js?',
match_threshold: 0.5,
match_count: 3
})
})
const result = await response.json()
console.log('Search results:', result)
}
// Run tests
testAddDocument()
.then(() => testSearch())
.catch(console.error)