-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvision.ts
More file actions
129 lines (115 loc) · 4.03 KB
/
vision.ts
File metadata and controls
129 lines (115 loc) · 4.03 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../core/resource';
import { APIPromise } from '../core/api-promise';
import { RequestOptions } from '../internal/request-options';
export class Vision extends APIResource {
/**
* Submit images and documents with a prompt to generate an analysis. Supports JPG,
* PNG, PDF, and TXT files up to 7MB each.
*
* @example
* ```ts
* const visionResponse = await client.vision.analyze({
* model: 'palmyra-vision',
* prompt:
* 'Describe the difference between the image {{image_1}} and the image {{image_2}}.',
* variables: [
* { name: 'image_1', file_id: 'f1234' },
* { name: 'image_2', file_id: 'f9876' },
* ],
* });
* ```
*/
analyze(body: VisionAnalyzeParams, options?: RequestOptions): APIPromise<VisionResponse> {
return this._client.post('/v1/vision', { body, ...options });
}
}
export interface VisionRequest {
/**
* The model to use for image analysis.
*/
model: 'palmyra-vision';
/**
* The prompt to use for the image analysis. The prompt must include the name of
* each image variable, surrounded by double curly braces (`{{}}`). For example,
* `Describe the difference between the image {{image_1}} and the image {{image_2}}`.
*/
prompt: string;
variables: Array<VisionRequest.Variable>;
}
export namespace VisionRequest {
/**
* An array of file variables required for the analysis. The files must be uploaded
* to the Writer platform before they can be used in a vision request. Learn how to
* upload files using the
* [Files API](https://dev.writer.com/api-reference/file-api/upload-files).
*
* Supported file types: JPG, PNG, PDF, TXT. The maximum allowed file size for each
* file is 7MB.
*/
export interface Variable {
/**
* The File ID of the file to analyze. The file must be uploaded to the Writer
* platform before it can be used in a vision request. Supported file types: JPG,
* PNG, PDF, TXT (max 7MB each).
*/
file_id: string;
/**
* The name of the file variable. You must reference this name in the prompt with
* double curly braces (`{{}}`). For example,
* `Describe the difference between the image {{image_1}} and the image {{image_2}}`.
*/
name: string;
}
}
export interface VisionResponse {
/**
* The result of the image analysis.
*/
data: string;
}
export interface VisionAnalyzeParams {
/**
* The model to use for image analysis.
*/
model: 'palmyra-vision';
/**
* The prompt to use for the image analysis. The prompt must include the name of
* each image variable, surrounded by double curly braces (`{{}}`). For example,
* `Describe the difference between the image {{image_1}} and the image {{image_2}}`.
*/
prompt: string;
variables: Array<VisionAnalyzeParams.Variable>;
}
export namespace VisionAnalyzeParams {
/**
* An array of file variables required for the analysis. The files must be uploaded
* to the Writer platform before they can be used in a vision request. Learn how to
* upload files using the
* [Files API](https://dev.writer.com/api-reference/file-api/upload-files).
*
* Supported file types: JPG, PNG, PDF, TXT. The maximum allowed file size for each
* file is 7MB.
*/
export interface Variable {
/**
* The File ID of the file to analyze. The file must be uploaded to the Writer
* platform before it can be used in a vision request. Supported file types: JPG,
* PNG, PDF, TXT (max 7MB each).
*/
file_id: string;
/**
* The name of the file variable. You must reference this name in the prompt with
* double curly braces (`{{}}`). For example,
* `Describe the difference between the image {{image_1}} and the image {{image_2}}`.
*/
name: string;
}
}
export declare namespace Vision {
export {
type VisionRequest as VisionRequest,
type VisionResponse as VisionResponse,
type VisionAnalyzeParams as VisionAnalyzeParams,
};
}