viscribe 0.1.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -462
- package/assets/viscribe-hero.png +0 -0
- package/dist/index.cjs +9 -319
- package/dist/index.d.cts +2 -53
- package/dist/index.d.ts +2 -53
- package/dist/index.js +9 -319
- package/package.json +2 -6
package/dist/index.cjs
CHANGED
|
@@ -45,12 +45,8 @@ module.exports = __toCommonJS(index_exports);
|
|
|
45
45
|
// src/images.ts
|
|
46
46
|
var images_exports = {};
|
|
47
47
|
__export(images_exports, {
|
|
48
|
-
ask: () => ask,
|
|
49
48
|
assertImagePathExists: () => assertImagePathExists,
|
|
50
49
|
buildImageSource: () => buildImageSource,
|
|
51
|
-
classify: () => classify,
|
|
52
|
-
compare: () => compare,
|
|
53
|
-
describe: () => describe,
|
|
54
50
|
extract: () => extract
|
|
55
51
|
});
|
|
56
52
|
|
|
@@ -68,9 +64,7 @@ function buildImageSource(input) {
|
|
|
68
64
|
input.imagePath !== void 0
|
|
69
65
|
].filter(Boolean).length;
|
|
70
66
|
if (provided !== 1) {
|
|
71
|
-
throw new Error(
|
|
72
|
-
"Provide exactly one of 'imageUrl', 'imageBase64', or 'imagePath'."
|
|
73
|
-
);
|
|
67
|
+
throw new Error("Provide exactly one of 'imageUrl', 'imageBase64', or 'imagePath'.");
|
|
74
68
|
}
|
|
75
69
|
if (input.imageUrl !== void 0) {
|
|
76
70
|
validateImageUrl(input.imageUrl);
|
|
@@ -90,9 +84,7 @@ function buildImageSource(input) {
|
|
|
90
84
|
const mimeType = detectImageMimeType(imageBytes);
|
|
91
85
|
return `data:${mimeType};base64,${input.imageBase64}`;
|
|
92
86
|
}
|
|
93
|
-
throw new Error(
|
|
94
|
-
"Provide exactly one of 'imageUrl', 'imageBase64', or 'imagePath'."
|
|
95
|
-
);
|
|
87
|
+
throw new Error("Provide exactly one of 'imageUrl', 'imageBase64', or 'imagePath'.");
|
|
96
88
|
}
|
|
97
89
|
async function assertImagePathExists(imagePath) {
|
|
98
90
|
const result = await (0, import_promises.stat)(imagePath);
|
|
@@ -157,67 +149,13 @@ CRITICAL INSTRUCTIONS:
|
|
|
157
149
|
- Do not include explanatory text, code blocks, or markdown formatting.
|
|
158
150
|
- Your response must be a single JSON object that exactly matches the provided schema.
|
|
159
151
|
|
|
160
|
-
|
|
152
|
+
GOAL:
|
|
161
153
|
- Analyze the image carefully and extract data according to the provided schema.
|
|
162
154
|
- Be precise and accurate.
|
|
163
155
|
- If a value is not visible or cannot be inferred from the image, use null
|
|
164
156
|
when the schema allows it.
|
|
165
157
|
- Ensure all required fields are included.
|
|
166
158
|
`.trim();
|
|
167
|
-
var DESCRIBE_SYSTEM_PROMPT = `
|
|
168
|
-
You are an expert image analyst.
|
|
169
|
-
|
|
170
|
-
CRITICAL INSTRUCTIONS:
|
|
171
|
-
- Respond with valid JSON only.
|
|
172
|
-
- Do not include explanatory text, code blocks, or markdown formatting.
|
|
173
|
-
- Your response must be a single JSON object that exactly matches the provided schema.
|
|
174
|
-
- Follow any user-provided instruction closely.
|
|
175
|
-
|
|
176
|
-
TASK:
|
|
177
|
-
- Provide a detailed, objective description of the image.
|
|
178
|
-
- Focus on main elements, context, and notable details.
|
|
179
|
-
- If tags are requested, generate up to 5 relevant tags.
|
|
180
|
-
`.trim();
|
|
181
|
-
var CLASSIFY_SYSTEM_PROMPT = `
|
|
182
|
-
You are an expert at image classification.
|
|
183
|
-
|
|
184
|
-
CRITICAL INSTRUCTIONS:
|
|
185
|
-
- Respond with valid JSON only.
|
|
186
|
-
- Do not include explanatory text, code blocks, or markdown formatting.
|
|
187
|
-
- Your response must be a single JSON object that exactly matches the provided schema.
|
|
188
|
-
|
|
189
|
-
TASK:
|
|
190
|
-
- Analyze the image and classify it according to the requested categories or task.
|
|
191
|
-
- Return only categories that are supported by the image.
|
|
192
|
-
- If the image cannot be classified into a requested category, return an empty list.
|
|
193
|
-
`.trim();
|
|
194
|
-
var ASK_SYSTEM_PROMPT = `
|
|
195
|
-
You are an expert at analyzing images and answering related questions.
|
|
196
|
-
|
|
197
|
-
CRITICAL INSTRUCTIONS:
|
|
198
|
-
- Respond with valid JSON only.
|
|
199
|
-
- Do not include explanatory text, code blocks, or markdown formatting.
|
|
200
|
-
- Your response must be a single JSON object that exactly matches the provided schema.
|
|
201
|
-
|
|
202
|
-
TASK:
|
|
203
|
-
- Carefully examine the provided image.
|
|
204
|
-
- Deliver a clear, accurate, and detailed response to the question.
|
|
205
|
-
- If the answer cannot be determined from the image, state that the information is not available.
|
|
206
|
-
`.trim();
|
|
207
|
-
var COMPARE_SYSTEM_PROMPT = `
|
|
208
|
-
You are an expert at comparing images.
|
|
209
|
-
|
|
210
|
-
CRITICAL INSTRUCTIONS:
|
|
211
|
-
- Respond with valid JSON only.
|
|
212
|
-
- Do not include explanatory text, code blocks, or markdown formatting.
|
|
213
|
-
- Your response must be a single JSON object that exactly matches the provided schema.
|
|
214
|
-
|
|
215
|
-
TASK:
|
|
216
|
-
- Analyze two provided images, focusing on their visual elements.
|
|
217
|
-
- Identify and describe similarities.
|
|
218
|
-
- Highlight differences in color, texture, composition, subject matter, and context.
|
|
219
|
-
- Point out notable features unique to each image.
|
|
220
|
-
`.trim();
|
|
221
159
|
|
|
222
160
|
// src/schema.ts
|
|
223
161
|
function buildSchemaFromFields(fields) {
|
|
@@ -294,78 +232,6 @@ var CLIENT_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
|
294
232
|
"fetch",
|
|
295
233
|
"httpAgent"
|
|
296
234
|
]);
|
|
297
|
-
var DESCRIBE_SCHEMA = {
|
|
298
|
-
title: "ImageDescription",
|
|
299
|
-
description: "Structured description of an image.",
|
|
300
|
-
type: "object",
|
|
301
|
-
properties: {
|
|
302
|
-
image_description: {
|
|
303
|
-
type: "string",
|
|
304
|
-
description: "Objective description of the image."
|
|
305
|
-
},
|
|
306
|
-
tags: {
|
|
307
|
-
type: "array",
|
|
308
|
-
items: { type: "string" },
|
|
309
|
-
maxItems: 5,
|
|
310
|
-
description: "Relevant tags describing the image."
|
|
311
|
-
}
|
|
312
|
-
},
|
|
313
|
-
required: ["image_description", "tags"],
|
|
314
|
-
additionalProperties: false
|
|
315
|
-
};
|
|
316
|
-
var DESCRIBE_NO_TAGS_SCHEMA = {
|
|
317
|
-
title: "ImageDescription",
|
|
318
|
-
description: "Structured description of an image.",
|
|
319
|
-
type: "object",
|
|
320
|
-
properties: {
|
|
321
|
-
image_description: {
|
|
322
|
-
type: "string",
|
|
323
|
-
description: "Objective description of the image."
|
|
324
|
-
}
|
|
325
|
-
},
|
|
326
|
-
required: ["image_description"],
|
|
327
|
-
additionalProperties: false
|
|
328
|
-
};
|
|
329
|
-
var CLASSIFY_SCHEMA = {
|
|
330
|
-
title: "ImageClassification",
|
|
331
|
-
description: "Structured classification of an image.",
|
|
332
|
-
type: "object",
|
|
333
|
-
properties: {
|
|
334
|
-
classification: {
|
|
335
|
-
type: "array",
|
|
336
|
-
items: { type: "string" },
|
|
337
|
-
description: "Predicted class names."
|
|
338
|
-
}
|
|
339
|
-
},
|
|
340
|
-
required: ["classification"],
|
|
341
|
-
additionalProperties: false
|
|
342
|
-
};
|
|
343
|
-
var ASK_SCHEMA = {
|
|
344
|
-
title: "ImageQuestionAnswer",
|
|
345
|
-
description: "Answer to a question about an image.",
|
|
346
|
-
type: "object",
|
|
347
|
-
properties: {
|
|
348
|
-
answer: {
|
|
349
|
-
type: "string",
|
|
350
|
-
description: "Answer to the question based on the image."
|
|
351
|
-
}
|
|
352
|
-
},
|
|
353
|
-
required: ["answer"],
|
|
354
|
-
additionalProperties: false
|
|
355
|
-
};
|
|
356
|
-
var COMPARE_SCHEMA = {
|
|
357
|
-
title: "ImageComparison",
|
|
358
|
-
description: "Structured comparison of two images.",
|
|
359
|
-
type: "object",
|
|
360
|
-
properties: {
|
|
361
|
-
comparison_result: {
|
|
362
|
-
type: "string",
|
|
363
|
-
description: "Textual comparison of the two images."
|
|
364
|
-
}
|
|
365
|
-
},
|
|
366
|
-
required: ["comparison_result"],
|
|
367
|
-
additionalProperties: false
|
|
368
|
-
};
|
|
369
235
|
var StructuredOutputError = class extends Error {
|
|
370
236
|
};
|
|
371
237
|
var StructuredOutputRefusalError = class extends StructuredOutputError {
|
|
@@ -392,11 +258,7 @@ var ViscribeAI = class {
|
|
|
392
258
|
this.strict = options.strict ?? true;
|
|
393
259
|
this.client = options.client;
|
|
394
260
|
this.images = {
|
|
395
|
-
extract: (extractOptions) => this.extractImage(extractOptions)
|
|
396
|
-
describe: (describeOptions) => this.describeImage(describeOptions),
|
|
397
|
-
classify: (classifyOptions) => this.classifyImage(classifyOptions),
|
|
398
|
-
ask: (askOptions) => this.askImage(askOptions),
|
|
399
|
-
compare: (compareOptions) => this.compareImages(compareOptions)
|
|
261
|
+
extract: (extractOptions) => this.extractImage(extractOptions)
|
|
400
262
|
};
|
|
401
263
|
}
|
|
402
264
|
async extractImage(options) {
|
|
@@ -410,45 +272,6 @@ var ViscribeAI = class {
|
|
|
410
272
|
schema
|
|
411
273
|
});
|
|
412
274
|
}
|
|
413
|
-
async describeImage(options) {
|
|
414
|
-
return this.structuredImageRequest({
|
|
415
|
-
messages: singleImageMessages({
|
|
416
|
-
systemPrompt: DESCRIBE_SYSTEM_PROMPT,
|
|
417
|
-
userPrompt: options.instruction ?? "Describe this image.",
|
|
418
|
-
imageSource: options
|
|
419
|
-
}),
|
|
420
|
-
schema: options.generateTags ?? true ? DESCRIBE_SCHEMA : DESCRIBE_NO_TAGS_SCHEMA
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
async classifyImage(options) {
|
|
424
|
-
const classes = validateClassificationOptions(options);
|
|
425
|
-
return this.structuredImageRequest({
|
|
426
|
-
messages: singleImageMessages({
|
|
427
|
-
systemPrompt: CLASSIFY_SYSTEM_PROMPT,
|
|
428
|
-
userPrompt: classificationPrompt({ ...options, classes }),
|
|
429
|
-
imageSource: options
|
|
430
|
-
}),
|
|
431
|
-
schema: classificationSchema({ multiLabel: options.multiLabel ?? false }),
|
|
432
|
-
transform: (data) => normalizeClassification(data, { classes })
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
async askImage(options) {
|
|
436
|
-
const question = validateQuestion(options.question);
|
|
437
|
-
return this.structuredImageRequest({
|
|
438
|
-
messages: singleImageMessages({
|
|
439
|
-
systemPrompt: ASK_SYSTEM_PROMPT,
|
|
440
|
-
userPrompt: question,
|
|
441
|
-
imageSource: options
|
|
442
|
-
}),
|
|
443
|
-
schema: ASK_SCHEMA
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
async compareImages(options) {
|
|
447
|
-
return this.structuredImageRequest({
|
|
448
|
-
messages: compareMessages(options),
|
|
449
|
-
schema: COMPARE_SCHEMA
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
275
|
async structuredImageRequest(options) {
|
|
453
276
|
const response = await this.getClient().chat.completions.create({
|
|
454
277
|
messages: options.messages,
|
|
@@ -456,10 +279,7 @@ var ViscribeAI = class {
|
|
|
456
279
|
response_format: responseFormatForSchema(options.schema, this.strict),
|
|
457
280
|
...this.modelConfig.request
|
|
458
281
|
});
|
|
459
|
-
return resultFromResponse(response
|
|
460
|
-
rawSchema: options.schema,
|
|
461
|
-
transform: options.transform
|
|
462
|
-
});
|
|
282
|
+
return resultFromResponse(response);
|
|
463
283
|
}
|
|
464
284
|
getClient() {
|
|
465
285
|
if (!this.client) {
|
|
@@ -519,116 +339,6 @@ function singleImageMessages(options) {
|
|
|
519
339
|
}
|
|
520
340
|
];
|
|
521
341
|
}
|
|
522
|
-
function compareMessages(options) {
|
|
523
|
-
const image1Source = buildNumberedImageSource("image1", {
|
|
524
|
-
imageUrl: options.image1Url,
|
|
525
|
-
imageBase64: options.image1Base64,
|
|
526
|
-
imagePath: options.image1Path
|
|
527
|
-
});
|
|
528
|
-
const image2Source = buildNumberedImageSource("image2", {
|
|
529
|
-
imageUrl: options.image2Url,
|
|
530
|
-
imageBase64: options.image2Base64,
|
|
531
|
-
imagePath: options.image2Path
|
|
532
|
-
});
|
|
533
|
-
return [
|
|
534
|
-
{ role: "system", content: COMPARE_SYSTEM_PROMPT },
|
|
535
|
-
{
|
|
536
|
-
role: "user",
|
|
537
|
-
content: [
|
|
538
|
-
{
|
|
539
|
-
type: "text",
|
|
540
|
-
text: options.instruction ?? "Describe the similarities and differences between these two images."
|
|
541
|
-
},
|
|
542
|
-
{ type: "image_url", image_url: { url: image1Source } },
|
|
543
|
-
{ type: "image_url", image_url: { url: image2Source } }
|
|
544
|
-
]
|
|
545
|
-
}
|
|
546
|
-
];
|
|
547
|
-
}
|
|
548
|
-
function buildNumberedImageSource(label, input) {
|
|
549
|
-
const provided = [
|
|
550
|
-
input.imageUrl !== void 0,
|
|
551
|
-
input.imageBase64 !== void 0,
|
|
552
|
-
input.imagePath !== void 0
|
|
553
|
-
].filter(Boolean).length;
|
|
554
|
-
if (provided !== 1) {
|
|
555
|
-
throw new Error(
|
|
556
|
-
`Provide exactly one source for '${label}': '${label}Url', '${label}Base64', or '${label}Path'.`
|
|
557
|
-
);
|
|
558
|
-
}
|
|
559
|
-
return buildImageSource(input);
|
|
560
|
-
}
|
|
561
|
-
function classificationSchema(options) {
|
|
562
|
-
const schema = structuredClone(CLASSIFY_SCHEMA);
|
|
563
|
-
const properties = schema.properties;
|
|
564
|
-
if (!options.multiLabel && isPlainObject(properties)) {
|
|
565
|
-
const classification = properties.classification;
|
|
566
|
-
if (isPlainObject(classification)) {
|
|
567
|
-
classification.maxItems = 1;
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
return schema;
|
|
571
|
-
}
|
|
572
|
-
function classificationPrompt(options) {
|
|
573
|
-
const parts = [options.instruction ?? "Classify this image."];
|
|
574
|
-
if (options.classes && options.classes.length > 0) {
|
|
575
|
-
parts.push(`Allowed classes: ${options.classes.join(", ")}.`);
|
|
576
|
-
} else if (options.classes) {
|
|
577
|
-
parts.push("No allowed classes were provided; return an empty list.");
|
|
578
|
-
}
|
|
579
|
-
if (options.classDescriptions) {
|
|
580
|
-
const descriptions = Object.entries(options.classDescriptions).map(([className, description]) => `- ${className}: ${description}`).join("\n");
|
|
581
|
-
parts.push(`Class descriptions:
|
|
582
|
-
${descriptions}`);
|
|
583
|
-
}
|
|
584
|
-
parts.push(
|
|
585
|
-
options.multiLabel ? "Return every relevant class in the classification list." : "Return at most one class in the classification list."
|
|
586
|
-
);
|
|
587
|
-
return parts.join("\n");
|
|
588
|
-
}
|
|
589
|
-
function validateClassificationOptions(options) {
|
|
590
|
-
const classes = options.classes ? [...options.classes] : void 0;
|
|
591
|
-
if (options.classDescriptions) {
|
|
592
|
-
if (!classes || classes.length === 0) {
|
|
593
|
-
throw new Error(
|
|
594
|
-
"'classDescriptions' can only be provided when 'classes' is provided."
|
|
595
|
-
);
|
|
596
|
-
}
|
|
597
|
-
const invalidClasses = Object.keys(options.classDescriptions).filter(
|
|
598
|
-
(className) => !classes.includes(className)
|
|
599
|
-
);
|
|
600
|
-
if (invalidClasses.length > 0) {
|
|
601
|
-
throw new Error(
|
|
602
|
-
`'classDescriptions' contains entries not present in 'classes': ${invalidClasses.sort().join(", ")}.`
|
|
603
|
-
);
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
return classes;
|
|
607
|
-
}
|
|
608
|
-
function normalizeClassification(data, options) {
|
|
609
|
-
const rawClassification = data.classification;
|
|
610
|
-
let classification;
|
|
611
|
-
if (typeof rawClassification === "string") {
|
|
612
|
-
classification = rawClassification ? [rawClassification] : [];
|
|
613
|
-
} else if (Array.isArray(rawClassification)) {
|
|
614
|
-
classification = rawClassification.filter((value) => typeof value === "string").map((value) => value);
|
|
615
|
-
} else {
|
|
616
|
-
classification = [];
|
|
617
|
-
}
|
|
618
|
-
if (options.classes) {
|
|
619
|
-
const allowedClasses = new Set(options.classes);
|
|
620
|
-
classification = classification.filter(
|
|
621
|
-
(className) => allowedClasses.has(className)
|
|
622
|
-
);
|
|
623
|
-
}
|
|
624
|
-
return { classification };
|
|
625
|
-
}
|
|
626
|
-
function validateQuestion(question) {
|
|
627
|
-
if (typeof question !== "string" || question.trim().length === 0) {
|
|
628
|
-
throw new Error("'question' must be provided.");
|
|
629
|
-
}
|
|
630
|
-
return question.trim();
|
|
631
|
-
}
|
|
632
342
|
function responseFormatForSchema(rawSchema, strict) {
|
|
633
343
|
if (rawSchema.type === "json_schema" && typeof rawSchema.json_schema === "object" && rawSchema.json_schema !== null) {
|
|
634
344
|
const jsonSchema = { ...rawSchema.json_schema };
|
|
@@ -688,10 +398,10 @@ function ensureStrictJsonSchema(schema) {
|
|
|
688
398
|
delete schema.default;
|
|
689
399
|
}
|
|
690
400
|
}
|
|
691
|
-
function resultFromResponse(response
|
|
401
|
+
function resultFromResponse(response) {
|
|
692
402
|
const parsed = parseStructuredResponse(response);
|
|
693
403
|
return {
|
|
694
|
-
data:
|
|
404
|
+
data: parsed,
|
|
695
405
|
raw: response,
|
|
696
406
|
usageMetadata: usageMetadata(response)
|
|
697
407
|
};
|
|
@@ -738,9 +448,7 @@ function messageContentText(message) {
|
|
|
738
448
|
).map((block) => block.text).join("");
|
|
739
449
|
if (text) return text;
|
|
740
450
|
}
|
|
741
|
-
throw new StructuredOutputParseError(
|
|
742
|
-
"Response message does not contain text content."
|
|
743
|
-
);
|
|
451
|
+
throw new StructuredOutputParseError("Response message does not contain text content.");
|
|
744
452
|
}
|
|
745
453
|
function loadsJsonObject(content) {
|
|
746
454
|
const trimmed = content.trim();
|
|
@@ -761,9 +469,7 @@ function loadsJsonObject(content) {
|
|
|
761
469
|
try {
|
|
762
470
|
const data = JSON.parse(attempt);
|
|
763
471
|
if (!isPlainObject(data)) {
|
|
764
|
-
throw new StructuredOutputParseError(
|
|
765
|
-
"Structured output must be a JSON object."
|
|
766
|
-
);
|
|
472
|
+
throw new StructuredOutputParseError("Structured output must be a JSON object.");
|
|
767
473
|
}
|
|
768
474
|
return data;
|
|
769
475
|
} catch (error) {
|
|
@@ -796,22 +502,6 @@ async function extract(options) {
|
|
|
796
502
|
const client = new ViscribeAI(options);
|
|
797
503
|
return client.images.extract(options);
|
|
798
504
|
}
|
|
799
|
-
async function describe(options) {
|
|
800
|
-
const client = new ViscribeAI(options);
|
|
801
|
-
return client.images.describe(options);
|
|
802
|
-
}
|
|
803
|
-
async function classify(options) {
|
|
804
|
-
const client = new ViscribeAI(options);
|
|
805
|
-
return client.images.classify(options);
|
|
806
|
-
}
|
|
807
|
-
async function ask(options) {
|
|
808
|
-
const client = new ViscribeAI(options);
|
|
809
|
-
return client.images.ask(options);
|
|
810
|
-
}
|
|
811
|
-
async function compare(options) {
|
|
812
|
-
const client = new ViscribeAI(options);
|
|
813
|
-
return client.images.compare(options);
|
|
814
|
-
}
|
|
815
505
|
// Annotate the CommonJS export names for ESM import in node:
|
|
816
506
|
0 && (module.exports = {
|
|
817
507
|
DEFAULT_MODEL,
|
package/dist/index.d.cts
CHANGED
|
@@ -25,45 +25,10 @@ interface ImageResult<T = Record<string, unknown>> {
|
|
|
25
25
|
interface ExtractResult<T = Record<string, unknown>> extends ImageResult<T> {
|
|
26
26
|
}
|
|
27
27
|
type OutputSchema = ExtractField[] | JsonSchema;
|
|
28
|
-
interface DescribeData {
|
|
29
|
-
image_description: string;
|
|
30
|
-
tags?: string[];
|
|
31
|
-
}
|
|
32
|
-
interface ClassificationData {
|
|
33
|
-
classification: string[];
|
|
34
|
-
}
|
|
35
|
-
interface AskData {
|
|
36
|
-
answer: string;
|
|
37
|
-
}
|
|
38
|
-
interface CompareData {
|
|
39
|
-
comparison_result: string;
|
|
40
|
-
}
|
|
41
28
|
interface ExtractOptions extends ImageSourceInput {
|
|
42
29
|
outputSchema?: OutputSchema;
|
|
43
30
|
instruction?: string;
|
|
44
31
|
}
|
|
45
|
-
interface DescribeOptions extends ImageSourceInput {
|
|
46
|
-
instruction?: string;
|
|
47
|
-
generateTags?: boolean;
|
|
48
|
-
}
|
|
49
|
-
interface ClassifyOptions extends ImageSourceInput {
|
|
50
|
-
classes?: string[];
|
|
51
|
-
classDescriptions?: Record<string, string>;
|
|
52
|
-
instruction?: string;
|
|
53
|
-
multiLabel?: boolean;
|
|
54
|
-
}
|
|
55
|
-
interface AskOptions extends ImageSourceInput {
|
|
56
|
-
question: string;
|
|
57
|
-
}
|
|
58
|
-
interface CompareOptions {
|
|
59
|
-
image1Url?: string;
|
|
60
|
-
image1Base64?: string;
|
|
61
|
-
image1Path?: string;
|
|
62
|
-
image2Url?: string;
|
|
63
|
-
image2Base64?: string;
|
|
64
|
-
image2Path?: string;
|
|
65
|
-
instruction?: string;
|
|
66
|
-
}
|
|
67
32
|
interface ViscribeAIOptions {
|
|
68
33
|
modelConfig?: ModelConfig;
|
|
69
34
|
apiKey?: string;
|
|
@@ -73,10 +38,6 @@ interface ViscribeAIOptions {
|
|
|
73
38
|
}
|
|
74
39
|
interface ImagesClient {
|
|
75
40
|
extract<T = Record<string, unknown>>(options: ExtractOptions): Promise<ExtractResult<T>>;
|
|
76
|
-
describe(options: DescribeOptions): Promise<ImageResult<DescribeData>>;
|
|
77
|
-
classify(options: ClassifyOptions): Promise<ImageResult<ClassificationData>>;
|
|
78
|
-
ask(options: AskOptions): Promise<ImageResult<AskData>>;
|
|
79
|
-
compare(options: CompareOptions): Promise<ImageResult<CompareData>>;
|
|
80
41
|
}
|
|
81
42
|
type OpenAILike = {
|
|
82
43
|
chat: {
|
|
@@ -106,30 +67,18 @@ declare class ViscribeAI {
|
|
|
106
67
|
private client?;
|
|
107
68
|
constructor(options?: ViscribeAIOptions);
|
|
108
69
|
private extractImage;
|
|
109
|
-
private describeImage;
|
|
110
|
-
private classifyImage;
|
|
111
|
-
private askImage;
|
|
112
|
-
private compareImages;
|
|
113
70
|
private structuredImageRequest;
|
|
114
71
|
private getClient;
|
|
115
72
|
}
|
|
116
73
|
|
|
117
74
|
declare function extract<T = Record<string, unknown>>(options: ExtractOptions & ViscribeAIOptions): Promise<ExtractResult<T>>;
|
|
118
|
-
declare function describe(options: DescribeOptions & ViscribeAIOptions): Promise<ImageResult<DescribeData>>;
|
|
119
|
-
declare function classify(options: ClassifyOptions & ViscribeAIOptions): Promise<ImageResult<ClassificationData>>;
|
|
120
|
-
declare function ask(options: AskOptions & ViscribeAIOptions): Promise<ImageResult<AskData>>;
|
|
121
|
-
declare function compare(options: CompareOptions & ViscribeAIOptions): Promise<ImageResult<CompareData>>;
|
|
122
75
|
|
|
123
76
|
type images_ImageSourceInput = ImageSourceInput;
|
|
124
|
-
declare const images_ask: typeof ask;
|
|
125
77
|
declare const images_assertImagePathExists: typeof assertImagePathExists;
|
|
126
78
|
declare const images_buildImageSource: typeof buildImageSource;
|
|
127
|
-
declare const images_classify: typeof classify;
|
|
128
|
-
declare const images_compare: typeof compare;
|
|
129
|
-
declare const images_describe: typeof describe;
|
|
130
79
|
declare const images_extract: typeof extract;
|
|
131
80
|
declare namespace images {
|
|
132
|
-
export { type images_ImageSourceInput as ImageSourceInput,
|
|
81
|
+
export { type images_ImageSourceInput as ImageSourceInput, images_assertImagePathExists as assertImagePathExists, images_buildImageSource as buildImageSource, images_extract as extract };
|
|
133
82
|
}
|
|
134
83
|
|
|
135
|
-
export {
|
|
84
|
+
export { DEFAULT_MODEL, type ExtractField, type ExtractOptions, type ExtractResult, type FieldType, type ImageResult, type ImagesClient, type JsonSchema, type ModelConfig, type OpenAILike, type OutputSchema, StructuredOutputError, StructuredOutputFinishReasonError, StructuredOutputParseError, StructuredOutputRefusalError, StructuredOutputValidationError, ViscribeAI, type ViscribeAIOptions, buildSchemaFromFields, images };
|
package/dist/index.d.ts
CHANGED
|
@@ -25,45 +25,10 @@ interface ImageResult<T = Record<string, unknown>> {
|
|
|
25
25
|
interface ExtractResult<T = Record<string, unknown>> extends ImageResult<T> {
|
|
26
26
|
}
|
|
27
27
|
type OutputSchema = ExtractField[] | JsonSchema;
|
|
28
|
-
interface DescribeData {
|
|
29
|
-
image_description: string;
|
|
30
|
-
tags?: string[];
|
|
31
|
-
}
|
|
32
|
-
interface ClassificationData {
|
|
33
|
-
classification: string[];
|
|
34
|
-
}
|
|
35
|
-
interface AskData {
|
|
36
|
-
answer: string;
|
|
37
|
-
}
|
|
38
|
-
interface CompareData {
|
|
39
|
-
comparison_result: string;
|
|
40
|
-
}
|
|
41
28
|
interface ExtractOptions extends ImageSourceInput {
|
|
42
29
|
outputSchema?: OutputSchema;
|
|
43
30
|
instruction?: string;
|
|
44
31
|
}
|
|
45
|
-
interface DescribeOptions extends ImageSourceInput {
|
|
46
|
-
instruction?: string;
|
|
47
|
-
generateTags?: boolean;
|
|
48
|
-
}
|
|
49
|
-
interface ClassifyOptions extends ImageSourceInput {
|
|
50
|
-
classes?: string[];
|
|
51
|
-
classDescriptions?: Record<string, string>;
|
|
52
|
-
instruction?: string;
|
|
53
|
-
multiLabel?: boolean;
|
|
54
|
-
}
|
|
55
|
-
interface AskOptions extends ImageSourceInput {
|
|
56
|
-
question: string;
|
|
57
|
-
}
|
|
58
|
-
interface CompareOptions {
|
|
59
|
-
image1Url?: string;
|
|
60
|
-
image1Base64?: string;
|
|
61
|
-
image1Path?: string;
|
|
62
|
-
image2Url?: string;
|
|
63
|
-
image2Base64?: string;
|
|
64
|
-
image2Path?: string;
|
|
65
|
-
instruction?: string;
|
|
66
|
-
}
|
|
67
32
|
interface ViscribeAIOptions {
|
|
68
33
|
modelConfig?: ModelConfig;
|
|
69
34
|
apiKey?: string;
|
|
@@ -73,10 +38,6 @@ interface ViscribeAIOptions {
|
|
|
73
38
|
}
|
|
74
39
|
interface ImagesClient {
|
|
75
40
|
extract<T = Record<string, unknown>>(options: ExtractOptions): Promise<ExtractResult<T>>;
|
|
76
|
-
describe(options: DescribeOptions): Promise<ImageResult<DescribeData>>;
|
|
77
|
-
classify(options: ClassifyOptions): Promise<ImageResult<ClassificationData>>;
|
|
78
|
-
ask(options: AskOptions): Promise<ImageResult<AskData>>;
|
|
79
|
-
compare(options: CompareOptions): Promise<ImageResult<CompareData>>;
|
|
80
41
|
}
|
|
81
42
|
type OpenAILike = {
|
|
82
43
|
chat: {
|
|
@@ -106,30 +67,18 @@ declare class ViscribeAI {
|
|
|
106
67
|
private client?;
|
|
107
68
|
constructor(options?: ViscribeAIOptions);
|
|
108
69
|
private extractImage;
|
|
109
|
-
private describeImage;
|
|
110
|
-
private classifyImage;
|
|
111
|
-
private askImage;
|
|
112
|
-
private compareImages;
|
|
113
70
|
private structuredImageRequest;
|
|
114
71
|
private getClient;
|
|
115
72
|
}
|
|
116
73
|
|
|
117
74
|
declare function extract<T = Record<string, unknown>>(options: ExtractOptions & ViscribeAIOptions): Promise<ExtractResult<T>>;
|
|
118
|
-
declare function describe(options: DescribeOptions & ViscribeAIOptions): Promise<ImageResult<DescribeData>>;
|
|
119
|
-
declare function classify(options: ClassifyOptions & ViscribeAIOptions): Promise<ImageResult<ClassificationData>>;
|
|
120
|
-
declare function ask(options: AskOptions & ViscribeAIOptions): Promise<ImageResult<AskData>>;
|
|
121
|
-
declare function compare(options: CompareOptions & ViscribeAIOptions): Promise<ImageResult<CompareData>>;
|
|
122
75
|
|
|
123
76
|
type images_ImageSourceInput = ImageSourceInput;
|
|
124
|
-
declare const images_ask: typeof ask;
|
|
125
77
|
declare const images_assertImagePathExists: typeof assertImagePathExists;
|
|
126
78
|
declare const images_buildImageSource: typeof buildImageSource;
|
|
127
|
-
declare const images_classify: typeof classify;
|
|
128
|
-
declare const images_compare: typeof compare;
|
|
129
|
-
declare const images_describe: typeof describe;
|
|
130
79
|
declare const images_extract: typeof extract;
|
|
131
80
|
declare namespace images {
|
|
132
|
-
export { type images_ImageSourceInput as ImageSourceInput,
|
|
81
|
+
export { type images_ImageSourceInput as ImageSourceInput, images_assertImagePathExists as assertImagePathExists, images_buildImageSource as buildImageSource, images_extract as extract };
|
|
133
82
|
}
|
|
134
83
|
|
|
135
|
-
export {
|
|
84
|
+
export { DEFAULT_MODEL, type ExtractField, type ExtractOptions, type ExtractResult, type FieldType, type ImageResult, type ImagesClient, type JsonSchema, type ModelConfig, type OpenAILike, type OutputSchema, StructuredOutputError, StructuredOutputFinishReasonError, StructuredOutputParseError, StructuredOutputRefusalError, StructuredOutputValidationError, ViscribeAI, type ViscribeAIOptions, buildSchemaFromFields, images };
|