Forked from vadimfedenko/analyze-images
Forked from vadimfedenko/analyze-images
scripts / check-inline-image-live.cjs
const { LMStudioClient, Chat } = require('@lmstudio/sdk');
const { inlineImage } = require('../dist/inlineImage');
async function main() {
const client = new LMStudioClient();
const models = await client.llm.listLoaded();
const infos = await Promise.all(models.map(model => model.getModelInfo()));
const index = infos.findIndex(info => info.vision && info.identifier !== 'strata-vision-primer');
if (index < 0) throw Error('Load a full vision model for the inline-image check.');
const sharp = require('sharp');
const bytes = await sharp({ create: { width: 224, height: 224, channels: 3, background: '#ff0000' } }).png().toBuffer();
const chat = Chat.from('Describe the color briefly.');
chat.getMessagesArray()[0].appendFile(inlineImage(client, 'inline-test.png', bytes));
const prompt = await models[index].applyPromptTemplate(chat);
console.log(JSON.stringify({passed: typeof prompt === 'string', model: infos[index].identifier, promptLength: prompt.length}));
}
main().then(() => process.exit(0)).catch(error => { console.error(error); process.exit(1); });
scripts / check-inline-image-live.cjs
const { LMStudioClient, Chat } = require('@lmstudio/sdk');
const { inlineImage } = require('../dist/inlineImage');
async function main() {
const client = new LMStudioClient();
const models = await client.llm.listLoaded();
const infos = await Promise.all(models.map(model => model.getModelInfo()));
const index = infos.findIndex(info => info.vision && info.identifier !== 'strata-vision-primer');
if (index < 0) throw Error('Load a full vision model for the inline-image check.');
const sharp = require('sharp');
const bytes = await sharp({ create: { width: 224, height: 224, channels: 3, background: '#ff0000' } }).png().toBuffer();
const chat = Chat.from('Describe the color briefly.');
chat.getMessagesArray()[0].appendFile(inlineImage(client, 'inline-test.png', bytes));
const prompt = await models[index].applyPromptTemplate(chat);
console.log(JSON.stringify({passed: typeof prompt === 'string', model: infos[index].identifier, promptLength: prompt.length}));
}
main().then(() => process.exit(0)).catch(error => { console.error(error); process.exit(1); });