@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/dist/index.js
CHANGED
|
@@ -24,12 +24,28 @@ const HostedAiOutputFieldSchema = z.strictObject({
|
|
|
24
24
|
type: HostedAiOutputFieldTypeSchema
|
|
25
25
|
});
|
|
26
26
|
const HostedAiInstructionsSchema = z.string().trim().min(1).max(16e3);
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Which hosted model a request runs on. Deliberately NOT named after a billing
|
|
29
|
+
* plan: which plans may reach which tier is policy (see `access-policy.ts`),
|
|
30
|
+
* not identity, so a future plan can be sold with any tier without a rename.
|
|
31
|
+
*/
|
|
32
|
+
const HostedAiModelTierSchema = z.enum(["normal", "advance"]);
|
|
33
|
+
/**
|
|
34
|
+
* The billing/access subject of a hosted request, not a route id. Sub-calls
|
|
35
|
+
* bill against the feature they serve: the page summary is `pageTranslation`,
|
|
36
|
+
* and the video summary and subtitle segmentation are `videoSubtitles`.
|
|
37
|
+
*
|
|
38
|
+
* Appended last on purpose: the db pgEnum mirrors this order, and appending
|
|
39
|
+
* keeps drizzle from emitting the ADD VALUE ... BEFORE variant.
|
|
40
|
+
*/
|
|
28
41
|
const HostedAiFeatureSchema = z.enum([
|
|
29
42
|
"pageTranslation",
|
|
30
43
|
"customAction",
|
|
31
44
|
"noteSuggestion",
|
|
32
|
-
"selectionTranslation"
|
|
45
|
+
"selectionTranslation",
|
|
46
|
+
"videoSubtitles",
|
|
47
|
+
"inputTranslation",
|
|
48
|
+
"languageDetection"
|
|
33
49
|
]);
|
|
34
50
|
const HostedAiRequestIdSchema = z.uuid();
|
|
35
51
|
const HostedAiRequestMetadataSchema = {
|
|
@@ -200,7 +216,7 @@ const HostedAiTierStatusSchema = z.strictObject({
|
|
|
200
216
|
});
|
|
201
217
|
const HostedAiFeatureStatusSchema = z.strictObject({
|
|
202
218
|
normal: HostedAiTierStatusSchema,
|
|
203
|
-
|
|
219
|
+
advance: HostedAiTierStatusSchema
|
|
204
220
|
});
|
|
205
221
|
const HostedAiStatusOutputSchema = z.strictObject({
|
|
206
222
|
credits: z.array(HostedAiCreditStatusSchema),
|
|
@@ -208,7 +224,10 @@ const HostedAiStatusOutputSchema = z.strictObject({
|
|
|
208
224
|
pageTranslation: HostedAiFeatureStatusSchema,
|
|
209
225
|
customAction: HostedAiFeatureStatusSchema,
|
|
210
226
|
noteSuggestion: HostedAiFeatureStatusSchema,
|
|
211
|
-
selectionTranslation: HostedAiFeatureStatusSchema
|
|
227
|
+
selectionTranslation: HostedAiFeatureStatusSchema,
|
|
228
|
+
videoSubtitles: HostedAiFeatureStatusSchema,
|
|
229
|
+
inputTranslation: HostedAiFeatureStatusSchema,
|
|
230
|
+
languageDetection: HostedAiFeatureStatusSchema
|
|
212
231
|
})
|
|
213
232
|
});
|
|
214
233
|
//#endregion
|
|
@@ -762,6 +781,39 @@ const hostedAiContract = {
|
|
|
762
781
|
summary: "Stream hosted selection translation text output",
|
|
763
782
|
tags: ["Hosted AI"]
|
|
764
783
|
}).input(HostedAiStreamTextInputSchema).output(eventIterator(HostedAiStreamPartSchema)).errors(hostedAiStreamErrors) },
|
|
784
|
+
videoSubtitles: {
|
|
785
|
+
streamText: oc.route({
|
|
786
|
+
method: "POST",
|
|
787
|
+
path: "/hosted-ai/video-subtitles/stream-text",
|
|
788
|
+
summary: "Stream hosted subtitle translation or video summary text output",
|
|
789
|
+
tags: ["Hosted AI"]
|
|
790
|
+
}).input(HostedAiStreamTextInputSchema).output(eventIterator(HostedAiStreamPartSchema)).errors(hostedAiStreamErrors),
|
|
791
|
+
/**
|
|
792
|
+
* Segmentation shares the `videoSubtitles` feature but not its route,
|
|
793
|
+
* because `endpointMaxOutputTokens` sizes the credit reservation: emitting
|
|
794
|
+
* a WebVTT block needs several times a subtitle line's budget, and folding
|
|
795
|
+
* both into one route would make every line reserve — and, near the end of
|
|
796
|
+
* a credit window, fail to afford — what only segmentation needs.
|
|
797
|
+
*/
|
|
798
|
+
streamSegmentation: oc.route({
|
|
799
|
+
method: "POST",
|
|
800
|
+
path: "/hosted-ai/video-subtitles/stream-segmentation",
|
|
801
|
+
summary: "Stream hosted subtitle segmentation output",
|
|
802
|
+
tags: ["Hosted AI"]
|
|
803
|
+
}).input(HostedAiStreamTextInputSchema).output(eventIterator(HostedAiStreamPartSchema)).errors(hostedAiStreamErrors)
|
|
804
|
+
},
|
|
805
|
+
inputTranslation: { streamText: oc.route({
|
|
806
|
+
method: "POST",
|
|
807
|
+
path: "/hosted-ai/input-translation/stream-text",
|
|
808
|
+
summary: "Stream hosted input box translation text output",
|
|
809
|
+
tags: ["Hosted AI"]
|
|
810
|
+
}).input(HostedAiStreamTextInputSchema).output(eventIterator(HostedAiStreamPartSchema)).errors(hostedAiStreamErrors) },
|
|
811
|
+
languageDetection: { streamText: oc.route({
|
|
812
|
+
method: "POST",
|
|
813
|
+
path: "/hosted-ai/language-detection/stream-text",
|
|
814
|
+
summary: "Stream hosted language detection output",
|
|
815
|
+
tags: ["Hosted AI"]
|
|
816
|
+
}).input(HostedAiStreamTextInputSchema).output(eventIterator(HostedAiStreamPartSchema)).errors(hostedAiStreamErrors) },
|
|
765
817
|
customAction: { streamStructuredObject: oc.route({
|
|
766
818
|
method: "POST",
|
|
767
819
|
path: "/hosted-ai/custom-actions/stream-structured-object",
|