@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/limits.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// The ChatGPT plan's limits, as the Codex backend's response headers report
|
|
2
|
+
// them: a primary window and perhaps a secondary one, each a percentage used
|
|
3
|
+
// and when it resets. The plan is the one Codex reports (`codex`), whoever
|
|
4
|
+
// asked.
|
|
5
|
+
|
|
6
|
+
import type { Limit } from 'jsr:@yaks/model@0.2.36'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The readings in a response's limit headers, of `account`'s plan where the
|
|
10
|
+
* caller knows whose it is. A window of no minutes is no window.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { planLimits } from './limits.ts'
|
|
14
|
+
* import { equal } from '@yaks/testing'
|
|
15
|
+
*
|
|
16
|
+
* equal(
|
|
17
|
+
* planLimits({
|
|
18
|
+
* 'x-codex-primary-window-minutes': '10080',
|
|
19
|
+
* 'x-codex-primary-used-percent': '9',
|
|
20
|
+
* 'x-codex-primary-reset-at': '1792967691',
|
|
21
|
+
* 'x-codex-secondary-window-minutes': '0',
|
|
22
|
+
* 'x-codex-secondary-used-percent': '0',
|
|
23
|
+
* 'x-codex-secondary-reset-at': '',
|
|
24
|
+
* }),
|
|
25
|
+
* [{ provider: 'codex', window: 10080, used: 9, resets: '2026-10-25T22:34:51.000Z' }],
|
|
26
|
+
* )
|
|
27
|
+
* equal(planLimits({ 'x-ratelimit-remaining-requests': '99' }), [])
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export let planLimits = (
|
|
31
|
+
headers: Record<string, string>,
|
|
32
|
+
account?: string,
|
|
33
|
+
): Limit[] =>
|
|
34
|
+
['primary', 'secondary'].flatMap((name) => {
|
|
35
|
+
let at = (part: string) => headers[`x-codex-${name}-${part}`] ?? ''
|
|
36
|
+
let window = Number(at('window-minutes')), used = Number(at('used-percent'))
|
|
37
|
+
if (!(window > 0) || at('used-percent') == '' || !Number.isFinite(used)) {
|
|
38
|
+
return []
|
|
39
|
+
}
|
|
40
|
+
let resets = Number(at('reset-at'))
|
|
41
|
+
return [{
|
|
42
|
+
provider: 'codex',
|
|
43
|
+
...account ? { account } : {},
|
|
44
|
+
window,
|
|
45
|
+
used,
|
|
46
|
+
...resets > 0 ? { resets: new Date(resets * 1000).toISOString() } : {},
|
|
47
|
+
}]
|
|
48
|
+
})
|
package/list.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// The credential's own model listing; OpenAI gives names, Codex also windows.
|
|
2
|
+
import { ModelError } from "@yaks/model";
|
|
3
|
+
import { CODEX } from "./credential.js";
|
|
4
|
+
import { ResponseError } from "./transport.js";
|
|
5
|
+
let sleep = (ms)=>new Promise((resolve)=>setTimeout(resolve, ms));
|
|
6
|
+
// Unlike the exponential delay's cap, Retry-After is a lower bound, even
|
|
7
|
+
// when the provider asks for more than a minute. Both header forms are valid.
|
|
8
|
+
let retryAfter = (headers)=>{
|
|
9
|
+
let value = headers.get('retry-after')?.trim();
|
|
10
|
+
if (!value) return 0;
|
|
11
|
+
let ms = /^\d+(\.\d+)?$/.test(value) ? Number(value) * 1000 : Date.parse(value) - Date.now();
|
|
12
|
+
return Number.isFinite(ms) ? Math.max(0, ms) : 0;
|
|
13
|
+
};
|
|
14
|
+
let request = async (url, init, fetcher, opts)=>{
|
|
15
|
+
let retries = opts.retries ?? 2;
|
|
16
|
+
for(let failures = 0;; failures++){
|
|
17
|
+
let response;
|
|
18
|
+
try {
|
|
19
|
+
response = await fetcher(url, init);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
if (failures >= retries) {
|
|
22
|
+
throw new ModelError('transport', `Model listing transport failed: ${String(error?.message ?? error)}`, {
|
|
23
|
+
after: 0
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
await (opts.pause ?? sleep)(Math.min(1000 * 4 ** failures, 60_000));
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (response.ok || response.status == 401) return response;
|
|
30
|
+
// Consume error responses before retrying, releasing the connection. Use
|
|
31
|
+
// the Responses transport's capacity/quota classification, but never put
|
|
32
|
+
// the provider's possibly credential-bearing error body in the exception.
|
|
33
|
+
let body = await response.text().catch(()=>'');
|
|
34
|
+
let code;
|
|
35
|
+
try {
|
|
36
|
+
let error = JSON.parse(body)?.error;
|
|
37
|
+
if (typeof error?.code == 'string') code = error.code;
|
|
38
|
+
else if (typeof error?.type == 'string') code = error.type;
|
|
39
|
+
} catch {}
|
|
40
|
+
let fault = new ResponseError(`http_${response.status}`, `Model listing says ${response.status}`);
|
|
41
|
+
fault.status = response.status;
|
|
42
|
+
fault.code = code;
|
|
43
|
+
let transient = !!fault.retry || response.status == 408 || response.status == 409;
|
|
44
|
+
let after = retryAfter(response.headers);
|
|
45
|
+
if (!transient || failures >= retries) {
|
|
46
|
+
throw new ModelError(fault.kind, fault.message, transient ? {
|
|
47
|
+
after
|
|
48
|
+
} : undefined);
|
|
49
|
+
}
|
|
50
|
+
await (opts.pause ?? sleep)(Math.max(Math.min(1000 * 4 ** failures, 60_000), after));
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
export let listing = async (cred, fetcher = fetch, refresh, headers = {}, opts = {})=>{
|
|
54
|
+
let url = new URL(cred.base.replace(/\/$/, '') + '/models');
|
|
55
|
+
if (cred.base == CODEX) url.searchParams.set('client_version', '0.157.1');
|
|
56
|
+
let res = await request(url, {
|
|
57
|
+
headers: {
|
|
58
|
+
...headers,
|
|
59
|
+
...cred.token ? {
|
|
60
|
+
authorization: `Bearer ${cred.token}`
|
|
61
|
+
} : {},
|
|
62
|
+
...cred.account ? {
|
|
63
|
+
'chatgpt-account-id': cred.account
|
|
64
|
+
} : {}
|
|
65
|
+
}
|
|
66
|
+
}, fetcher, opts);
|
|
67
|
+
if (res.status == 401 && cred.base == CODEX && refresh) {
|
|
68
|
+
await res.body?.cancel();
|
|
69
|
+
return listing(await refresh(cred), fetcher, undefined, headers, opts);
|
|
70
|
+
}
|
|
71
|
+
if (!res.ok) {
|
|
72
|
+
await res.body?.cancel();
|
|
73
|
+
throw new ModelError(`http_${res.status}`, `Model listing says ${res.status}`);
|
|
74
|
+
}
|
|
75
|
+
let body = await res.json();
|
|
76
|
+
return body.models?.map((m)=>({
|
|
77
|
+
name: m.slug,
|
|
78
|
+
...m.context_window ? {
|
|
79
|
+
context: m.context_window
|
|
80
|
+
} : {}
|
|
81
|
+
})) ?? (body.data ?? []).map((m)=>({
|
|
82
|
+
name: m.id,
|
|
83
|
+
...m.context_length ? {
|
|
84
|
+
context: m.context_length
|
|
85
|
+
} : {}
|
|
86
|
+
}));
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=list.js.map
|
package/list.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sources":["./list.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,SAAsB,UAAU,2BAAgC;AAChE,SAAS,KAAK,0BAA0C;AACxD,SAAS,aAAa,yBAAwB;AAO9C,IAAI,QAAQ,CAAC,KACX,IAAI,QAAc,CAAC,UAAY,WAAW,SAAS;AAErD,yEAAyE;AACzE,8EAA8E;AAC9E,IAAI,aAAa,CAAC;EAChB,IAAI,QAAQ,QAAQ,GAAG,CAAC,gBAAgB;EACxC,IAAI,CAAC,OAAO,OAAO;EACnB,IAAI,KAAK,gBAAgB,IAAI,CAAC,SAC1B,OAAO,SAAS,OAChB,KAAK,KAAK,C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CAAC;IAC1D,CAAC,MACC,CAAC,KAAK,IAAI,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,IAAM,CAAC;MAC5B,MAAM,EAAE,EAAE;MACV,GAAG,EAAE,cAAc,GAAG;QAAE,SAAS,EAAE,cAAc;MAAC,IAAI,CAAC,CAAC;IAC1D,CAAC;AACL,EAAC"}
|
package/list.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// The credential's own model listing; OpenAI gives names, Codex also windows.
|
|
2
|
+
import { type Listed, ModelError } from '@yaks/model'
|
|
3
|
+
import { CODEX, type Credential } from './credential.js'
|
|
4
|
+
import { ResponseError } from './transport.js'
|
|
5
|
+
|
|
6
|
+
export type ListingOptions = {
|
|
7
|
+
retries?: number
|
|
8
|
+
pause?: (ms: number) => Promise<void>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let sleep = (ms: number) =>
|
|
12
|
+
new Promise<void>((resolve) => setTimeout(resolve, ms))
|
|
13
|
+
|
|
14
|
+
// Unlike the exponential delay's cap, Retry-After is a lower bound, even
|
|
15
|
+
// when the provider asks for more than a minute. Both header forms are valid.
|
|
16
|
+
let retryAfter = (headers: Headers): number => {
|
|
17
|
+
let value = headers.get('retry-after')?.trim()
|
|
18
|
+
if (!value) return 0
|
|
19
|
+
let ms = /^\d+(\.\d+)?$/.test(value)
|
|
20
|
+
? Number(value) * 1000
|
|
21
|
+
: Date.parse(value) - Date.now()
|
|
22
|
+
return Number.isFinite(ms) ? Math.max(0, ms) : 0
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let request = async (
|
|
26
|
+
url: URL,
|
|
27
|
+
init: RequestInit,
|
|
28
|
+
fetcher: typeof fetch,
|
|
29
|
+
opts: ListingOptions,
|
|
30
|
+
): Promise<Response> => {
|
|
31
|
+
let retries = opts.retries ?? 2
|
|
32
|
+
for (let failures = 0;; failures++) {
|
|
33
|
+
let response: Response
|
|
34
|
+
try {
|
|
35
|
+
response = await fetcher(url, init)
|
|
36
|
+
} catch (error) {
|
|
37
|
+
if (failures >= retries) {
|
|
38
|
+
throw new ModelError(
|
|
39
|
+
'transport',
|
|
40
|
+
`Model listing transport failed: ${
|
|
41
|
+
String((error as Error)?.message ?? error)
|
|
42
|
+
}`,
|
|
43
|
+
{ after: 0 },
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
await (opts.pause ?? sleep)(Math.min(1000 * 4 ** failures, 60_000))
|
|
47
|
+
continue
|
|
48
|
+
}
|
|
49
|
+
if (response.ok || response.status == 401) return response
|
|
50
|
+
|
|
51
|
+
// Consume error responses before retrying, releasing the connection. Use
|
|
52
|
+
// the Responses transport's capacity/quota classification, but never put
|
|
53
|
+
// the provider's possibly credential-bearing error body in the exception.
|
|
54
|
+
let body = await response.text().catch(() => '')
|
|
55
|
+
let code: string | undefined
|
|
56
|
+
try {
|
|
57
|
+
let error = JSON.parse(body)?.error
|
|
58
|
+
if (typeof error?.code == 'string') code = error.code
|
|
59
|
+
else if (typeof error?.type == 'string') code = error.type
|
|
60
|
+
} catch { /* A gateway may return HTML rather than a provider error. */ }
|
|
61
|
+
let fault = new ResponseError(
|
|
62
|
+
`http_${response.status}`,
|
|
63
|
+
`Model listing says ${response.status}`,
|
|
64
|
+
)
|
|
65
|
+
fault.status = response.status
|
|
66
|
+
fault.code = code
|
|
67
|
+
let transient = !!fault.retry || response.status == 408 ||
|
|
68
|
+
response.status == 409
|
|
69
|
+
let after = retryAfter(response.headers)
|
|
70
|
+
if (!transient || failures >= retries) {
|
|
71
|
+
throw new ModelError(
|
|
72
|
+
fault.kind,
|
|
73
|
+
fault.message,
|
|
74
|
+
transient ? { after } : undefined,
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
await (opts.pause ?? sleep)(
|
|
78
|
+
Math.max(Math.min(1000 * 4 ** failures, 60_000), after),
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export let listing = async (
|
|
84
|
+
cred: Credential,
|
|
85
|
+
fetcher: typeof fetch = fetch,
|
|
86
|
+
refresh?: (stale: Credential) => Credential | Promise<Credential>,
|
|
87
|
+
headers: Record<string, string> = {},
|
|
88
|
+
opts: ListingOptions = {},
|
|
89
|
+
): Promise<Listed[]> => {
|
|
90
|
+
let url = new URL(cred.base.replace(/\/$/, '') + '/models')
|
|
91
|
+
if (cred.base == CODEX) url.searchParams.set('client_version', '0.157.1')
|
|
92
|
+
let res = await request(
|
|
93
|
+
url,
|
|
94
|
+
{
|
|
95
|
+
headers: {
|
|
96
|
+
...headers,
|
|
97
|
+
...cred.token ? { authorization: `Bearer ${cred.token}` } : {},
|
|
98
|
+
...cred.account ? { 'chatgpt-account-id': cred.account } : {},
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
fetcher,
|
|
102
|
+
opts,
|
|
103
|
+
)
|
|
104
|
+
if (res.status == 401 && cred.base == CODEX && refresh) {
|
|
105
|
+
await res.body?.cancel()
|
|
106
|
+
return listing(await refresh(cred), fetcher, undefined, headers, opts)
|
|
107
|
+
}
|
|
108
|
+
if (!res.ok) {
|
|
109
|
+
await res.body?.cancel()
|
|
110
|
+
throw new ModelError(
|
|
111
|
+
`http_${res.status}`,
|
|
112
|
+
`Model listing says ${res.status}`,
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
let body: {
|
|
116
|
+
data?: { id: string; context_length?: number }[]
|
|
117
|
+
models?: { slug: string; context_window?: number }[]
|
|
118
|
+
} = await res.json()
|
|
119
|
+
return body.models?.map((m) => ({
|
|
120
|
+
name: m.slug,
|
|
121
|
+
...m.context_window ? { context: m.context_window } : {},
|
|
122
|
+
})) ??
|
|
123
|
+
(body.data ?? []).map((m) => ({
|
|
124
|
+
name: m.id,
|
|
125
|
+
...m.context_length ? { context: m.context_length } : {},
|
|
126
|
+
}))
|
|
127
|
+
}
|
package/mark.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// What a host writes on the entry recording a reply, importable without the
|
|
2
|
+
// model (./responses.ts): ./provider.ts marks its replies before loading it.
|
|
3
|
+
import { prefixCacheMark } from "@yaks/model";
|
|
4
|
+
// Retention for the default request settings. Earlier models that support
|
|
5
|
+
// extended retention can default to 24h depending on the account's policy.
|
|
6
|
+
// https://developers.openai.com/api/docs/guides/prompt-caching
|
|
7
|
+
let retentionOf = (model)=>/^gpt-(?:[6-9]|[1-9]\d|5\.[6-9]|5\.[1-9]\d)/.test(model) ? 1_800 : /^gpt-(?:5(?:\.(?:1|2|4|5)(?=-|$)|(?:-codex)?(?=-\d|$))|4\.1(?=-\d|$))/.test(model) ? 86_400 : 3_600;
|
|
8
|
+
/**
|
|
9
|
+
* The mark of a reply under `name`: `openai{response_id, cache_expires_at}`.
|
|
10
|
+
* The expiry is the request's start plus `retention`, a provider row's own
|
|
11
|
+
* `cache_retention` first; with neither, it is unknown.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* let reply = { id: 'resp_1', model: 'gpt', items: [] }
|
|
15
|
+
* marking('openai', 300)(reply, { requestedAt: 0 })
|
|
16
|
+
* // { openai: { response_id: 'resp_1', cache_expires_at: '1970-01-01T00:05:00.000Z' } }
|
|
17
|
+
* marking('openai')(reply, { requestedAt: 0 })
|
|
18
|
+
* // { openai: { response_id: 'resp_1', cache_expires_at: null } }
|
|
19
|
+
* ```
|
|
20
|
+
*/ export let marking = (name, retention)=>(reply, cache)=>({
|
|
21
|
+
[name]: {
|
|
22
|
+
response_id: reply.id,
|
|
23
|
+
...prefixCacheMark(reply, cache && {
|
|
24
|
+
...cache,
|
|
25
|
+
retention: cache.retention ?? (retention == 'openai-default' ? retentionOf(reply.model) : retention)
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=mark.js.map
|
package/mark.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mark.js","sources":["./mark.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,6EAA6E;AAC7E,SAA4B,eAAe,2BAA4C;AAEvF,0EAA0E;AAC1E,2EAA2E;AAC3E,+DAA+D;AAC/D,IAAI,cAAc,CAAC,QACjB,6CAA6C,IAAI,CAAC,SAC9C,QACA,wEACG,IAAI,CAAC,SACR,SACA;AAEN;;;;;;;;;;;;CAYC,GACD,OAAO,IAAI,UAAU,CACnB,MACA,YAEF,CACE,OACA,QAC4C,CAAC;MAC7C,CAAC,KAAK,EAAE;QACN,aAAa,MAAM,EAAE;QACrB,GAAG,gBACD,OACA,SAAS;UACP,GAAG,KAAK;UACR,WAAW,MAAM,SAAS,IACxB,CAAC,aAAa,mBACV,YAAY,MAAM,KAAK,IACvB,SAAS;QACjB,EACD;MACH;IACF,CAAC,EAAC"}
|
package/mark.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// What a host writes on the entry recording a reply, importable without the
|
|
2
|
+
// model (./responses.ts): ./provider.ts marks its replies before loading it.
|
|
3
|
+
import { type CacheContext, prefixCacheMark, type Reply } from '@yaks/model'
|
|
4
|
+
|
|
5
|
+
// Retention for the default request settings. Earlier models that support
|
|
6
|
+
// extended retention can default to 24h depending on the account's policy.
|
|
7
|
+
// https://developers.openai.com/api/docs/guides/prompt-caching
|
|
8
|
+
let retentionOf = (model: string): number =>
|
|
9
|
+
/^gpt-(?:[6-9]|[1-9]\d|5\.[6-9]|5\.[1-9]\d)/.test(model)
|
|
10
|
+
? 1_800
|
|
11
|
+
: /^gpt-(?:5(?:\.(?:1|2|4|5)(?=-|$)|(?:-codex)?(?=-\d|$))|4\.1(?=-\d|$))/
|
|
12
|
+
.test(model)
|
|
13
|
+
? 86_400
|
|
14
|
+
: 3_600
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The mark of a reply under `name`: `openai{response_id, cache_expires_at}`.
|
|
18
|
+
* The expiry is the request's start plus `retention`, a provider row's own
|
|
19
|
+
* `cache_retention` first; with neither, it is unknown.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* let reply = { id: 'resp_1', model: 'gpt', items: [] }
|
|
23
|
+
* marking('openai', 300)(reply, { requestedAt: 0 })
|
|
24
|
+
* // { openai: { response_id: 'resp_1', cache_expires_at: '1970-01-01T00:05:00.000Z' } }
|
|
25
|
+
* marking('openai')(reply, { requestedAt: 0 })
|
|
26
|
+
* // { openai: { response_id: 'resp_1', cache_expires_at: null } }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export let marking = (
|
|
30
|
+
name: string,
|
|
31
|
+
retention?: number | 'openai-default',
|
|
32
|
+
) =>
|
|
33
|
+
(
|
|
34
|
+
reply: Reply,
|
|
35
|
+
cache?: CacheContext,
|
|
36
|
+
): Record<string, Record<string, unknown>> => ({
|
|
37
|
+
[name]: {
|
|
38
|
+
response_id: reply.id,
|
|
39
|
+
...prefixCacheMark(
|
|
40
|
+
reply,
|
|
41
|
+
cache && {
|
|
42
|
+
...cache,
|
|
43
|
+
retention: cache.retention ??
|
|
44
|
+
(retention == 'openai-default'
|
|
45
|
+
? retentionOf(reply.model)
|
|
46
|
+
: retention),
|
|
47
|
+
},
|
|
48
|
+
),
|
|
49
|
+
},
|
|
50
|
+
})
|
package/media.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** Decode provider media at the artifact boundary, before bytes enter a store. */ import { matchesMediaType } from "@yaks/blob";
|
|
2
|
+
import { ModelError } from "@yaks/model";
|
|
3
|
+
/** Encode neutral media items for a provider's JSON input. */ export let dataUrl = (m)=>{
|
|
4
|
+
let chunks = [];
|
|
5
|
+
for(let at = 0; at < m.bytes.length; at += 8192){
|
|
6
|
+
chunks.push(String.fromCharCode(...m.bytes.subarray(at, at + 8192)));
|
|
7
|
+
}
|
|
8
|
+
return 'data:' + m.mediaType + ';base64,' + btoa(chunks.join(''));
|
|
9
|
+
};
|
|
10
|
+
/** Refuses, as the store says, when it has no room for media: asked by a
|
|
11
|
+
* model that makes bytes before its paid call. */ export let mediaRoom = async (options)=>{
|
|
12
|
+
await options?.store.room?.();
|
|
13
|
+
};
|
|
14
|
+
/** Store one complete base64 media value, returning only its address and type. */ export let generatedMedia = async (data, mediaType, call, options)=>{
|
|
15
|
+
if (!options) {
|
|
16
|
+
throw new ModelError('media_storage', 'Media output requires artifact storage');
|
|
17
|
+
}
|
|
18
|
+
let max = options.maxBytes ?? 64 * 1024 * 1024;
|
|
19
|
+
if (!Number.isSafeInteger(max) || max < 1) {
|
|
20
|
+
throw new ModelError('media_limit', 'Invalid media size limit');
|
|
21
|
+
}
|
|
22
|
+
if (typeof data != 'string' || !data.length || data.length > Math.ceil(max / 3) * 4 || data.length % 4 != 0 || /[^A-Za-z0-9+/=]/.test(data) || /=/.test(data.slice(0, -2)) || data.at(-2) == '=' && data.at(-1) != '=') {
|
|
23
|
+
throw new ModelError('media_payload', 'Invalid or oversized media payload');
|
|
24
|
+
}
|
|
25
|
+
let raw;
|
|
26
|
+
try {
|
|
27
|
+
raw = atob(data);
|
|
28
|
+
} catch {
|
|
29
|
+
throw new ModelError('media_payload', 'Invalid media encoding');
|
|
30
|
+
}
|
|
31
|
+
let bytes = Uint8Array.from(raw, (c)=>c.charCodeAt(0));
|
|
32
|
+
return await generatedBytes(bytes, mediaType, call, options);
|
|
33
|
+
};
|
|
34
|
+
/** Store bytes from a provider that answers with a binary body. */ export let generatedBytes = async (bytes, mediaType, call, options)=>{
|
|
35
|
+
if (!options) {
|
|
36
|
+
throw new ModelError('media_storage', 'Media output requires artifact storage');
|
|
37
|
+
}
|
|
38
|
+
let max = options.maxBytes ?? 64 * 1024 * 1024;
|
|
39
|
+
if (!Number.isSafeInteger(max) || max < 1) {
|
|
40
|
+
throw new ModelError('media_limit', 'Invalid media size limit');
|
|
41
|
+
}
|
|
42
|
+
if (bytes.length > max) {
|
|
43
|
+
throw new ModelError('media_payload', 'Media exceeds configured size limit');
|
|
44
|
+
}
|
|
45
|
+
if (!matchesMediaType(bytes, mediaType)) {
|
|
46
|
+
throw new ModelError('media_format', 'Media signature does not match format');
|
|
47
|
+
}
|
|
48
|
+
if (!call) throw new ModelError('media_call', 'Media output has no call ID');
|
|
49
|
+
try {
|
|
50
|
+
return {
|
|
51
|
+
...await options.store(bytes, mediaType),
|
|
52
|
+
call
|
|
53
|
+
};
|
|
54
|
+
} catch (error) {
|
|
55
|
+
// A store's own refusal, such as having no room, is said as it is.
|
|
56
|
+
if (error instanceof ModelError) throw error;
|
|
57
|
+
throw new ModelError('media_storage', 'Could not persist generated media');
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=media.js.map
|
package/media.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.js","sources":["./media.ts"],"names":[],"mappings":"AAAA,gFAAgF,GAChF,SAA6B,gBAAgB,0BAA+B;AAC5E,SAAoB,UAAU,2BAA4C;AAE1E,4DAA4D,GAC5D,OAAO,IAAI,UAAU,CAAC;EACpB,IAAI,SAAmB,EAAE;EACzB,IAAK,IAAI,KAAK,GAAG,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM,KAAM;IAChD,OAAO,IAAI,CAAC,OAAO,YAAY,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI,KAAK;EAC/D;EACA,OAAO,UAAU,EAAE,SAAS,GAAG,aAAa,KAAK,OAAO,IAAI,CAAC;AAC/D,EAAC;AAMD;gDACgD,GAChD,OAAO,IAAI,YAAY,OAAO;EAC5B,MAAM,SAAS,MAAM;AACvB,EAAC;AAED,gFAAgF,GAChF,OAAO,IAAI,iBAAiB,OAC1B,MACA,WACA,MACA;EAEA,IAAI,CAAC,SAAS;IACZ,MAAM,IAAI,WACR,iBACA;EAEJ;EACA,IAAI,MAAM,QAAQ,QAAQ,IAAI,KAAK,OAAO;EAC1C,IAAI,CAAC,OAAO,aAAa,CAAC,QAAQ,MAAM,GAAG;IACzC,MAAM,IAAI,WAAW,eAAe;EACtC;EACA,IACE,OAAO,QAAQ,YAAY,CAAC,KAAK,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provider media at the artifact boundary, before bytes enter a store. */
|
|
2
|
+
import { type ArtifactStore, matchesMediaType } from '@yaks/blob'
|
|
3
|
+
import { type Item, ModelError, type Reply } from '@yaks/model'
|
|
4
|
+
|
|
5
|
+
/** Encode neutral media items for a provider's JSON input. */
|
|
6
|
+
export let dataUrl = (m: Extract<Item, { bytes: Uint8Array }>): string => {
|
|
7
|
+
let chunks: string[] = []
|
|
8
|
+
for (let at = 0; at < m.bytes.length; at += 8192) {
|
|
9
|
+
chunks.push(String.fromCharCode(...m.bytes.subarray(at, at + 8192)))
|
|
10
|
+
}
|
|
11
|
+
return 'data:' + m.mediaType + ';base64,' + btoa(chunks.join(''))
|
|
12
|
+
}
|
|
13
|
+
export type MediaStore = {
|
|
14
|
+
store: ArtifactStore
|
|
15
|
+
maxBytes?: number
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Refuses, as the store says, when it has no room for media: asked by a
|
|
19
|
+
* model that makes bytes before its paid call. */
|
|
20
|
+
export let mediaRoom = async (options?: MediaStore): Promise<void> => {
|
|
21
|
+
await options?.store.room?.()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Store one complete base64 media value, returning only its address and type. */
|
|
25
|
+
export let generatedMedia = async (
|
|
26
|
+
data: unknown,
|
|
27
|
+
mediaType: string,
|
|
28
|
+
call: string,
|
|
29
|
+
options?: MediaStore,
|
|
30
|
+
): Promise<NonNullable<Reply['artifacts']>[number]> => {
|
|
31
|
+
if (!options) {
|
|
32
|
+
throw new ModelError(
|
|
33
|
+
'media_storage',
|
|
34
|
+
'Media output requires artifact storage',
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
let max = options.maxBytes ?? 64 * 1024 * 1024
|
|
38
|
+
if (!Number.isSafeInteger(max) || max < 1) {
|
|
39
|
+
throw new ModelError('media_limit', 'Invalid media size limit')
|
|
40
|
+
}
|
|
41
|
+
if (
|
|
42
|
+
typeof data != 'string' || !data.length ||
|
|
43
|
+
data.length > Math.ceil(max / 3) * 4 ||
|
|
44
|
+
data.length % 4 != 0 || /[^A-Za-z0-9+/=]/.test(data) ||
|
|
45
|
+
/=/.test(data.slice(0, -2)) ||
|
|
46
|
+
(data.at(-2) == '=' && data.at(-1) != '=')
|
|
47
|
+
) {
|
|
48
|
+
throw new ModelError('media_payload', 'Invalid or oversized media payload')
|
|
49
|
+
}
|
|
50
|
+
let raw: string
|
|
51
|
+
try {
|
|
52
|
+
raw = atob(data)
|
|
53
|
+
} catch {
|
|
54
|
+
throw new ModelError('media_payload', 'Invalid media encoding')
|
|
55
|
+
}
|
|
56
|
+
let bytes = Uint8Array.from(raw, (c) => c.charCodeAt(0))
|
|
57
|
+
return await generatedBytes(bytes, mediaType, call, options)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Store bytes from a provider that answers with a binary body. */
|
|
61
|
+
export let generatedBytes = async (
|
|
62
|
+
bytes: Uint8Array,
|
|
63
|
+
mediaType: string,
|
|
64
|
+
call: string,
|
|
65
|
+
options?: MediaStore,
|
|
66
|
+
): Promise<NonNullable<Reply['artifacts']>[number]> => {
|
|
67
|
+
if (!options) {
|
|
68
|
+
throw new ModelError(
|
|
69
|
+
'media_storage',
|
|
70
|
+
'Media output requires artifact storage',
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
let max = options.maxBytes ?? 64 * 1024 * 1024
|
|
74
|
+
if (!Number.isSafeInteger(max) || max < 1) {
|
|
75
|
+
throw new ModelError('media_limit', 'Invalid media size limit')
|
|
76
|
+
}
|
|
77
|
+
if (bytes.length > max) {
|
|
78
|
+
throw new ModelError('media_payload', 'Media exceeds configured size limit')
|
|
79
|
+
}
|
|
80
|
+
if (!matchesMediaType(bytes, mediaType)) {
|
|
81
|
+
throw new ModelError(
|
|
82
|
+
'media_format',
|
|
83
|
+
'Media signature does not match format',
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
if (!call) throw new ModelError('media_call', 'Media output has no call ID')
|
|
87
|
+
try {
|
|
88
|
+
return { ...await options.store(bytes, mediaType), call }
|
|
89
|
+
} catch (error) {
|
|
90
|
+
// A store's own refusal, such as having no room, is said as it is.
|
|
91
|
+
if (error instanceof ModelError) throw error
|
|
92
|
+
throw new ModelError('media_storage', 'Could not persist generated media')
|
|
93
|
+
}
|
|
94
|
+
}
|
package/mod.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @yaks/openai implements {@link https://jsr.io/@yaks/model | @yaks/model}'s
|
|
3
|
+
* `Model` interface over OpenAI's Responses API: one streamed exchange over
|
|
4
|
+
* `fetch`, a bearer an application supplies, and the endpoint it reaches. It
|
|
5
|
+
* opens no database and starts no process; a server that wants a model calls
|
|
6
|
+
* {@link responses} and gets back a `Model`.
|
|
7
|
+
*
|
|
8
|
+
* ```ts ignore
|
|
9
|
+
* import { fromEnv, responses } from '@yaks/openai'
|
|
10
|
+
* import { env } from '@yaks/process/system'
|
|
11
|
+
*
|
|
12
|
+
* let model = responses({
|
|
13
|
+
* credential: () => fromEnv(env.get)!,
|
|
14
|
+
* })
|
|
15
|
+
* let reply = await model({
|
|
16
|
+
* model: 'gpt-6.2-astra',
|
|
17
|
+
* items: [{ kind: 'user', text: 'hi' }],
|
|
18
|
+
* tools: [],
|
|
19
|
+
* })
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @module
|
|
23
|
+
*/ export { CODEX, fromChatGPT, fromEnv, OPENAI } from "./credential.js";
|
|
24
|
+
export { body, input, items, OPENAI_COMP, openaiDoc, responses } from "./responses.js";
|
|
25
|
+
export { CREDENTIAL_FAULT, frames, ResponseError, transport } from "./transport.js";
|
|
26
|
+
export { generatedBytes, generatedMedia, mediaRoom } from "./media.js";
|
|
27
|
+
export { listing } from "./list.js";
|
|
28
|
+
//# sourceMappingURL=mod.js.map
|
package/mod.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.js","sources":["./mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;CAsBC,GAED,SACE,KAAK,EAEL,WAAW,EACX,OAAO,EACP,MAAM,0BACgB;AACxB,SACE,IAAI,EACJ,KAAK,EACL,KAAK,EACL,WAAW,EACX,SAAS,EAET,SAAS,yBACY;AAEvB,SACE,gBAAgB,EAEhB,MAAM,EAEN,aAAa,EASb,SAAS,yBAEY;AAGvB,SAAS,cAAc,EAAE,cAAc,EAAE,SAAS,qBAAoB;AAGtE,SAAS,OAAO,oBAAmB"}
|
package/mod.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @yaks/openai implements {@link https://jsr.io/@yaks/model | @yaks/model}'s
|
|
3
|
+
* `Model` interface over OpenAI's Responses API: one streamed exchange over
|
|
4
|
+
* `fetch`, a bearer an application supplies, and the endpoint it reaches. It
|
|
5
|
+
* opens no database and starts no process; a server that wants a model calls
|
|
6
|
+
* {@link responses} and gets back a `Model`.
|
|
7
|
+
*
|
|
8
|
+
* ```ts ignore
|
|
9
|
+
* import { fromEnv, responses } from '@yaks/openai'
|
|
10
|
+
* import { env } from '@yaks/process/system'
|
|
11
|
+
*
|
|
12
|
+
* let model = responses({
|
|
13
|
+
* credential: () => fromEnv(env.get)!,
|
|
14
|
+
* })
|
|
15
|
+
* let reply = await model({
|
|
16
|
+
* model: 'gpt-6.2-astra',
|
|
17
|
+
* items: [{ kind: 'user', text: 'hi' }],
|
|
18
|
+
* tools: [],
|
|
19
|
+
* })
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @module
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
CODEX,
|
|
27
|
+
type Credential,
|
|
28
|
+
fromChatGPT,
|
|
29
|
+
fromEnv,
|
|
30
|
+
OPENAI,
|
|
31
|
+
} from './credential.js'
|
|
32
|
+
export {
|
|
33
|
+
body,
|
|
34
|
+
input,
|
|
35
|
+
items,
|
|
36
|
+
OPENAI_COMP,
|
|
37
|
+
openaiDoc,
|
|
38
|
+
type Options,
|
|
39
|
+
responses,
|
|
40
|
+
} from './responses.js'
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
CREDENTIAL_FAULT,
|
|
44
|
+
type CredentialSource,
|
|
45
|
+
frames,
|
|
46
|
+
type RateLimits,
|
|
47
|
+
ResponseError,
|
|
48
|
+
type ResponseEvent,
|
|
49
|
+
type ResponseFault,
|
|
50
|
+
type ResponseItem,
|
|
51
|
+
type ResponseOptions,
|
|
52
|
+
type ResponseRequest,
|
|
53
|
+
type ResponseResult,
|
|
54
|
+
type ResponseUsage,
|
|
55
|
+
type RunOptions,
|
|
56
|
+
transport,
|
|
57
|
+
type TransportCredential,
|
|
58
|
+
} from './transport.js'
|
|
59
|
+
|
|
60
|
+
export type { ImageGeneration, Images } from './images.ts'
|
|
61
|
+
export { generatedBytes, generatedMedia, mediaRoom } from './media.js'
|
|
62
|
+
export type { MediaStore } from './media.js'
|
|
63
|
+
|
|
64
|
+
export { listing } from './list.js'
|