| 1 | import type * as translate from "@distilled.cloud/gcp/translate_v3"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { RuntimeContext } from "../../RuntimeContext.ts"; |
| 5 | import type { AdaptiveMtDataset } from "./AdaptiveMtDataset.ts"; |
| 6 | |
| 7 | export interface AdaptiveMtTranslateRequest { |
| 8 | /** |
| 9 | * Request body. `dataset` is filled from the bound Adaptive MT |
| 10 | * dataset. |
| 11 | */ |
| 12 | body?: Omit<translate.AdaptiveMtTranslateRequest, "dataset">; |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * Runtime binding for Cloud Translation `adaptiveMtTranslate`. |
| 17 | * |
| 18 | * Bind this operation to an {@link AdaptiveMtDataset} in a Function/Action |
| 19 | * init phase. Provide {@link AdaptiveMtTranslateHttp}. |
| 20 | * |
| 21 | * ### Translating with Adaptive MT |
| 22 | * **Example:** Translate a sentence |
| 23 | * ```typescript |
| 24 | * const translateText = yield* GCP.Translate.AdaptiveMtTranslate(dataset); |
| 25 | * const result = yield* translateText({ |
| 26 | * body: { content: ["Hello, world"] }, |
| 27 | * }); |
| 28 | * ``` |
| 29 | * |
| 30 | * @binding |
| 31 | * @category Translate |
| 32 | */ |
| 33 | export interface AdaptiveMtTranslate extends Binding.Service< |
| 34 | AdaptiveMtTranslate, |
| 35 | "GCP.Translate.AdaptiveMtTranslate", |
| 36 | ( |
| 37 | dataset: AdaptiveMtDataset, |
| 38 | ) => Effect.Effect< |
| 39 | ( |
| 40 | request?: AdaptiveMtTranslateRequest, |
| 41 | ) => Effect.Effect< |
| 42 | translate.AdaptiveMtTranslateResponse, |
| 43 | translate.AdaptiveMtTranslateProjectsLocationsError, |
| 44 | RuntimeContext |
| 45 | > |
| 46 | > |
| 47 | > {} |
| 48 | |
| 49 | export const AdaptiveMtTranslate = Binding.Service<AdaptiveMtTranslate>( |
| 50 | "GCP.Translate.AdaptiveMtTranslate", |
| 51 | ); |