UNPKG

@genkit-ai/flow

Version:

Genkit AI framework workflow APIs.

64 lines (60 loc) 2.34 kB
import { FlowState, Operation, FlowStateExecution } from '@genkit-ai/core'; import { z } from 'zod'; import { F as Flow, R as RunStepConfig } from './flow-DR52DKjZ.js'; import 'body-parser'; import 'cors'; import 'express'; /** * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Context object encapsulates flow execution state at runtime. */ declare class Context<I extends z.ZodTypeAny, O extends z.ZodTypeAny, S extends z.ZodTypeAny> { readonly flow: Flow<I, O, S>; readonly flowId: string; readonly state: FlowState; readonly auth?: unknown; private seenSteps; constructor(flow: Flow<I, O, S>, flowId: string, state: FlowState, auth?: unknown); private isCached; private getCached; private updateCachedValue; private memoize; saveState(): Promise<void>; run<T>(config: RunStepConfig, input: any | undefined, func: () => Promise<T>): Promise<T>; private resolveStepName; interrupt<I extends z.ZodTypeAny, O>(stepName: string, func: (payload: I) => Promise<O>, responseSchema: I | null, skipCache?: boolean): Promise<O>; sleep<I extends z.ZodTypeAny, O extends z.ZodTypeAny>(stepName: string, seconds: number): Promise<O>; /** * Wait for the provided flow to complete execution. This will do a poll. * Poll will be done with an exponential backoff (configurable). */ waitFor(opts: { flow: Flow<z.ZodTypeAny, z.ZodTypeAny, z.ZodTypeAny>; stepName: string; flowIds: string[]; pollingConfig?: PollingConfig; }): Promise<Operation[]>; private getFlowsOperations; /** * Returns current active execution state. */ getCurrentExecution(): FlowStateExecution; } interface PollingConfig { interval: number; } export { Context, type PollingConfig };