@read-frog/api-contract 0.12.5 → 0.12.6
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/dist/index.d.ts +283 -32
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +56 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/contracts/hosted-ai.ts +58 -0
- package/src/schemas/hosted-ai.ts +21 -4
package/package.json
CHANGED
|
@@ -48,6 +48,64 @@ export const hostedAiContract = {
|
|
|
48
48
|
.output(eventIterator(HostedAiStreamPartSchema))
|
|
49
49
|
.errors(hostedAiStreamErrors),
|
|
50
50
|
},
|
|
51
|
+
videoSubtitles: {
|
|
52
|
+
// Subtitle lines and the video summary share this route: both are short
|
|
53
|
+
// text and both bill against `videoSubtitles`.
|
|
54
|
+
streamText: oc
|
|
55
|
+
.route({
|
|
56
|
+
method: "POST",
|
|
57
|
+
path: "/hosted-ai/video-subtitles/stream-text",
|
|
58
|
+
summary: "Stream hosted subtitle translation or video summary text output",
|
|
59
|
+
tags: ["Hosted AI"],
|
|
60
|
+
})
|
|
61
|
+
.input(HostedAiStreamTextInputSchema)
|
|
62
|
+
.output(eventIterator(HostedAiStreamPartSchema))
|
|
63
|
+
.errors(hostedAiStreamErrors),
|
|
64
|
+
/**
|
|
65
|
+
* Segmentation shares the `videoSubtitles` feature but not its route,
|
|
66
|
+
* because `endpointMaxOutputTokens` sizes the credit reservation: emitting
|
|
67
|
+
* a WebVTT block needs several times a subtitle line's budget, and folding
|
|
68
|
+
* both into one route would make every line reserve — and, near the end of
|
|
69
|
+
* a credit window, fail to afford — what only segmentation needs.
|
|
70
|
+
*/
|
|
71
|
+
streamSegmentation: oc
|
|
72
|
+
.route({
|
|
73
|
+
method: "POST",
|
|
74
|
+
path: "/hosted-ai/video-subtitles/stream-segmentation",
|
|
75
|
+
summary: "Stream hosted subtitle segmentation output",
|
|
76
|
+
tags: ["Hosted AI"],
|
|
77
|
+
})
|
|
78
|
+
.input(HostedAiStreamTextInputSchema)
|
|
79
|
+
.output(eventIterator(HostedAiStreamPartSchema))
|
|
80
|
+
.errors(hostedAiStreamErrors),
|
|
81
|
+
},
|
|
82
|
+
inputTranslation: {
|
|
83
|
+
streamText: oc
|
|
84
|
+
.route({
|
|
85
|
+
method: "POST",
|
|
86
|
+
path: "/hosted-ai/input-translation/stream-text",
|
|
87
|
+
summary: "Stream hosted input box translation text output",
|
|
88
|
+
tags: ["Hosted AI"],
|
|
89
|
+
})
|
|
90
|
+
.input(HostedAiStreamTextInputSchema)
|
|
91
|
+
.output(eventIterator(HostedAiStreamPartSchema))
|
|
92
|
+
.errors(hostedAiStreamErrors),
|
|
93
|
+
},
|
|
94
|
+
languageDetection: {
|
|
95
|
+
// Detection wants one short string back, not a stream, but the quota
|
|
96
|
+
// reserve/settle path is stream-shaped end to end. Reusing it keeps one
|
|
97
|
+
// metering implementation; the client collects the deltas.
|
|
98
|
+
streamText: oc
|
|
99
|
+
.route({
|
|
100
|
+
method: "POST",
|
|
101
|
+
path: "/hosted-ai/language-detection/stream-text",
|
|
102
|
+
summary: "Stream hosted language detection output",
|
|
103
|
+
tags: ["Hosted AI"],
|
|
104
|
+
})
|
|
105
|
+
.input(HostedAiStreamTextInputSchema)
|
|
106
|
+
.output(eventIterator(HostedAiStreamPartSchema))
|
|
107
|
+
.errors(hostedAiStreamErrors),
|
|
108
|
+
},
|
|
51
109
|
customAction: {
|
|
52
110
|
streamStructuredObject: oc
|
|
53
111
|
.route({
|
package/src/schemas/hosted-ai.ts
CHANGED
|
@@ -9,14 +9,28 @@ export const HostedAiOutputFieldSchema = z.strictObject({
|
|
|
9
9
|
|
|
10
10
|
const HostedAiInstructionsSchema = z.string().trim().min(1).max(16000)
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Which hosted model a request runs on. Deliberately NOT named after a billing
|
|
14
|
+
* plan: which plans may reach which tier is policy (see `access-policy.ts`),
|
|
15
|
+
* not identity, so a future plan can be sold with any tier without a rename.
|
|
16
|
+
*/
|
|
17
|
+
export const HostedAiModelTierSchema = z.enum(["normal", "advance"])
|
|
18
|
+
/**
|
|
19
|
+
* The billing/access subject of a hosted request, not a route id. Sub-calls
|
|
20
|
+
* bill against the feature they serve: the page summary is `pageTranslation`,
|
|
21
|
+
* and the video summary and subtitle segmentation are `videoSubtitles`.
|
|
22
|
+
*
|
|
23
|
+
* Appended last on purpose: the db pgEnum mirrors this order, and appending
|
|
24
|
+
* keeps drizzle from emitting the ADD VALUE ... BEFORE variant.
|
|
25
|
+
*/
|
|
13
26
|
export const HostedAiFeatureSchema = z.enum([
|
|
14
27
|
"pageTranslation",
|
|
15
28
|
"customAction",
|
|
16
29
|
"noteSuggestion",
|
|
17
|
-
// Appended last on purpose: the db pgEnum mirrors this order, and appending
|
|
18
|
-
// keeps drizzle from emitting the ADD VALUE ... BEFORE variant.
|
|
19
30
|
"selectionTranslation",
|
|
31
|
+
"videoSubtitles",
|
|
32
|
+
"inputTranslation",
|
|
33
|
+
"languageDetection",
|
|
20
34
|
])
|
|
21
35
|
export const HostedAiRequestIdSchema = z.uuid()
|
|
22
36
|
|
|
@@ -210,7 +224,7 @@ export const HostedAiTierStatusSchema = z.strictObject({
|
|
|
210
224
|
|
|
211
225
|
export const HostedAiFeatureStatusSchema = z.strictObject({
|
|
212
226
|
normal: HostedAiTierStatusSchema,
|
|
213
|
-
|
|
227
|
+
advance: HostedAiTierStatusSchema,
|
|
214
228
|
})
|
|
215
229
|
|
|
216
230
|
export const HostedAiStatusOutputSchema = z.strictObject({
|
|
@@ -220,6 +234,9 @@ export const HostedAiStatusOutputSchema = z.strictObject({
|
|
|
220
234
|
customAction: HostedAiFeatureStatusSchema,
|
|
221
235
|
noteSuggestion: HostedAiFeatureStatusSchema,
|
|
222
236
|
selectionTranslation: HostedAiFeatureStatusSchema,
|
|
237
|
+
videoSubtitles: HostedAiFeatureStatusSchema,
|
|
238
|
+
inputTranslation: HostedAiFeatureStatusSchema,
|
|
239
|
+
languageDetection: HostedAiFeatureStatusSchema,
|
|
223
240
|
}),
|
|
224
241
|
})
|
|
225
242
|
|