Files
search-test/embedding/add.ts
2025-12-07 22:29:44 +08:00

40 lines
780 B
TypeScript

import { index } from './common.ts'
import { BailianChat } from '@kevisual/ai'
const demos = [
{
id: 1,
text: 'This is a test embedding document.',
},
{
id: 2,
text: 'Another document for embedding storage.',
},
{
id: 3,
text: 'MeiliSearch is a powerful search engine.',
}
]
await index.updateEmbedders({
qwen: {
source: 'rest',
apiKey: process.env.BAILIAN_API_KEY,
url: BailianChat.BASE_URL + '/embeddings',
request: {
input: '{{text}}',
model: 'text-embedding-v4',
},
response: {
data: [
{
embedding: '{{embedding}}',
},
],
}
},
});
async function run() {
const response = await index.addDocuments(demos)
console.log('Documents added:', response)
}
run();