viscribe 0.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/LICENSE +21 -0
- package/README.md +522 -0
- package/assets/black-v.png +0 -0
- package/assets/black-v.svg +5 -0
- package/assets/white-v.png +0 -0
- package/assets/white-v.svg +5 -0
- package/dist/index.cjs +826 -0
- package/dist/index.d.cts +135 -0
- package/dist/index.d.ts +135 -0
- package/dist/index.js +787 -0
- package/package.json +66 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
interface ImageSourceInput {
|
|
2
|
+
imageUrl?: string;
|
|
3
|
+
imageBase64?: string;
|
|
4
|
+
imagePath?: string;
|
|
5
|
+
}
|
|
6
|
+
declare function buildImageSource(input: ImageSourceInput): string;
|
|
7
|
+
declare function assertImagePathExists(imagePath: string): Promise<void>;
|
|
8
|
+
|
|
9
|
+
type FieldType = "text" | "number" | "array_text" | "array_number";
|
|
10
|
+
type JsonSchema = Record<string, unknown>;
|
|
11
|
+
interface ExtractField {
|
|
12
|
+
name: string;
|
|
13
|
+
type: FieldType;
|
|
14
|
+
description?: string;
|
|
15
|
+
}
|
|
16
|
+
declare function buildSchemaFromFields(fields: Array<ExtractField>): JsonSchema;
|
|
17
|
+
|
|
18
|
+
declare const DEFAULT_MODEL = "gpt-4o-mini";
|
|
19
|
+
type ModelConfig = string | Record<string, unknown> | undefined;
|
|
20
|
+
interface ImageResult<T = Record<string, unknown>> {
|
|
21
|
+
data: T;
|
|
22
|
+
raw?: unknown;
|
|
23
|
+
usageMetadata: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
interface ExtractResult<T = Record<string, unknown>> extends ImageResult<T> {
|
|
26
|
+
}
|
|
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
|
+
interface ExtractOptions extends ImageSourceInput {
|
|
42
|
+
outputSchema?: OutputSchema;
|
|
43
|
+
instruction?: string;
|
|
44
|
+
}
|
|
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
|
+
interface ViscribeAIOptions {
|
|
68
|
+
modelConfig?: ModelConfig;
|
|
69
|
+
apiKey?: string;
|
|
70
|
+
temperature?: number;
|
|
71
|
+
strict?: boolean;
|
|
72
|
+
client?: OpenAILike;
|
|
73
|
+
}
|
|
74
|
+
interface ImagesClient {
|
|
75
|
+
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
|
+
}
|
|
81
|
+
type OpenAILike = {
|
|
82
|
+
chat: {
|
|
83
|
+
completions: {
|
|
84
|
+
create: (params: Record<string, unknown>) => Promise<unknown>;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
declare class StructuredOutputError extends Error {
|
|
89
|
+
}
|
|
90
|
+
declare class StructuredOutputRefusalError extends StructuredOutputError {
|
|
91
|
+
}
|
|
92
|
+
declare class StructuredOutputParseError extends StructuredOutputError {
|
|
93
|
+
}
|
|
94
|
+
declare class StructuredOutputValidationError extends StructuredOutputError {
|
|
95
|
+
}
|
|
96
|
+
declare class StructuredOutputFinishReasonError extends StructuredOutputError {
|
|
97
|
+
}
|
|
98
|
+
declare class ViscribeAI {
|
|
99
|
+
readonly model: string;
|
|
100
|
+
readonly strict: boolean;
|
|
101
|
+
readonly images: ImagesClient;
|
|
102
|
+
readonly modelConfig: {
|
|
103
|
+
client: Record<string, unknown>;
|
|
104
|
+
request: Record<string, unknown>;
|
|
105
|
+
};
|
|
106
|
+
private client?;
|
|
107
|
+
constructor(options?: ViscribeAIOptions);
|
|
108
|
+
private extractImage;
|
|
109
|
+
private describeImage;
|
|
110
|
+
private classifyImage;
|
|
111
|
+
private askImage;
|
|
112
|
+
private compareImages;
|
|
113
|
+
private structuredImageRequest;
|
|
114
|
+
private getClient;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
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
|
+
|
|
123
|
+
type images_ImageSourceInput = ImageSourceInput;
|
|
124
|
+
declare const images_ask: typeof ask;
|
|
125
|
+
declare const images_assertImagePathExists: typeof assertImagePathExists;
|
|
126
|
+
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
|
+
declare const images_extract: typeof extract;
|
|
131
|
+
declare namespace images {
|
|
132
|
+
export { type images_ImageSourceInput as ImageSourceInput, images_ask as ask, images_assertImagePathExists as assertImagePathExists, images_buildImageSource as buildImageSource, images_classify as classify, images_compare as compare, images_describe as describe, images_extract as extract };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export { type AskData, type AskOptions, type ClassificationData, type ClassifyOptions, type CompareData, type CompareOptions, DEFAULT_MODEL, type DescribeData, type DescribeOptions, 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
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
interface ImageSourceInput {
|
|
2
|
+
imageUrl?: string;
|
|
3
|
+
imageBase64?: string;
|
|
4
|
+
imagePath?: string;
|
|
5
|
+
}
|
|
6
|
+
declare function buildImageSource(input: ImageSourceInput): string;
|
|
7
|
+
declare function assertImagePathExists(imagePath: string): Promise<void>;
|
|
8
|
+
|
|
9
|
+
type FieldType = "text" | "number" | "array_text" | "array_number";
|
|
10
|
+
type JsonSchema = Record<string, unknown>;
|
|
11
|
+
interface ExtractField {
|
|
12
|
+
name: string;
|
|
13
|
+
type: FieldType;
|
|
14
|
+
description?: string;
|
|
15
|
+
}
|
|
16
|
+
declare function buildSchemaFromFields(fields: Array<ExtractField>): JsonSchema;
|
|
17
|
+
|
|
18
|
+
declare const DEFAULT_MODEL = "gpt-4o-mini";
|
|
19
|
+
type ModelConfig = string | Record<string, unknown> | undefined;
|
|
20
|
+
interface ImageResult<T = Record<string, unknown>> {
|
|
21
|
+
data: T;
|
|
22
|
+
raw?: unknown;
|
|
23
|
+
usageMetadata: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
interface ExtractResult<T = Record<string, unknown>> extends ImageResult<T> {
|
|
26
|
+
}
|
|
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
|
+
interface ExtractOptions extends ImageSourceInput {
|
|
42
|
+
outputSchema?: OutputSchema;
|
|
43
|
+
instruction?: string;
|
|
44
|
+
}
|
|
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
|
+
interface ViscribeAIOptions {
|
|
68
|
+
modelConfig?: ModelConfig;
|
|
69
|
+
apiKey?: string;
|
|
70
|
+
temperature?: number;
|
|
71
|
+
strict?: boolean;
|
|
72
|
+
client?: OpenAILike;
|
|
73
|
+
}
|
|
74
|
+
interface ImagesClient {
|
|
75
|
+
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
|
+
}
|
|
81
|
+
type OpenAILike = {
|
|
82
|
+
chat: {
|
|
83
|
+
completions: {
|
|
84
|
+
create: (params: Record<string, unknown>) => Promise<unknown>;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
declare class StructuredOutputError extends Error {
|
|
89
|
+
}
|
|
90
|
+
declare class StructuredOutputRefusalError extends StructuredOutputError {
|
|
91
|
+
}
|
|
92
|
+
declare class StructuredOutputParseError extends StructuredOutputError {
|
|
93
|
+
}
|
|
94
|
+
declare class StructuredOutputValidationError extends StructuredOutputError {
|
|
95
|
+
}
|
|
96
|
+
declare class StructuredOutputFinishReasonError extends StructuredOutputError {
|
|
97
|
+
}
|
|
98
|
+
declare class ViscribeAI {
|
|
99
|
+
readonly model: string;
|
|
100
|
+
readonly strict: boolean;
|
|
101
|
+
readonly images: ImagesClient;
|
|
102
|
+
readonly modelConfig: {
|
|
103
|
+
client: Record<string, unknown>;
|
|
104
|
+
request: Record<string, unknown>;
|
|
105
|
+
};
|
|
106
|
+
private client?;
|
|
107
|
+
constructor(options?: ViscribeAIOptions);
|
|
108
|
+
private extractImage;
|
|
109
|
+
private describeImage;
|
|
110
|
+
private classifyImage;
|
|
111
|
+
private askImage;
|
|
112
|
+
private compareImages;
|
|
113
|
+
private structuredImageRequest;
|
|
114
|
+
private getClient;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
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
|
+
|
|
123
|
+
type images_ImageSourceInput = ImageSourceInput;
|
|
124
|
+
declare const images_ask: typeof ask;
|
|
125
|
+
declare const images_assertImagePathExists: typeof assertImagePathExists;
|
|
126
|
+
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
|
+
declare const images_extract: typeof extract;
|
|
131
|
+
declare namespace images {
|
|
132
|
+
export { type images_ImageSourceInput as ImageSourceInput, images_ask as ask, images_assertImagePathExists as assertImagePathExists, images_buildImageSource as buildImageSource, images_classify as classify, images_compare as compare, images_describe as describe, images_extract as extract };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export { type AskData, type AskOptions, type ClassificationData, type ClassifyOptions, type CompareData, type CompareOptions, DEFAULT_MODEL, type DescribeData, type DescribeOptions, 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 };
|