@yaks/openai 0.0.0-stage → 0.2.36
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 +202 -0
- package/README.md +389 -2
- package/_dist/batches.d.ts +77 -0
- package/_dist/batches.d.ts.map +1 -0
- package/_dist/credential.d.ts +13 -0
- package/_dist/credential.d.ts.map +1 -0
- package/_dist/images.d.ts +15 -0
- package/_dist/images.d.ts.map +1 -0
- package/_dist/list.d.ts +8 -0
- package/_dist/list.d.ts.map +1 -0
- package/_dist/media.d.ts +11 -0
- package/_dist/media.d.ts.map +1 -0
- package/_dist/mod.d.ts +30 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/project-keys.d.ts +4 -0
- package/_dist/project-keys.d.ts.map +1 -0
- package/_dist/provider.d.ts +48 -0
- package/_dist/provider.d.ts.map +1 -0
- package/_dist/responses.d.ts +51 -0
- package/_dist/responses.d.ts.map +1 -0
- package/_dist/transport.d.ts +121 -0
- package/_dist/transport.d.ts.map +1 -0
- package/_dist/vocab.d.ts +10 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/batches.js +145 -0
- package/batches.js.map +1 -0
- package/batches.ts +194 -0
- package/credential.js +30 -0
- package/credential.js.map +1 -0
- package/credential.ts +40 -0
- package/deno.json +1 -0
- package/generations.js +288 -0
- package/generations.js.map +1 -0
- package/generations.ts +365 -0
- package/images.js +37 -0
- package/images.js.map +1 -0
- package/images.ts +63 -0
- package/info.js +55 -0
- package/info.js.map +1 -0
- package/info.ts +59 -0
- package/limits.js +50 -0
- package/limits.js.map +1 -0
- package/limits.ts +48 -0
- package/list.js +88 -0
- package/list.js.map +1 -0
- package/list.ts +127 -0
- package/mark.js +29 -0
- package/mark.js.map +1 -0
- package/mark.ts +50 -0
- package/media.js +60 -0
- package/media.js.map +1 -0
- package/media.ts +94 -0
- package/mod.js +28 -0
- package/mod.js.map +1 -0
- package/mod.ts +64 -0
- package/native.js +176 -0
- package/native.js.map +1 -0
- package/native.ts +221 -0
- package/package.json +36 -4
- package/project-keys.js +32 -0
- package/project-keys.js.map +1 -0
- package/project-keys.ts +43 -0
- package/provider.js +190 -0
- package/provider.js.map +1 -0
- package/provider.ts +292 -0
- package/reads.js +167 -0
- package/reads.js.map +1 -0
- package/reads.ts +169 -0
- package/responses.js +612 -0
- package/responses.js.map +1 -0
- package/responses.ts +706 -0
- package/transport.js +646 -0
- package/transport.js.map +1 -0
- package/transport.ts +972 -0
- package/vocab.js +23 -0
- package/vocab.js.map +1 -0
- package/vocab.json +25 -0
- package/vocab.ts +29 -0
package/reads.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
// Responses accepts these MIME types as input_file, including office files.
|
|
2
|
+
// https://developers.openai.com/api/docs/guides/file-inputs
|
|
3
|
+
// Files are under 50 MB each and together per request. PDF and images require
|
|
4
|
+
// vision; non-PDF documents contribute extracted text or spreadsheet metadata.
|
|
5
|
+
// https://developers.openai.com/api/docs/models/o3-mini documents a text-only
|
|
6
|
+
// Responses model: it receives those non-PDF inputs without PDF page images.
|
|
7
|
+
|
|
8
|
+
/** Every non-PDF MIME type in the Responses file-input guide. */
|
|
9
|
+
export let FILES: Record<string, number> = Object.fromEntries([
|
|
10
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
11
|
+
'application/vnd.ms-excel',
|
|
12
|
+
'text/csv',
|
|
13
|
+
'application/csv',
|
|
14
|
+
'text/tsv',
|
|
15
|
+
'text/x-iif',
|
|
16
|
+
'application/x-iif',
|
|
17
|
+
'application/vnd.google-apps.spreadsheet',
|
|
18
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
19
|
+
'application/msword',
|
|
20
|
+
'application/rtf',
|
|
21
|
+
'text/rtf',
|
|
22
|
+
'application/vnd.oasis.opendocument.text',
|
|
23
|
+
'application/vnd.apple.pages',
|
|
24
|
+
'application/vnd.google-apps.document',
|
|
25
|
+
'application/vnd.apple.iwork',
|
|
26
|
+
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
27
|
+
'application/vnd.ms-powerpoint',
|
|
28
|
+
'application/vnd.apple.keynote',
|
|
29
|
+
'application/vnd.google-apps.presentation',
|
|
30
|
+
'application/javascript',
|
|
31
|
+
'application/typescript',
|
|
32
|
+
'text/xml',
|
|
33
|
+
'text/x-shellscript',
|
|
34
|
+
'text/x-rst',
|
|
35
|
+
'text/x-makefile',
|
|
36
|
+
'text/x-lisp',
|
|
37
|
+
'text/x-asm',
|
|
38
|
+
'text/vbscript',
|
|
39
|
+
'text/css',
|
|
40
|
+
'message/rfc822',
|
|
41
|
+
'application/x-sql',
|
|
42
|
+
'application/x-scala',
|
|
43
|
+
'application/x-rust',
|
|
44
|
+
'application/x-powershell',
|
|
45
|
+
'text/x-diff',
|
|
46
|
+
'text/x-patch',
|
|
47
|
+
'application/x-patch',
|
|
48
|
+
'text/plain',
|
|
49
|
+
'text/markdown',
|
|
50
|
+
'text/x-java',
|
|
51
|
+
'text/x-script.python',
|
|
52
|
+
'text/x-python',
|
|
53
|
+
'text/x-c',
|
|
54
|
+
'text/x-c++',
|
|
55
|
+
'text/x-golang',
|
|
56
|
+
'text/html',
|
|
57
|
+
'text/x-php',
|
|
58
|
+
'application/x-php',
|
|
59
|
+
'application/x-httpd-php',
|
|
60
|
+
'application/x-httpd-php-source',
|
|
61
|
+
'text/x-ruby',
|
|
62
|
+
'text/x-sh',
|
|
63
|
+
'text/x-bash',
|
|
64
|
+
'application/x-bash',
|
|
65
|
+
'text/x-zsh',
|
|
66
|
+
'text/x-tex',
|
|
67
|
+
'text/x-csharp',
|
|
68
|
+
'application/json',
|
|
69
|
+
'text/x-typescript',
|
|
70
|
+
'text/javascript',
|
|
71
|
+
'text/x-go',
|
|
72
|
+
'text/x-rust',
|
|
73
|
+
'text/x-scala',
|
|
74
|
+
'text/x-kotlin',
|
|
75
|
+
'text/x-swift',
|
|
76
|
+
'text/x-lua',
|
|
77
|
+
'text/x-r',
|
|
78
|
+
'text/x-R',
|
|
79
|
+
'text/x-julia',
|
|
80
|
+
'text/x-perl',
|
|
81
|
+
'text/x-objectivec',
|
|
82
|
+
'text/x-objectivec++',
|
|
83
|
+
'text/x-erlang',
|
|
84
|
+
'text/x-elixir',
|
|
85
|
+
'text/x-haskell',
|
|
86
|
+
'text/x-clojure',
|
|
87
|
+
'text/x-groovy',
|
|
88
|
+
'text/x-dart',
|
|
89
|
+
'text/x-awk',
|
|
90
|
+
'application/x-awk',
|
|
91
|
+
'text/jsx',
|
|
92
|
+
'text/tsx',
|
|
93
|
+
'text/x-handlebars',
|
|
94
|
+
'text/x-mustache',
|
|
95
|
+
'text/x-ejs',
|
|
96
|
+
'text/x-jinja2',
|
|
97
|
+
'text/x-liquid',
|
|
98
|
+
'text/x-erb',
|
|
99
|
+
'text/x-twig',
|
|
100
|
+
'text/x-pug',
|
|
101
|
+
'text/x-jade',
|
|
102
|
+
'text/x-tmpl',
|
|
103
|
+
'text/x-cmake',
|
|
104
|
+
'text/x-dockerfile',
|
|
105
|
+
'text/x-gradle',
|
|
106
|
+
'text/x-ini',
|
|
107
|
+
'text/x-properties',
|
|
108
|
+
'text/x-protobuf',
|
|
109
|
+
'application/x-protobuf',
|
|
110
|
+
'text/x-sql',
|
|
111
|
+
'text/x-sass',
|
|
112
|
+
'text/x-scss',
|
|
113
|
+
'text/x-less',
|
|
114
|
+
'text/x-hcl',
|
|
115
|
+
'text/x-terraform',
|
|
116
|
+
'application/x-terraform',
|
|
117
|
+
'text/x-toml',
|
|
118
|
+
'application/x-toml',
|
|
119
|
+
'application/graphql',
|
|
120
|
+
'application/x-graphql',
|
|
121
|
+
'text/x-graphql',
|
|
122
|
+
'application/x-ndjson',
|
|
123
|
+
'application/json5',
|
|
124
|
+
'application/x-json5',
|
|
125
|
+
'text/x-yaml',
|
|
126
|
+
'application/toml',
|
|
127
|
+
'application/x-yaml',
|
|
128
|
+
'application/yaml',
|
|
129
|
+
'text/x-astro',
|
|
130
|
+
'text/srt',
|
|
131
|
+
'application/x-subrip',
|
|
132
|
+
'text/x-subrip',
|
|
133
|
+
'text/vtt',
|
|
134
|
+
'text/x-vcard',
|
|
135
|
+
'text/calendar',
|
|
136
|
+
].map((type) => [type, 50 * 1024 * 1024 - 1]))
|
|
137
|
+
|
|
138
|
+
// https://developers.openai.com/api/docs/guides/images-vision
|
|
139
|
+
// PNG/JPEG/WebP/non-animated GIF; 512 MB total request payload, including base64.
|
|
140
|
+
let references = Object.fromEntries(
|
|
141
|
+
['image/png', 'image/jpeg', 'image/webp'].map((
|
|
142
|
+
type,
|
|
143
|
+
) => [type, 14 * 1024 * 1024]),
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
let images = Object.fromEntries(
|
|
147
|
+
['image/png', 'image/jpeg', 'image/webp', 'image/gif'].map((
|
|
148
|
+
type,
|
|
149
|
+
) => [type, 384 * 1024 * 1024]),
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
/** Responses file inputs, keeping text-only and specialized endpoints apart. */
|
|
153
|
+
export let reads = (name: string): Record<string, number> => {
|
|
154
|
+
if (/^gpt-image-2\.[56](?:-|$)/.test(name)) return references
|
|
155
|
+
let text =
|
|
156
|
+
/^(gpt-(4o|4\.1|5|6)(?:[.-]|$)|o[134](?:-|$)|chatgpt-4o)/.test(name) &&
|
|
157
|
+
!/^(o1-(mini|preview))/.test(name) &&
|
|
158
|
+
!/(audio|transcribe|tts|realtime|search-api)/.test(name)
|
|
159
|
+
let vision =
|
|
160
|
+
/^(gpt-(4o|4\.1|5|6)(?:[.-]|$)|o1(?:-|$)|o3(?:-|$)|o4-mini(?:-|$)|chatgpt-4o)/
|
|
161
|
+
.test(name) &&
|
|
162
|
+
!/^(o1-(mini|preview)|o3-mini)/.test(name) &&
|
|
163
|
+
!/(audio|transcribe|tts|realtime|search-api)/.test(name)
|
|
164
|
+
return !text
|
|
165
|
+
? {}
|
|
166
|
+
: vision
|
|
167
|
+
? { ...FILES, ...images, 'application/pdf': 50 * 1024 * 1024 - 1 }
|
|
168
|
+
: FILES
|
|
169
|
+
}
|