-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_embedding.js
More file actions
26 lines (22 loc) · 814 Bytes
/
Copy pathtest_embedding.js
File metadata and controls
26 lines (22 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import OpenAI from 'openai';
import dotenv from 'dotenv';
dotenv.config();
const openai = new OpenAI({
baseURL: process.env.LM_STUDIO_URL || 'http://localhost:1234/v1',
apiKey: 'lm-studio',
});
async function testEmbedding() {
try {
console.log('Testing embedding generation...');
const response = await openai.embeddings.create({
model: process.env.LM_STUDIO_MODEL || 'qwen-2.5-7b-instruct', // Use configured model
input: "The quick brown fox jumps over the lazy dog",
});
console.log('Success!');
console.log('Vector length:', response.data[0].embedding.length);
} catch (error) {
console.error('Error:', error.message);
if (error.response) console.error('Data:', error.response.data);
}
}
testEmbedding();