1import type * as translate from "@distilled.cloud/gcp/translate_v3";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { RuntimeContext } from "../../RuntimeContext.ts";
5import type { Model } from "./Model.ts";
6
7export interface TranslateTextRequest {
8 /**
9 * Request body. `model` is filled from the bound custom model.
10 */
11 body?: Omit<translate.TranslateTextRequest, "model">;
12}
13
14/**
15 * Runtime binding for Cloud Translation `translateText` using a custom
16 * AutoML model.
17 *
18 * Bind this operation to a {@link Model} in a Function/Action init
19 * phase. Provide {@link TranslateTextHttp}.
20 *
21 * ### Translating with a Custom Model
22 * **Example:** Translate a sentence
23 * ```typescript
24 * const translateText = yield* GCP.Translate.TranslateText(model);
25 * const result = yield* translateText({
26 * body: {
27 * contents: ["Hello, world"],
28 * targetLanguageCode: "es",
29 * sourceLanguageCode: "en",
30 * mimeType: "text/plain",
31 * },
32 * });
33 * ```
34 *
35 * @binding
36 * @category Translate
37 */
38export interface TranslateText extends Binding.Service<
39 TranslateText,
40 "GCP.Translate.TranslateText",
41 (
42 model: Model,
43 ) => Effect.Effect<
44 (
45 request?: TranslateTextRequest,
46 ) => Effect.Effect<
47 translate.TranslateTextResponse,
48 translate.TranslateTextProjectsLocationsError,
49 RuntimeContext
50 >
51 >
52> {}
53
54export const TranslateText = Binding.Service<TranslateText>(
55 "GCP.Translate.TranslateText",
56);