UNPKG

@genkit-ai/flow

Version:

Genkit AI framework workflow APIs.

1 lines 36.6 kB
{"version":3,"sources":["../src/flow.ts"],"sourcesContent":["/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Action,\n FlowError,\n FlowState,\n FlowStateSchema,\n FlowStateStore,\n Operation,\n StreamingCallback,\n defineAction,\n getStreamingCallback,\n config as globalConfig,\n isDevEnv,\n} from '@genkit-ai/core';\nimport { logger } from '@genkit-ai/core/logging';\nimport { toJsonSchema } from '@genkit-ai/core/schema';\nimport {\n SPAN_TYPE_ATTR,\n newTrace,\n setCustomMetadataAttribute,\n setCustomMetadataAttributes,\n} from '@genkit-ai/core/tracing';\nimport { SpanStatusCode } from '@opentelemetry/api';\nimport * as bodyParser from 'body-parser';\nimport { CorsOptions, default as cors } from 'cors';\nimport express from 'express';\nimport { performance } from 'node:perf_hooks';\nimport * as z from 'zod';\nimport { Context } from './context.js';\nimport {\n FlowExecutionError,\n FlowStillRunningError,\n InterruptError,\n getErrorMessage,\n getErrorStack,\n} from './errors.js';\nimport {\n FlowActionInputSchema,\n FlowInvokeEnvelopeMessage,\n FlowInvokeEnvelopeMessageSchema,\n Invoker,\n RetryConfig,\n Scheduler,\n} from './types.js';\nimport {\n generateFlowId,\n metadataPrefix,\n runWithActiveContext,\n} from './utils.js';\n\nconst streamDelimiter = '\\n';\n\nconst CREATED_FLOWS = 'genkit__CREATED_FLOWS';\n\nfunction createdFlows(): Flow<any, any, any>[] {\n if (global[CREATED_FLOWS] === undefined) {\n global[CREATED_FLOWS] = [];\n }\n return global[CREATED_FLOWS];\n}\n\n/**\n * Step configuration for retries, etc.\n */\nexport interface RunStepConfig {\n name: string;\n retryConfig?: RetryConfig;\n}\n\n/**\n * Flow Auth policy. Consumes the authorization context of the flow and\n * performs checks before the flow runs. If this throws, the flow will not\n * be executed.\n */\nexport interface FlowAuthPolicy<I extends z.ZodTypeAny = z.ZodTypeAny> {\n (auth: any | undefined, input: z.infer<I>): void | Promise<void>;\n}\n\n/**\n * For express-based flows, req.auth should contain the value to bepassed into\n * the flow context.\n */\nexport interface __RequestWithAuth extends express.Request {\n auth?: unknown;\n}\n\n/**\n * Defines the flow.\n */\nexport function defineFlow<\n I extends z.ZodTypeAny = z.ZodTypeAny,\n O extends z.ZodTypeAny = z.ZodTypeAny,\n S extends z.ZodTypeAny = z.ZodTypeAny,\n>(\n config: {\n name: string;\n inputSchema?: I;\n outputSchema?: O;\n streamSchema?: S;\n authPolicy?: FlowAuthPolicy<I>;\n middleware?: express.RequestHandler[];\n invoker?: Invoker<I, O, S>;\n experimentalDurable?: boolean;\n experimentalScheduler?: Scheduler<I, O, S>;\n },\n steps: StepsFunction<I, O, S>\n): Flow<I, O, S> {\n const f = new Flow(\n {\n name: config.name,\n inputSchema: config.inputSchema,\n outputSchema: config.outputSchema,\n streamSchema: config.streamSchema,\n experimentalDurable: !!config.experimentalDurable,\n stateStore: globalConfig\n ? () => globalConfig.getFlowStateStore()\n : undefined,\n authPolicy: config.authPolicy,\n middleware: config.middleware,\n // We always use local dispatcher in dev mode or when one is not provided.\n invoker: async (flow, msg, streamingCallback) => {\n if (!isDevEnv() && config.invoker) {\n return config.invoker(flow, msg, streamingCallback);\n }\n const state = await flow.runEnvelope(msg, streamingCallback);\n return state.operation;\n },\n scheduler: async (flow, msg, delay = 0) => {\n if (!config.experimentalDurable) {\n throw new Error(\n 'This flow is not durable, cannot use scheduling features.'\n );\n }\n if (!isDevEnv() && config.experimentalScheduler) {\n return config.experimentalScheduler(flow, msg, delay);\n }\n setTimeout(() => flow.runEnvelope(msg), delay * 1000);\n },\n },\n steps\n );\n createdFlows().push(f);\n wrapAsAction(f);\n return f;\n}\n\nexport interface FlowWrapper<\n I extends z.ZodTypeAny = z.ZodTypeAny,\n O extends z.ZodTypeAny = z.ZodTypeAny,\n S extends z.ZodTypeAny = z.ZodTypeAny,\n> {\n flow: Flow<I, O, S>;\n}\n\nexport class Flow<\n I extends z.ZodTypeAny = z.ZodTypeAny,\n O extends z.ZodTypeAny = z.ZodTypeAny,\n S extends z.ZodTypeAny = z.ZodTypeAny,\n> {\n readonly name: string;\n readonly inputSchema?: I;\n readonly outputSchema?: O;\n readonly streamSchema?: S;\n readonly stateStore?: () => Promise<FlowStateStore>;\n readonly invoker: Invoker<I, O, S>;\n readonly scheduler: Scheduler<I, O, S>;\n readonly experimentalDurable: boolean;\n readonly authPolicy?: FlowAuthPolicy<I>;\n readonly middleware?: express.RequestHandler[];\n\n constructor(\n config: {\n name: string;\n inputSchema?: I;\n outputSchema?: O;\n streamSchema?: S;\n stateStore?: () => Promise<FlowStateStore>;\n invoker: Invoker<I, O, S>;\n scheduler: Scheduler<I, O, S>;\n experimentalDurable: boolean;\n authPolicy?: FlowAuthPolicy<I>;\n middleware?: express.RequestHandler[];\n },\n private steps: StepsFunction<I, O, S>\n ) {\n this.name = config.name;\n this.inputSchema = config.inputSchema;\n this.outputSchema = config.outputSchema;\n this.streamSchema = config.streamSchema;\n this.stateStore = config.stateStore;\n this.invoker = config.invoker;\n this.scheduler = config.scheduler;\n this.experimentalDurable = config.experimentalDurable;\n this.authPolicy = config.authPolicy;\n this.middleware = config.middleware;\n\n // Durable flows can't use an auth policy; instead they should be invoked\n // from a privileged context after ACL checks are performed.\n if (this.authPolicy && this.experimentalDurable) {\n throw new Error('Durable flows can not define auth policies.');\n }\n }\n\n /**\n * Executes the flow with the input directly.\n *\n * This will either be called by runEnvelope when starting durable flows,\n * or it will be called directly when starting non-durable flows.\n */\n async runDirectly(\n input: unknown,\n opts: {\n streamingCallback?: StreamingCallback<unknown>;\n labels?: Record<string, string>;\n auth?: unknown;\n }\n ): Promise<FlowState> {\n const flowId = generateFlowId();\n const state = createNewState(flowId, this.name, input);\n const ctx = new Context(this, flowId, state, opts.auth);\n try {\n await this.executeSteps(\n ctx,\n this.steps,\n 'start',\n opts.streamingCallback,\n opts.labels\n );\n } finally {\n if (isDevEnv() || this.experimentalDurable) {\n await ctx.saveState();\n }\n }\n return state;\n }\n\n /**\n * Executes the flow with the input in the envelope format.\n */\n async runEnvelope(\n req: FlowInvokeEnvelopeMessage,\n streamingCallback?: StreamingCallback<any>,\n auth?: unknown\n ): Promise<FlowState> {\n logger.debug(req, 'runEnvelope');\n if (req.start) {\n // First time, create new state.\n return this.runDirectly(req.start.input, {\n streamingCallback,\n auth,\n labels: req.start.labels,\n });\n }\n if (req.schedule) {\n if (!this.experimentalDurable) {\n throw new Error('Cannot schedule a non-durable flow');\n }\n if (!this.stateStore) {\n throw new Error(\n 'Flow state store for durable flows must be configured'\n );\n }\n // First time, create new state.\n const flowId = generateFlowId();\n const state = createNewState(flowId, this.name, req.schedule.input);\n try {\n await (await this.stateStore()).save(flowId, state);\n await this.scheduler(\n this,\n { runScheduled: { flowId } } as FlowInvokeEnvelopeMessage,\n req.schedule.delay\n );\n } catch (e) {\n state.operation.done = true;\n state.operation.result = {\n error: getErrorMessage(e),\n stacktrace: getErrorStack(e),\n };\n await (await this.stateStore()).save(flowId, state);\n }\n return state;\n }\n if (req.state) {\n if (!this.experimentalDurable) {\n throw new Error('Cannot state check a non-durable flow');\n }\n if (!this.stateStore) {\n throw new Error(\n 'Flow state store for durable flows must be configured'\n );\n }\n const flowId = req.state.flowId;\n const state = await (await this.stateStore()).load(flowId);\n if (state === undefined) {\n throw new Error(`Unable to find flow state for ${flowId}`);\n }\n return state;\n }\n if (req.runScheduled) {\n if (!this.experimentalDurable) {\n throw new Error('Cannot run scheduled non-durable flow');\n }\n if (!this.stateStore) {\n throw new Error(\n 'Flow state store for durable flows must be configured'\n );\n }\n const flowId = req.runScheduled.flowId;\n const state = await (await this.stateStore()).load(flowId);\n if (state === undefined) {\n throw new Error(`Unable to find flow state for ${flowId}`);\n }\n const ctx = new Context(this, flowId, state);\n try {\n await this.executeSteps(\n ctx,\n this.steps,\n 'runScheduled',\n undefined,\n undefined\n );\n } finally {\n await ctx.saveState();\n }\n return state;\n }\n if (req.resume) {\n if (!this.experimentalDurable) {\n throw new Error('Cannot resume a non-durable flow');\n }\n if (!this.stateStore) {\n throw new Error(\n 'Flow state store for durable flows must be configured'\n );\n }\n const flowId = req.resume.flowId;\n const state = await (await this.stateStore()).load(flowId);\n if (state === undefined) {\n throw new Error(`Unable to find flow state for ${flowId}`);\n }\n if (!state.blockedOnStep) {\n throw new Error(\n \"Unable to resume flow that's currently not interrupted\"\n );\n }\n state.eventsTriggered[state.blockedOnStep.name] = req.resume.payload;\n const ctx = new Context(this, flowId, state);\n try {\n await this.executeSteps(\n ctx,\n this.steps,\n 'resume',\n undefined,\n undefined\n );\n } finally {\n await ctx.saveState();\n }\n return state;\n }\n // TODO: add retry\n\n throw new Error(\n 'Unexpected envelope message case, must set one of: ' +\n 'start, schedule, runScheduled, resume, retry, state'\n );\n }\n\n // TODO: refactor me... this is a mess!\n private async executeSteps(\n ctx: Context<I, O, S>,\n handler: StepsFunction<I, O, S>,\n dispatchType: string,\n streamingCallback: StreamingCallback<any> | undefined,\n labels: Record<string, string> | undefined\n ) {\n const startTimeMs = performance.now();\n await runWithActiveContext(ctx, async () => {\n let traceContext;\n if (ctx.state.traceContext) {\n traceContext = JSON.parse(ctx.state.traceContext);\n }\n let ctxLinks = traceContext ? [{ context: traceContext }] : [];\n let errored = false;\n const output = await newTrace(\n {\n name: ctx.flow.name,\n labels: {\n [SPAN_TYPE_ATTR]: 'flow',\n },\n links: ctxLinks,\n },\n async (metadata, rootSpan) => {\n ctx.state.executions.push({\n startTime: Date.now(),\n traceIds: [],\n });\n setCustomMetadataAttribute(\n metadataPrefix(`execution`),\n (ctx.state.executions.length - 1).toString()\n );\n if (labels) {\n Object.keys(labels).forEach((label) => {\n setCustomMetadataAttribute(\n metadataPrefix(`label:${label}`),\n labels[label]\n );\n });\n }\n\n setCustomMetadataAttributes({\n [metadataPrefix('name')]: this.name,\n [metadataPrefix('id')]: ctx.flowId,\n });\n ctx\n .getCurrentExecution()\n .traceIds.push(rootSpan.spanContext().traceId);\n // Save the trace in the state so that we can tie subsequent invocation together.\n if (!traceContext) {\n ctx.state.traceContext = JSON.stringify(rootSpan.spanContext());\n }\n setCustomMetadataAttribute(\n metadataPrefix('dispatchType'),\n dispatchType\n );\n try {\n const input = this.inputSchema\n ? this.inputSchema.parse(ctx.state.input)\n : ctx.state.input;\n metadata.input = input;\n const output = await handler(input, streamingCallback);\n metadata.output = JSON.stringify(output);\n setCustomMetadataAttribute(metadataPrefix('state'), 'done');\n return output;\n } catch (e) {\n if (e instanceof InterruptError) {\n setCustomMetadataAttribute(\n metadataPrefix('state'),\n 'interrupted'\n );\n // Log interrupted\n } else {\n metadata.state = 'error';\n rootSpan.setStatus({\n code: SpanStatusCode.ERROR,\n message: getErrorMessage(e),\n });\n if (e instanceof Error) {\n rootSpan.recordException(e);\n }\n\n setCustomMetadataAttribute(metadataPrefix('state'), 'error');\n ctx.state.operation.done = true;\n ctx.state.operation.result = {\n error: getErrorMessage(e),\n stacktrace: getErrorStack(e),\n } as FlowError;\n }\n errored = true;\n }\n }\n );\n if (!errored) {\n // flow done, set response.\n ctx.state.operation.done = true;\n ctx.state.operation.result = { response: output };\n }\n });\n }\n\n private async durableExpressHandler(\n req: express.Request,\n res: express.Response\n ): Promise<void> {\n if (req.query.stream === 'true') {\n const respBody = {\n error: {\n status: 'INVALID_ARGUMENT',\n message: 'Output from durable flows cannot be streamed',\n },\n };\n res.status(400).send(respBody).end();\n return;\n }\n\n let data = req.body;\n // Task queue will wrap body in a \"data\" object, unwrap it.\n if (req.body.data) {\n data = req.body.data;\n }\n const envMsg = FlowInvokeEnvelopeMessageSchema.parse(data);\n try {\n const state = await this.runEnvelope(envMsg);\n res.status(200).send(state.operation).end();\n } catch (e) {\n // Pass errors as operations instead of a standard API error\n // (https://cloud.google.com/apis/design/errors#http_mapping)\n const respBody = {\n done: true,\n result: {\n error: getErrorMessage(e),\n stacktrace: getErrorStack(e),\n },\n };\n res\n .status(500)\n .send(respBody as Operation)\n .end();\n }\n }\n\n private async nonDurableExpressHandler(\n req: __RequestWithAuth,\n res: express.Response\n ): Promise<void> {\n const { stream } = req.query;\n const auth = req.auth;\n\n let input = req.body.data;\n\n try {\n await this.authPolicy?.(auth, input);\n } catch (e: any) {\n const respBody = {\n error: {\n status: 'PERMISSION_DENIED',\n message: e.message || 'Permission denied to resource',\n },\n };\n res.status(403).send(respBody).end();\n return;\n }\n\n if (stream === 'true') {\n res.writeHead(200, {\n 'Content-Type': 'text/plain',\n 'Transfer-Encoding': 'chunked',\n });\n try {\n const state = await this.runDirectly(input, {\n streamingCallback: (chunk) => {\n res.write(JSON.stringify(chunk) + streamDelimiter);\n },\n auth,\n });\n res.write(JSON.stringify(state.operation));\n res.end();\n } catch (e) {\n // Errors while streaming are also passed back as operations\n const respBody = {\n done: true,\n result: {\n error: getErrorMessage(e),\n stacktrace: getErrorStack(e),\n },\n };\n res.write(JSON.stringify(respBody as Operation));\n res.end();\n }\n } else {\n try {\n const state = await this.runDirectly(input, { auth });\n if (state.operation.result?.error) {\n throw new Error(state.operation.result?.error);\n }\n // Responses for non-streaming, non-durable flows are passed back\n // with the flow result stored in a field called \"result.\"\n res\n .status(200)\n .send({\n result: state.operation.result?.response,\n })\n .end();\n } catch (e) {\n // Errors for non-durable, non-streaming flows are passed back as\n // standard API errors.\n res\n .status(500)\n .send({\n error: {\n status: 'INTERNAL',\n message: getErrorMessage(e),\n details: getErrorStack(e),\n },\n })\n .end();\n }\n }\n }\n\n get expressHandler(): (\n req: __RequestWithAuth,\n res: express.Response\n ) => Promise<void> {\n return this.experimentalDurable\n ? this.durableExpressHandler.bind(this)\n : this.nonDurableExpressHandler.bind(this);\n }\n}\n\n/**\n * Runs the flow. If the flow does not get interrupted may return a completed (done=true) operation.\n */\nexport async function runFlow<\n I extends z.ZodTypeAny = z.ZodTypeAny,\n O extends z.ZodTypeAny = z.ZodTypeAny,\n S extends z.ZodTypeAny = z.ZodTypeAny,\n>(\n flow: Flow<I, O, S> | FlowWrapper<I, O, S>,\n payload?: z.infer<I>,\n opts?: { withLocalAuthContext?: unknown }\n): Promise<z.infer<O>> {\n if (!(flow instanceof Flow)) {\n flow = flow.flow;\n }\n\n const input = flow.inputSchema ? flow.inputSchema.parse(payload) : payload;\n await flow.authPolicy?.(opts?.withLocalAuthContext, payload);\n\n if (flow.middleware) {\n logger.warn(\n `Flow (${flow.name}) middleware won't run when invoked with runFlow.`\n );\n }\n\n const state = await flow.runEnvelope(\n {\n start: {\n input,\n },\n },\n undefined,\n opts?.withLocalAuthContext\n );\n if (!state.operation.done) {\n throw new FlowStillRunningError(\n `flow ${state.name} did not finish execution`\n );\n }\n if (state.operation.result?.error) {\n throw new FlowExecutionError(\n state.operation.name,\n state.operation.result?.error,\n state.operation.result?.stacktrace\n );\n }\n return state.operation.result?.response;\n}\n\ninterface StreamingResponse<\n O extends z.ZodTypeAny = z.ZodTypeAny,\n S extends z.ZodTypeAny = z.ZodTypeAny,\n> {\n stream(): AsyncGenerator<unknown, Operation, z.infer<S> | undefined>;\n output(): Promise<z.infer<O>>;\n}\n\n/**\n * Runs the flow and streams results. If the flow does not get interrupted may return a completed (done=true) operation.\n */\nexport function streamFlow<\n I extends z.ZodTypeAny = z.ZodTypeAny,\n O extends z.ZodTypeAny = z.ZodTypeAny,\n S extends z.ZodTypeAny = z.ZodTypeAny,\n>(\n flowOrFlowWrapper: Flow<I, O, S> | FlowWrapper<I, O, S>,\n payload?: z.infer<I>,\n opts?: { withLocalAuthContext?: unknown }\n): StreamingResponse<O, S> {\n const flow = !(flowOrFlowWrapper instanceof Flow)\n ? flowOrFlowWrapper.flow\n : flowOrFlowWrapper;\n\n let chunkStreamController: ReadableStreamController<z.infer<S>>;\n const chunkStream = new ReadableStream<z.infer<S>>({\n start(controller) {\n chunkStreamController = controller;\n },\n pull() {},\n cancel() {},\n });\n\n const authPromise =\n flow.authPolicy?.(opts?.withLocalAuthContext, payload) ?? Promise.resolve();\n\n const operationPromise = authPromise\n .then(() =>\n flow.runEnvelope(\n {\n start: {\n input: flow.inputSchema ? flow.inputSchema.parse(payload) : payload,\n },\n },\n (c) => {\n chunkStreamController.enqueue(c);\n },\n opts?.withLocalAuthContext\n )\n )\n .then((s) => s.operation)\n .finally(() => {\n chunkStreamController.close();\n });\n\n return {\n output() {\n return operationPromise.then((op) => {\n if (!op.done) {\n throw new FlowStillRunningError(\n `flow ${op.name} did not finish execution`\n );\n }\n if (op.result?.error) {\n throw new FlowExecutionError(\n op.name,\n op.result?.error,\n op.result?.stacktrace\n );\n }\n return op.result?.response;\n });\n },\n async *stream() {\n const reader = chunkStream.getReader();\n while (true) {\n const chunk = await reader.read();\n if (chunk.value) {\n yield chunk.value;\n }\n if (chunk.done) {\n break;\n }\n }\n return await operationPromise;\n },\n };\n}\n\nfunction createNewState(\n flowId: string,\n name: string,\n input: unknown\n): FlowState {\n return {\n flowId: flowId,\n name: name,\n startTime: Date.now(),\n input: input,\n cache: {},\n eventsTriggered: {},\n blockedOnStep: null,\n executions: [],\n operation: {\n name: flowId,\n done: false,\n },\n };\n}\n\nexport type StepsFunction<\n I extends z.ZodTypeAny = z.ZodTypeAny,\n O extends z.ZodTypeAny = z.ZodTypeAny,\n S extends z.ZodTypeAny = z.ZodTypeAny,\n> = (\n input: z.infer<I>,\n streamingCallback: StreamingCallback<z.infer<S>> | undefined\n) => Promise<z.infer<O>>;\n\nfunction wrapAsAction<\n I extends z.ZodTypeAny = z.ZodTypeAny,\n O extends z.ZodTypeAny = z.ZodTypeAny,\n S extends z.ZodTypeAny = z.ZodTypeAny,\n>(\n flow: Flow<I, O, S>\n): Action<typeof FlowActionInputSchema, typeof FlowStateSchema> {\n return defineAction(\n {\n actionType: 'flow',\n name: flow.name,\n inputSchema: FlowActionInputSchema,\n outputSchema: FlowStateSchema,\n metadata: {\n inputSchema: toJsonSchema({ schema: flow.inputSchema }),\n outputSchema: toJsonSchema({ schema: flow.outputSchema }),\n experimentalDurable: !!flow.experimentalDurable,\n requiresAuth: !!flow.authPolicy,\n },\n },\n async (envelope) => {\n // Only non-durable flows have an authPolicy, so envelope.start should always\n // be defined here.\n await flow.authPolicy?.(\n envelope.auth,\n envelope.start?.input as I | undefined\n );\n setCustomMetadataAttribute(metadataPrefix('wrapperAction'), 'true');\n return await flow.runEnvelope(\n envelope,\n getStreamingCallback(),\n envelope.auth\n );\n }\n );\n}\n\nexport function startFlowsServer(params?: {\n flows?: Flow<any, any, any>[];\n port?: number;\n cors?: CorsOptions;\n pathPrefix?: string;\n jsonParserOptions?: bodyParser.OptionsJson;\n}) {\n const port =\n params?.port || (process.env.PORT ? parseInt(process.env.PORT) : 0) || 3400;\n const pathPrefix = params?.pathPrefix ?? '';\n const app = express();\n app.use(bodyParser.json(params?.jsonParserOptions));\n app.use(cors(params?.cors));\n\n const flows = params?.flows || createdFlows();\n logger.info(`Starting flows server on port ${port}`);\n flows.forEach((f) => {\n const flowPath = `/${pathPrefix}${f.name}`;\n logger.info(` - ${flowPath}`);\n // Add middlware\n f.middleware?.forEach((m) => {\n app.post(flowPath, m);\n });\n app.post(flowPath, f.expressHandler);\n });\n\n app.listen(port, () => {\n console.log(`Flows server listening on port ${port}`);\n });\n}\n"],"mappings":";;;;;AAgBA;AAAA,EAIE;AAAA,EAIA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AAAA,OACK;AACP,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAC7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,YAAY,gBAAgB;AAC5B,SAAsB,WAAW,YAAY;AAC7C,OAAO,aAAa;AACpB,SAAS,mBAAmB;AAE5B,SAAS,eAAe;A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