| 1 | import type * as ml from "@distilled.cloud/gcp/ml_v1"; |
| 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 { Model } from "./Model.ts"; |
| 6 | |
| 7 | export interface PredictRequest extends Omit< |
| 8 | ml.PredictProjectsRequest, |
| 9 | "name" |
| 10 | > {} |
| 11 | |
| 12 | /** |
| 13 | * Runtime binding for AI Platform (legacy ML Engine) `projects.predict`. |
| 14 | * |
| 15 | * Bind this operation to a {@link Model} in a Function/Action init |
| 16 | * phase. Requests that omit a version use the model's default version. |
| 17 | * Provide {@link PredictHttp}. |
| 18 | * |
| 19 | * ### Predicting |
| 20 | * **Example:** Score instances |
| 21 | * ```typescript |
| 22 | * const predict = yield* GCP.ML.Predict(model); |
| 23 | * const result = yield* predict({ |
| 24 | * body: { |
| 25 | * httpBody: { |
| 26 | * contentType: "application/json", |
| 27 | * data: btoa(JSON.stringify({ instances: [{ f1: 1 }] })), |
| 28 | * }, |
| 29 | * }, |
| 30 | * }); |
| 31 | * ``` |
| 32 | * |
| 33 | * @binding |
| 34 | * @category ML |
| 35 | */ |
| 36 | export interface Predict extends Binding.Service< |
| 37 | Predict, |
| 38 | "GCP.ML.Predict", |
| 39 | ( |
| 40 | model: Model, |
| 41 | ) => Effect.Effect< |
| 42 | ( |
| 43 | request: PredictRequest, |
| 44 | ) => Effect.Effect< |
| 45 | ml.GoogleApi__HttpBody, |
| 46 | ml.PredictProjectsError, |
| 47 | RuntimeContext |
| 48 | > |
| 49 | > |
| 50 | > {} |
| 51 | |
| 52 | export const Predict = Binding.Service<Predict>("GCP.ML.Predict"); |