update
This commit is contained in:
40
embedding/add.ts
Normal file
40
embedding/add.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
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();
|
||||
Reference in New Issue
Block a user