@vertesia/workflow 0.77.0 → 0.78.0-dev-28b447d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +128 -120
- package/src/activities/advanced/createDocumentTypeFromInteractionRun.ts +8 -5
- package/src/activities/advanced/createOrUpdateDocumentFromInteractionRun.ts +6 -10
- package/src/activities/advanced/updateDocumentFromInteractionRun.ts +4 -1
- package/src/activities/chunkDocument.ts +4 -1
- package/src/activities/executeInteraction.ts +16 -9
- package/src/activities/generateDocumentProperties.ts +13 -7
- package/src/activities/generateOrAssignContentType.ts +17 -11
- package/src/activities/index-dsl.ts +1 -1
- package/src/activities/notifyWebhook.test.ts +117 -19
- package/src/activities/notifyWebhook.ts +17 -4
- package/src/activities/rateLimiter.ts +41 -0
- package/src/conversion/image.ts +6 -3
- package/src/dsl/dsl-workflow.ts +80 -0
- package/src/dsl/setup/ActivityContext.ts +45 -12
- package/src/dsl/workflow-exec-child.test.ts +4 -3
- package/src/dsl/workflow-fetch.test.ts +1 -1
- package/src/dsl/workflow-import.test.ts +1 -1
- package/src/dsl/workflow.test.ts +2 -1
- package/src/errors.ts +13 -0
- package/src/index.ts +1 -1
- package/src/iterative-generation/activities/extractToc.ts +26 -12
- package/src/iterative-generation/activities/finalizeOutput.ts +52 -29
- package/src/iterative-generation/activities/generatePart.ts +66 -24
- package/src/iterative-generation/activities/generateToc.ts +85 -66
- package/src/iterative-generation/utils.ts +2 -2
- package/src/utils/blobs.ts +3 -1
- package/src/utils/client.ts +22 -8
- package/lib/cjs/activities/advanced/createDocumentTypeFromInteractionRun.js +0 -32
- package/lib/cjs/activities/advanced/createDocumentTypeFromInteractionRun.js.map +0 -1
- package/lib/cjs/activities/advanced/createOrUpdateDocumentFromInteractionRun.js +0 -72
- package/lib/cjs/activities/advanced/createOrUpdateDocumentFromInteractionRun.js.map +0 -1
- package/lib/cjs/activities/advanced/updateDocumentFromInteractionRun.js +0 -18
- package/lib/cjs/activities/advanced/updateDocumentFromInteractionRun.js.map +0 -1
- package/lib/cjs/activities/chunkDocument.js +0 -84
- package/lib/cjs/activities/chunkDocument.js.map +0 -1
- package/lib/cjs/activities/createDocumentFromOther.js +0 -64
- package/lib/cjs/activities/createDocumentFromOther.js.map +0 -1
- package/lib/cjs/activities/executeInteraction.js +0 -186
- package/lib/cjs/activities/executeInteraction.js.map +0 -1
- package/lib/cjs/activities/extractDocumentText.js +0 -156
- package/lib/cjs/activities/extractDocumentText.js.map +0 -1
- package/lib/cjs/activities/generateDocumentProperties.js +0 -78
- package/lib/cjs/activities/generateDocumentProperties.js.map +0 -1
- package/lib/cjs/activities/generateEmbeddings.js +0 -358
- package/lib/cjs/activities/generateEmbeddings.js.map +0 -1
- package/lib/cjs/activities/generateOrAssignContentType.js +0 -123
- package/lib/cjs/activities/generateOrAssignContentType.js.map +0 -1
- package/lib/cjs/activities/getObjectFromStore.js +0 -20
- package/lib/cjs/activities/getObjectFromStore.js.map +0 -1
- package/lib/cjs/activities/handleError.js +0 -22
- package/lib/cjs/activities/handleError.js.map +0 -1
- package/lib/cjs/activities/identifyTextSections.js +0 -48
- package/lib/cjs/activities/identifyTextSections.js.map +0 -1
- package/lib/cjs/activities/index-dsl.js +0 -43
- package/lib/cjs/activities/index-dsl.js.map +0 -1
- package/lib/cjs/activities/index.js +0 -21
- package/lib/cjs/activities/index.js.map +0 -1
- package/lib/cjs/activities/media/processPdfWithTextract.js +0 -103
- package/lib/cjs/activities/media/processPdfWithTextract.js.map +0 -1
- package/lib/cjs/activities/media/transcribeMediaWithGladia.js +0 -51
- package/lib/cjs/activities/media/transcribeMediaWithGladia.js.map +0 -1
- package/lib/cjs/activities/notifyWebhook.js +0 -33
- package/lib/cjs/activities/notifyWebhook.js.map +0 -1
- package/lib/cjs/activities/renditions/generateImageRendition.js +0 -66
- package/lib/cjs/activities/renditions/generateImageRendition.js.map +0 -1
- package/lib/cjs/activities/renditions/generateVideoRendition.js +0 -200
- package/lib/cjs/activities/renditions/generateVideoRendition.js.map +0 -1
- package/lib/cjs/activities/setDocumentStatus.js +0 -15
- package/lib/cjs/activities/setDocumentStatus.js.map +0 -1
- package/lib/cjs/conversion/TextractProcessor.js +0 -417
- package/lib/cjs/conversion/TextractProcessor.js.map +0 -1
- package/lib/cjs/conversion/image.js +0 -147
- package/lib/cjs/conversion/image.js.map +0 -1
- package/lib/cjs/conversion/markitdown.js +0 -42
- package/lib/cjs/conversion/markitdown.js.map +0 -1
- package/lib/cjs/conversion/mutool.js +0 -147
- package/lib/cjs/conversion/mutool.js.map +0 -1
- package/lib/cjs/conversion/pandoc.js +0 -39
- package/lib/cjs/conversion/pandoc.js.map +0 -1
- package/lib/cjs/dsl/conditions.js +0 -81
- package/lib/cjs/dsl/conditions.js.map +0 -1
- package/lib/cjs/dsl/dsl-workflow.js +0 -277
- package/lib/cjs/dsl/dsl-workflow.js.map +0 -1
- package/lib/cjs/dsl/dslProxyActivities.js +0 -23
- package/lib/cjs/dsl/dslProxyActivities.js.map +0 -1
- package/lib/cjs/dsl/projections.js +0 -59
- package/lib/cjs/dsl/projections.js.map +0 -1
- package/lib/cjs/dsl/setup/ActivityContext.js +0 -120
- package/lib/cjs/dsl/setup/ActivityContext.js.map +0 -1
- package/lib/cjs/dsl/setup/fetch/DataProvider.js +0 -51
- package/lib/cjs/dsl/setup/fetch/DataProvider.js.map +0 -1
- package/lib/cjs/dsl/setup/fetch/index.js +0 -16
- package/lib/cjs/dsl/setup/fetch/index.js.map +0 -1
- package/lib/cjs/dsl/setup/fetch/providers.js +0 -67
- package/lib/cjs/dsl/setup/fetch/providers.js.map +0 -1
- package/lib/cjs/dsl/test/test-child-workflow.js +0 -10
- package/lib/cjs/dsl/test/test-child-workflow.js.map +0 -1
- package/lib/cjs/dsl/validation.js +0 -122
- package/lib/cjs/dsl/validation.js.map +0 -1
- package/lib/cjs/dsl/vars.js +0 -341
- package/lib/cjs/dsl/vars.js.map +0 -1
- package/lib/cjs/dsl/walk.js +0 -100
- package/lib/cjs/dsl/walk.js.map +0 -1
- package/lib/cjs/dsl.js +0 -20
- package/lib/cjs/dsl.js.map +0 -1
- package/lib/cjs/errors.js +0 -49
- package/lib/cjs/errors.js.map +0 -1
- package/lib/cjs/index.js +0 -54
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/iterative-generation/activities/extractToc.js +0 -47
- package/lib/cjs/iterative-generation/activities/extractToc.js.map +0 -1
- package/lib/cjs/iterative-generation/activities/finalizeOutput.js +0 -69
- package/lib/cjs/iterative-generation/activities/finalizeOutput.js.map +0 -1
- package/lib/cjs/iterative-generation/activities/generatePart.js +0 -73
- package/lib/cjs/iterative-generation/activities/generatePart.js.map +0 -1
- package/lib/cjs/iterative-generation/activities/generateToc.js +0 -91
- package/lib/cjs/iterative-generation/activities/generateToc.js.map +0 -1
- package/lib/cjs/iterative-generation/activities/index.js +0 -12
- package/lib/cjs/iterative-generation/activities/index.js.map +0 -1
- package/lib/cjs/iterative-generation/iterativeGenerationWorkflow.js +0 -56
- package/lib/cjs/iterative-generation/iterativeGenerationWorkflow.js.map +0 -1
- package/lib/cjs/iterative-generation/types.js +0 -5
- package/lib/cjs/iterative-generation/types.js.map +0 -1
- package/lib/cjs/iterative-generation/utils.js +0 -121
- package/lib/cjs/iterative-generation/utils.js.map +0 -1
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/result-types.js +0 -10
- package/lib/cjs/result-types.js.map +0 -1
- package/lib/cjs/system/notifyWebhookWorkflow.js +0 -46
- package/lib/cjs/system/notifyWebhookWorkflow.js.map +0 -1
- package/lib/cjs/system/recalculateEmbeddingsWorkflow.js +0 -33
- package/lib/cjs/system/recalculateEmbeddingsWorkflow.js.map +0 -1
- package/lib/cjs/utils/auth.js +0 -15
- package/lib/cjs/utils/auth.js.map +0 -1
- package/lib/cjs/utils/blobs.js +0 -61
- package/lib/cjs/utils/blobs.js.map +0 -1
- package/lib/cjs/utils/chunks.js +0 -14
- package/lib/cjs/utils/chunks.js.map +0 -1
- package/lib/cjs/utils/client.js +0 -29
- package/lib/cjs/utils/client.js.map +0 -1
- package/lib/cjs/utils/expand-vars.js +0 -33
- package/lib/cjs/utils/expand-vars.js.map +0 -1
- package/lib/cjs/utils/memory.js +0 -65
- package/lib/cjs/utils/memory.js.map +0 -1
- package/lib/cjs/utils/renditions.js +0 -88
- package/lib/cjs/utils/renditions.js.map +0 -1
- package/lib/cjs/utils/storage.js +0 -55
- package/lib/cjs/utils/storage.js.map +0 -1
- package/lib/cjs/utils/tokens.js +0 -38
- package/lib/cjs/utils/tokens.js.map +0 -1
- package/lib/cjs/vars.js +0 -20
- package/lib/cjs/vars.js.map +0 -1
- package/lib/cjs/workflows.js +0 -15
- package/lib/cjs/workflows.js.map +0 -1
- package/lib/esm/activities/advanced/createDocumentTypeFromInteractionRun.js +0 -29
- package/lib/esm/activities/advanced/createDocumentTypeFromInteractionRun.js.map +0 -1
- package/lib/esm/activities/advanced/createOrUpdateDocumentFromInteractionRun.js +0 -69
- package/lib/esm/activities/advanced/createOrUpdateDocumentFromInteractionRun.js.map +0 -1
- package/lib/esm/activities/advanced/updateDocumentFromInteractionRun.js +0 -15
- package/lib/esm/activities/advanced/updateDocumentFromInteractionRun.js.map +0 -1
- package/lib/esm/activities/chunkDocument.js +0 -81
- package/lib/esm/activities/chunkDocument.js.map +0 -1
- package/lib/esm/activities/createDocumentFromOther.js +0 -58
- package/lib/esm/activities/createDocumentFromOther.js.map +0 -1
- package/lib/esm/activities/executeInteraction.js +0 -182
- package/lib/esm/activities/executeInteraction.js.map +0 -1
- package/lib/esm/activities/extractDocumentText.js +0 -153
- package/lib/esm/activities/extractDocumentText.js.map +0 -1
- package/lib/esm/activities/generateDocumentProperties.js +0 -75
- package/lib/esm/activities/generateDocumentProperties.js.map +0 -1
- package/lib/esm/activities/generateEmbeddings.js +0 -355
- package/lib/esm/activities/generateEmbeddings.js.map +0 -1
- package/lib/esm/activities/generateOrAssignContentType.js +0 -120
- package/lib/esm/activities/generateOrAssignContentType.js.map +0 -1
- package/lib/esm/activities/getObjectFromStore.js +0 -17
- package/lib/esm/activities/getObjectFromStore.js.map +0 -1
- package/lib/esm/activities/handleError.js +0 -19
- package/lib/esm/activities/handleError.js.map +0 -1
- package/lib/esm/activities/identifyTextSections.js +0 -45
- package/lib/esm/activities/identifyTextSections.js.map +0 -1
- package/lib/esm/activities/index-dsl.js +0 -21
- package/lib/esm/activities/index-dsl.js.map +0 -1
- package/lib/esm/activities/index.js +0 -5
- package/lib/esm/activities/index.js.map +0 -1
- package/lib/esm/activities/media/processPdfWithTextract.js +0 -99
- package/lib/esm/activities/media/processPdfWithTextract.js.map +0 -1
- package/lib/esm/activities/media/transcribeMediaWithGladia.js +0 -48
- package/lib/esm/activities/media/transcribeMediaWithGladia.js.map +0 -1
- package/lib/esm/activities/notifyWebhook.js +0 -30
- package/lib/esm/activities/notifyWebhook.js.map +0 -1
- package/lib/esm/activities/renditions/generateImageRendition.js +0 -63
- package/lib/esm/activities/renditions/generateImageRendition.js.map +0 -1
- package/lib/esm/activities/renditions/generateVideoRendition.js +0 -194
- package/lib/esm/activities/renditions/generateVideoRendition.js.map +0 -1
- package/lib/esm/activities/setDocumentStatus.js +0 -12
- package/lib/esm/activities/setDocumentStatus.js.map +0 -1
- package/lib/esm/conversion/TextractProcessor.js +0 -410
- package/lib/esm/conversion/TextractProcessor.js.map +0 -1
- package/lib/esm/conversion/image.js +0 -141
- package/lib/esm/conversion/image.js.map +0 -1
- package/lib/esm/conversion/markitdown.js +0 -36
- package/lib/esm/conversion/markitdown.js.map +0 -1
- package/lib/esm/conversion/mutool.js +0 -139
- package/lib/esm/conversion/mutool.js.map +0 -1
- package/lib/esm/conversion/pandoc.js +0 -36
- package/lib/esm/conversion/pandoc.js.map +0 -1
- package/lib/esm/dsl/conditions.js +0 -75
- package/lib/esm/dsl/conditions.js.map +0 -1
- package/lib/esm/dsl/dsl-workflow.js +0 -270
- package/lib/esm/dsl/dsl-workflow.js.map +0 -1
- package/lib/esm/dsl/dslProxyActivities.js +0 -20
- package/lib/esm/dsl/dslProxyActivities.js.map +0 -1
- package/lib/esm/dsl/projections.js +0 -55
- package/lib/esm/dsl/projections.js.map +0 -1
- package/lib/esm/dsl/setup/ActivityContext.js +0 -115
- package/lib/esm/dsl/setup/ActivityContext.js.map +0 -1
- package/lib/esm/dsl/setup/fetch/DataProvider.js +0 -47
- package/lib/esm/dsl/setup/fetch/DataProvider.js.map +0 -1
- package/lib/esm/dsl/setup/fetch/index.js +0 -12
- package/lib/esm/dsl/setup/fetch/index.js.map +0 -1
- package/lib/esm/dsl/setup/fetch/providers.js +0 -61
- package/lib/esm/dsl/setup/fetch/providers.js.map +0 -1
- package/lib/esm/dsl/test/test-child-workflow.js +0 -5
- package/lib/esm/dsl/test/test-child-workflow.js.map +0 -1
- package/lib/esm/dsl/validation.js +0 -118
- package/lib/esm/dsl/validation.js.map +0 -1
- package/lib/esm/dsl/vars.js +0 -335
- package/lib/esm/dsl/vars.js.map +0 -1
- package/lib/esm/dsl/walk.js +0 -96
- package/lib/esm/dsl/walk.js.map +0 -1
- package/lib/esm/dsl.js +0 -4
- package/lib/esm/dsl.js.map +0 -1
- package/lib/esm/errors.js +0 -42
- package/lib/esm/errors.js.map +0 -1
- package/lib/esm/index.js +0 -36
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/iterative-generation/activities/extractToc.js +0 -44
- package/lib/esm/iterative-generation/activities/extractToc.js.map +0 -1
- package/lib/esm/iterative-generation/activities/finalizeOutput.js +0 -66
- package/lib/esm/iterative-generation/activities/finalizeOutput.js.map +0 -1
- package/lib/esm/iterative-generation/activities/generatePart.js +0 -70
- package/lib/esm/iterative-generation/activities/generatePart.js.map +0 -1
- package/lib/esm/iterative-generation/activities/generateToc.js +0 -88
- package/lib/esm/iterative-generation/activities/generateToc.js.map +0 -1
- package/lib/esm/iterative-generation/activities/index.js +0 -5
- package/lib/esm/iterative-generation/activities/index.js.map +0 -1
- package/lib/esm/iterative-generation/iterativeGenerationWorkflow.js +0 -53
- package/lib/esm/iterative-generation/iterativeGenerationWorkflow.js.map +0 -1
- package/lib/esm/iterative-generation/types.js +0 -2
- package/lib/esm/iterative-generation/types.js.map +0 -1
- package/lib/esm/iterative-generation/utils.js +0 -112
- package/lib/esm/iterative-generation/utils.js.map +0 -1
- package/lib/esm/result-types.js +0 -7
- package/lib/esm/result-types.js.map +0 -1
- package/lib/esm/system/notifyWebhookWorkflow.js +0 -43
- package/lib/esm/system/notifyWebhookWorkflow.js.map +0 -1
- package/lib/esm/system/recalculateEmbeddingsWorkflow.js +0 -30
- package/lib/esm/system/recalculateEmbeddingsWorkflow.js.map +0 -1
- package/lib/esm/utils/auth.js +0 -8
- package/lib/esm/utils/auth.js.map +0 -1
- package/lib/esm/utils/blobs.js +0 -51
- package/lib/esm/utils/blobs.js.map +0 -1
- package/lib/esm/utils/chunks.js +0 -9
- package/lib/esm/utils/chunks.js.map +0 -1
- package/lib/esm/utils/client.js +0 -25
- package/lib/esm/utils/client.js.map +0 -1
- package/lib/esm/utils/expand-vars.js +0 -30
- package/lib/esm/utils/expand-vars.js.map +0 -1
- package/lib/esm/utils/memory.js +0 -55
- package/lib/esm/utils/memory.js.map +0 -1
- package/lib/esm/utils/renditions.js +0 -80
- package/lib/esm/utils/renditions.js.map +0 -1
- package/lib/esm/utils/storage.js +0 -46
- package/lib/esm/utils/storage.js.map +0 -1
- package/lib/esm/utils/tokens.js +0 -34
- package/lib/esm/utils/tokens.js.map +0 -1
- package/lib/esm/vars.js +0 -4
- package/lib/esm/vars.js.map +0 -1
- package/lib/esm/workflows.js +0 -8
- package/lib/esm/workflows.js.map +0 -1
- package/lib/types/activities/advanced/createDocumentTypeFromInteractionRun.d.ts +0 -17
- package/lib/types/activities/advanced/createDocumentTypeFromInteractionRun.d.ts.map +0 -1
- package/lib/types/activities/advanced/createOrUpdateDocumentFromInteractionRun.d.ts +0 -39
- package/lib/types/activities/advanced/createOrUpdateDocumentFromInteractionRun.d.ts.map +0 -1
- package/lib/types/activities/advanced/updateDocumentFromInteractionRun.d.ts +0 -19
- package/lib/types/activities/advanced/updateDocumentFromInteractionRun.d.ts.map +0 -1
- package/lib/types/activities/chunkDocument.d.ts +0 -33
- package/lib/types/activities/chunkDocument.d.ts.map +0 -1
- package/lib/types/activities/createDocumentFromOther.d.ts +0 -21
- package/lib/types/activities/createDocumentFromOther.d.ts.map +0 -1
- package/lib/types/activities/executeInteraction.d.ts +0 -57
- package/lib/types/activities/executeInteraction.d.ts.map +0 -1
- package/lib/types/activities/extractDocumentText.d.ts +0 -10
- package/lib/types/activities/extractDocumentText.d.ts.map +0 -1
- package/lib/types/activities/generateDocumentProperties.d.ts +0 -32
- package/lib/types/activities/generateDocumentProperties.d.ts.map +0 -1
- package/lib/types/activities/generateEmbeddings.d.ts +0 -53
- package/lib/types/activities/generateEmbeddings.d.ts.map +0 -1
- package/lib/types/activities/generateOrAssignContentType.d.ts +0 -44
- package/lib/types/activities/generateOrAssignContentType.d.ts.map +0 -1
- package/lib/types/activities/getObjectFromStore.d.ts +0 -14
- package/lib/types/activities/getObjectFromStore.d.ts.map +0 -1
- package/lib/types/activities/handleError.d.ts +0 -6
- package/lib/types/activities/handleError.d.ts.map +0 -1
- package/lib/types/activities/identifyTextSections.d.ts +0 -12
- package/lib/types/activities/identifyTextSections.d.ts.map +0 -1
- package/lib/types/activities/index-dsl.d.ts +0 -20
- package/lib/types/activities/index-dsl.d.ts.map +0 -1
- package/lib/types/activities/index.d.ts +0 -5
- package/lib/types/activities/index.d.ts.map +0 -1
- package/lib/types/activities/media/processPdfWithTextract.d.ts +0 -26
- package/lib/types/activities/media/processPdfWithTextract.d.ts.map +0 -1
- package/lib/types/activities/media/transcribeMediaWithGladia.d.ts +0 -14
- package/lib/types/activities/media/transcribeMediaWithGladia.d.ts.map +0 -1
- package/lib/types/activities/notifyWebhook.d.ts +0 -16
- package/lib/types/activities/notifyWebhook.d.ts.map +0 -1
- package/lib/types/activities/renditions/generateImageRendition.d.ts +0 -14
- package/lib/types/activities/renditions/generateImageRendition.d.ts.map +0 -1
- package/lib/types/activities/renditions/generateVideoRendition.d.ts +0 -15
- package/lib/types/activities/renditions/generateVideoRendition.d.ts.map +0 -1
- package/lib/types/activities/setDocumentStatus.d.ts +0 -15
- package/lib/types/activities/setDocumentStatus.d.ts.map +0 -1
- package/lib/types/conversion/TextractProcessor.d.ts +0 -45
- package/lib/types/conversion/TextractProcessor.d.ts.map +0 -1
- package/lib/types/conversion/image.d.ts +0 -13
- package/lib/types/conversion/image.d.ts.map +0 -1
- package/lib/types/conversion/markitdown.d.ts +0 -2
- package/lib/types/conversion/markitdown.d.ts.map +0 -1
- package/lib/types/conversion/mutool.d.ts +0 -19
- package/lib/types/conversion/mutool.d.ts.map +0 -1
- package/lib/types/conversion/pandoc.d.ts +0 -2
- package/lib/types/conversion/pandoc.d.ts.map +0 -1
- package/lib/types/dsl/conditions.d.ts +0 -2
- package/lib/types/dsl/conditions.d.ts.map +0 -1
- package/lib/types/dsl/dsl-workflow.d.ts +0 -5
- package/lib/types/dsl/dsl-workflow.d.ts.map +0 -1
- package/lib/types/dsl/dslProxyActivities.d.ts +0 -10
- package/lib/types/dsl/dslProxyActivities.d.ts.map +0 -1
- package/lib/types/dsl/projections.d.ts +0 -4
- package/lib/types/dsl/projections.d.ts.map +0 -1
- package/lib/types/dsl/setup/ActivityContext.d.ts +0 -17
- package/lib/types/dsl/setup/ActivityContext.d.ts.map +0 -1
- package/lib/types/dsl/setup/fetch/DataProvider.d.ts +0 -9
- package/lib/types/dsl/setup/fetch/DataProvider.d.ts.map +0 -1
- package/lib/types/dsl/setup/fetch/index.d.ts +0 -6
- package/lib/types/dsl/setup/fetch/index.d.ts.map +0 -1
- package/lib/types/dsl/setup/fetch/providers.d.ts +0 -25
- package/lib/types/dsl/setup/fetch/providers.d.ts.map +0 -1
- package/lib/types/dsl/test/test-child-workflow.d.ts +0 -4
- package/lib/types/dsl/test/test-child-workflow.d.ts.map +0 -1
- package/lib/types/dsl/validation.d.ts +0 -4
- package/lib/types/dsl/validation.d.ts.map +0 -1
- package/lib/types/dsl/vars.d.ts +0 -48
- package/lib/types/dsl/vars.d.ts.map +0 -1
- package/lib/types/dsl/walk.d.ts +0 -18
- package/lib/types/dsl/walk.d.ts.map +0 -1
- package/lib/types/dsl.d.ts +0 -4
- package/lib/types/dsl.d.ts.map +0 -1
- package/lib/types/errors.d.ts +0 -23
- package/lib/types/errors.d.ts.map +0 -1
- package/lib/types/index.d.ts +0 -35
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/iterative-generation/activities/extractToc.d.ts +0 -10
- package/lib/types/iterative-generation/activities/extractToc.d.ts.map +0 -1
- package/lib/types/iterative-generation/activities/finalizeOutput.d.ts +0 -3
- package/lib/types/iterative-generation/activities/finalizeOutput.d.ts.map +0 -1
- package/lib/types/iterative-generation/activities/generatePart.d.ts +0 -3
- package/lib/types/iterative-generation/activities/generatePart.d.ts.map +0 -1
- package/lib/types/iterative-generation/activities/generateToc.d.ts +0 -4
- package/lib/types/iterative-generation/activities/generateToc.d.ts.map +0 -1
- package/lib/types/iterative-generation/activities/index.d.ts +0 -5
- package/lib/types/iterative-generation/activities/index.d.ts.map +0 -1
- package/lib/types/iterative-generation/iterativeGenerationWorkflow.d.ts +0 -3
- package/lib/types/iterative-generation/iterativeGenerationWorkflow.d.ts.map +0 -1
- package/lib/types/iterative-generation/types.d.ts +0 -79
- package/lib/types/iterative-generation/types.d.ts.map +0 -1
- package/lib/types/iterative-generation/utils.d.ts +0 -27
- package/lib/types/iterative-generation/utils.d.ts.map +0 -1
- package/lib/types/result-types.d.ts +0 -22
- package/lib/types/result-types.d.ts.map +0 -1
- package/lib/types/system/notifyWebhookWorkflow.d.ts +0 -7
- package/lib/types/system/notifyWebhookWorkflow.d.ts.map +0 -1
- package/lib/types/system/recalculateEmbeddingsWorkflow.d.ts +0 -25
- package/lib/types/system/recalculateEmbeddingsWorkflow.d.ts.map +0 -1
- package/lib/types/utils/auth.d.ts +0 -4
- package/lib/types/utils/auth.d.ts.map +0 -1
- package/lib/types/utils/blobs.d.ts +0 -7
- package/lib/types/utils/blobs.d.ts.map +0 -1
- package/lib/types/utils/chunks.d.ts +0 -9
- package/lib/types/utils/chunks.d.ts.map +0 -1
- package/lib/types/utils/client.d.ts +0 -12
- package/lib/types/utils/client.d.ts.map +0 -1
- package/lib/types/utils/expand-vars.d.ts +0 -8
- package/lib/types/utils/expand-vars.d.ts.map +0 -1
- package/lib/types/utils/memory.d.ts +0 -8
- package/lib/types/utils/memory.d.ts.map +0 -1
- package/lib/types/utils/renditions.d.ts +0 -23
- package/lib/types/utils/renditions.d.ts.map +0 -1
- package/lib/types/utils/storage.d.ts +0 -16
- package/lib/types/utils/storage.d.ts.map +0 -1
- package/lib/types/utils/tokens.d.ts +0 -11
- package/lib/types/utils/tokens.d.ts.map +0 -1
- package/lib/types/vars.d.ts +0 -3
- package/lib/types/vars.d.ts.map +0 -1
- package/lib/types/workflows.d.ts +0 -8
- package/lib/types/workflows.d.ts.map +0 -1
- package/lib/workflows-bundle.js +0 -12908
- package/src/activities/identifyTextSections.ts +0 -71
|
@@ -2,14 +2,24 @@ import { log } from "@temporalio/activity";
|
|
|
2
2
|
import { WorkflowExecutionPayload } from "@vertesia/common";
|
|
3
3
|
import { getVertesiaClient } from "../../utils/client.js";
|
|
4
4
|
import { expandVars } from "../../utils/expand-vars.js";
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
buildAndPublishMemoryPack,
|
|
7
|
+
loadMemoryPack,
|
|
8
|
+
} from "../../utils/memory.js";
|
|
9
|
+
import {
|
|
10
|
+
IterativeGenerationPayload,
|
|
11
|
+
Section,
|
|
12
|
+
SECTION_ID_PLACEHOLDER,
|
|
13
|
+
TocSection,
|
|
14
|
+
} from "../types.js";
|
|
7
15
|
|
|
8
|
-
export async function it_gen_finalizeOutput(
|
|
16
|
+
export async function it_gen_finalizeOutput(
|
|
17
|
+
payload: WorkflowExecutionPayload,
|
|
18
|
+
): Promise<string> {
|
|
9
19
|
const vars = payload.vars as IterativeGenerationPayload;
|
|
10
20
|
|
|
11
21
|
const memory = vars.memory;
|
|
12
|
-
const client = getVertesiaClient(payload);
|
|
22
|
+
const client = await getVertesiaClient(payload);
|
|
13
23
|
const inMemory = await loadMemoryPack(client, `${memory}/input`);
|
|
14
24
|
const outMemory = await loadMemoryPack(client, `${memory}/output`);
|
|
15
25
|
|
|
@@ -35,43 +45,56 @@ export async function it_gen_finalizeOutput(payload: WorkflowExecutionPayload):
|
|
|
35
45
|
}
|
|
36
46
|
const sections = JSON.parse(content) as Section[];
|
|
37
47
|
|
|
38
|
-
await buildAndPublishMemoryPack(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
await buildAndPublishMemoryPack(
|
|
49
|
+
client,
|
|
50
|
+
`${memory}/output`,
|
|
51
|
+
async ({ copyText }) => {
|
|
52
|
+
// copy the input toc file if any
|
|
53
|
+
if (toc) {
|
|
54
|
+
copyText(toc, tocName);
|
|
55
|
+
}
|
|
56
|
+
// copy the raw JSON content
|
|
57
|
+
copyText(content, "content.json");
|
|
58
|
+
if (vars.section_file_pattern) {
|
|
59
|
+
log.info(
|
|
60
|
+
`Saving sections to files using pattern: ${vars.section_file_pattern}`,
|
|
61
|
+
);
|
|
62
|
+
// save sections to files
|
|
63
|
+
for (const section of sections) {
|
|
64
|
+
let content = section.content;
|
|
65
|
+
if (vars.section_file_header) {
|
|
66
|
+
content =
|
|
67
|
+
getSectionFileHeader(
|
|
68
|
+
section,
|
|
69
|
+
vars.section_file_header,
|
|
70
|
+
) +
|
|
71
|
+
"\n\n" +
|
|
72
|
+
content;
|
|
73
|
+
}
|
|
74
|
+
copyText(
|
|
75
|
+
content,
|
|
76
|
+
getSectionFileName(section, vars.section_file_pattern),
|
|
77
|
+
);
|
|
52
78
|
}
|
|
53
|
-
copyText(content, getSectionFileName(section, vars.section_file_pattern));
|
|
54
79
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
80
|
+
return {
|
|
81
|
+
...inMeta,
|
|
82
|
+
vars,
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
);
|
|
61
86
|
|
|
62
87
|
return `Processing done. Extracted files to: ${vars.section_file_pattern}`;
|
|
63
88
|
}
|
|
64
89
|
|
|
65
|
-
|
|
66
|
-
|
|
67
90
|
function getSectionFileHeader(section: TocSection, header: string): string {
|
|
68
91
|
const date = new Date().toISOString();
|
|
69
92
|
return expandVars(header, {
|
|
70
93
|
section,
|
|
71
|
-
date
|
|
94
|
+
date,
|
|
72
95
|
});
|
|
73
96
|
}
|
|
74
97
|
|
|
75
98
|
function getSectionFileName(section: TocSection, pattern: string): string {
|
|
76
99
|
return pattern.replace(SECTION_ID_PLACEHOLDER, section.id);
|
|
77
|
-
}
|
|
100
|
+
}
|
|
@@ -2,29 +2,50 @@ import { ApplicationFailure } from "@temporalio/workflow";
|
|
|
2
2
|
import { WorkflowExecutionPayload } from "@vertesia/common";
|
|
3
3
|
import { MemoryPack } from "@vertesia/memory";
|
|
4
4
|
import { getVertesiaClient } from "../../utils/client.js";
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
buildAndPublishMemoryPack,
|
|
7
|
+
loadMemoryPack,
|
|
8
|
+
} from "../../utils/memory.js";
|
|
9
|
+
import {
|
|
10
|
+
IterativeGenerationPayload,
|
|
11
|
+
OutputMemoryMeta,
|
|
12
|
+
Section,
|
|
13
|
+
TocPart,
|
|
14
|
+
TocSection,
|
|
15
|
+
} from "../types.js";
|
|
7
16
|
import { executeWithVars, expectMemoryIsConsistent } from "../utils.js";
|
|
17
|
+
import { completionResultToString } from "@llumiverse/common";
|
|
8
18
|
|
|
9
|
-
export async function it_gen_generatePart(
|
|
19
|
+
export async function it_gen_generatePart(
|
|
20
|
+
payload: WorkflowExecutionPayload,
|
|
21
|
+
path: number[],
|
|
22
|
+
) {
|
|
10
23
|
const vars = payload.vars as IterativeGenerationPayload;
|
|
11
|
-
const client = getVertesiaClient(payload);
|
|
24
|
+
const client = await getVertesiaClient(payload);
|
|
12
25
|
const memory = vars.memory;
|
|
13
26
|
|
|
14
27
|
const [sectionIndex, partIndex] = path;
|
|
15
28
|
const outMemory = await loadMemoryPack(client, `${memory}/output`);
|
|
16
|
-
const meta = await outMemory.getMetadata() as OutputMemoryMeta;
|
|
29
|
+
const meta = (await outMemory.getMetadata()) as OutputMemoryMeta;
|
|
17
30
|
|
|
18
31
|
// the section we build is the section at the given index
|
|
19
32
|
const section: TocSection = meta.toc.sections[sectionIndex];
|
|
20
33
|
if (!section) {
|
|
21
|
-
throw ApplicationFailure.nonRetryable(
|
|
34
|
+
throw ApplicationFailure.nonRetryable(
|
|
35
|
+
"Section not found in the TOC",
|
|
36
|
+
"SectionNotFound",
|
|
37
|
+
{ memory, path },
|
|
38
|
+
);
|
|
22
39
|
}
|
|
23
40
|
let part: TocPart | undefined;
|
|
24
41
|
if (partIndex !== undefined) {
|
|
25
42
|
part = section.parts?.[partIndex];
|
|
26
43
|
if (!part) {
|
|
27
|
-
throw ApplicationFailure.nonRetryable(
|
|
44
|
+
throw ApplicationFailure.nonRetryable(
|
|
45
|
+
"Part not found in the TOC section",
|
|
46
|
+
"PartNotFound",
|
|
47
|
+
{ memory, path },
|
|
48
|
+
);
|
|
28
49
|
}
|
|
29
50
|
}
|
|
30
51
|
|
|
@@ -32,17 +53,26 @@ export async function it_gen_generatePart(payload: WorkflowExecutionPayload, pat
|
|
|
32
53
|
|
|
33
54
|
const content = await loadGeneratedContent(outMemory);
|
|
34
55
|
|
|
35
|
-
let previously_generated = getPreviouslyGeneratedContent(
|
|
56
|
+
let previously_generated = getPreviouslyGeneratedContent(
|
|
57
|
+
content,
|
|
58
|
+
!part,
|
|
59
|
+
vars.remembrance_strategy,
|
|
60
|
+
);
|
|
36
61
|
|
|
37
|
-
if (!part) {
|
|
62
|
+
if (!part) {
|
|
63
|
+
// a new section
|
|
38
64
|
content.push({
|
|
39
65
|
id: section.id,
|
|
40
66
|
name: section.name,
|
|
41
67
|
description: section.description,
|
|
42
|
-
content:
|
|
43
|
-
})
|
|
68
|
+
content: "",
|
|
69
|
+
});
|
|
44
70
|
} else if (!content.length) {
|
|
45
|
-
throw ApplicationFailure.nonRetryable(
|
|
71
|
+
throw ApplicationFailure.nonRetryable(
|
|
72
|
+
"content.json is empty while generating a part",
|
|
73
|
+
"InvalidIterationState",
|
|
74
|
+
{ memory, path },
|
|
75
|
+
);
|
|
46
76
|
}
|
|
47
77
|
|
|
48
78
|
const interaction = vars.iterative_interaction || vars.interaction;
|
|
@@ -53,30 +83,42 @@ export async function it_gen_generatePart(payload: WorkflowExecutionPayload, pat
|
|
|
53
83
|
section: section.name,
|
|
54
84
|
part: part?.name,
|
|
55
85
|
path: path,
|
|
56
|
-
}
|
|
86
|
+
},
|
|
57
87
|
});
|
|
58
88
|
|
|
59
|
-
const result = r.result
|
|
89
|
+
const result = r.result.map(completionResultToString).join('\n');
|
|
60
90
|
content[content.length - 1].content += result;
|
|
61
91
|
meta.lastProcessedPart = path;
|
|
62
|
-
await buildAndPublishMemoryPack(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
92
|
+
await buildAndPublishMemoryPack(
|
|
93
|
+
client,
|
|
94
|
+
`${memory}/output`,
|
|
95
|
+
async ({ copyText }) => {
|
|
96
|
+
copyText(JSON.stringify(content, null, 2), "content.json");
|
|
97
|
+
return meta;
|
|
98
|
+
},
|
|
99
|
+
);
|
|
66
100
|
}
|
|
67
101
|
|
|
68
102
|
async function loadGeneratedContent(memory: MemoryPack): Promise<Section[]> {
|
|
69
|
-
const content = await memory.getEntryText(
|
|
103
|
+
const content = await memory.getEntryText("content.json");
|
|
70
104
|
return content ? JSON.parse(content) : [];
|
|
71
105
|
}
|
|
72
106
|
|
|
73
|
-
function getPreviouslyGeneratedContent(
|
|
107
|
+
function getPreviouslyGeneratedContent(
|
|
108
|
+
sections: Section[],
|
|
109
|
+
isNewSection: boolean,
|
|
110
|
+
strategy?: "document" | "section" | "none",
|
|
111
|
+
): string {
|
|
74
112
|
switch (strategy) {
|
|
75
113
|
case "document":
|
|
76
|
-
return sections
|
|
114
|
+
return sections
|
|
115
|
+
.map((section: Section) => section.content || "")
|
|
116
|
+
.join("\n\n");
|
|
77
117
|
case "none":
|
|
78
|
-
return
|
|
118
|
+
return "";
|
|
79
119
|
default:
|
|
80
|
-
return isNewSection
|
|
120
|
+
return isNewSection
|
|
121
|
+
? ""
|
|
122
|
+
: sections[sections.length - 1]?.content || "";
|
|
81
123
|
}
|
|
82
|
-
}
|
|
124
|
+
}
|
|
@@ -1,98 +1,117 @@
|
|
|
1
1
|
import { WorkflowExecutionPayload } from "@vertesia/common";
|
|
2
2
|
import { getVertesiaClient } from "../../utils/client.js";
|
|
3
3
|
import { buildAndPublishMemoryPack } from "../../utils/memory.js";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
IterativeGenerationPayload,
|
|
6
|
+
OutputMemoryMeta,
|
|
7
|
+
Toc,
|
|
8
|
+
TocIndex,
|
|
9
|
+
} from "../types.js";
|
|
5
10
|
import { executeWithVars, tocIndex } from "../utils.js";
|
|
11
|
+
import { parseCompletionResultsToJson } from "@llumiverse/common";
|
|
6
12
|
|
|
7
13
|
const defaultTocSchema = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
type: "object",
|
|
15
|
+
properties: {
|
|
16
|
+
sections: {
|
|
17
|
+
type: "array",
|
|
18
|
+
items: {
|
|
19
|
+
type: "object",
|
|
20
|
+
properties: {
|
|
21
|
+
id: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description:
|
|
24
|
+
"the id of the section, can be a filename if working on a file, a slug if working on a document or path, or a unique identifier if working on a model.",
|
|
18
25
|
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
operation: {
|
|
27
|
+
type: "string",
|
|
28
|
+
enum: ["create", "update", "delete"],
|
|
29
|
+
description:
|
|
30
|
+
"The operation to perform on the section, create, update or delete. If update, you will be requested later to provide the list of change operation to perform.",
|
|
23
31
|
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
name: {
|
|
33
|
+
type: "string",
|
|
34
|
+
description:
|
|
35
|
+
"The name or title of the section, should be the path in the OpenAPI spec, of the title of the section/part.",
|
|
27
36
|
},
|
|
28
|
-
|
|
29
|
-
|
|
37
|
+
description: {
|
|
38
|
+
type: "string",
|
|
30
39
|
},
|
|
31
|
-
|
|
32
|
-
|
|
40
|
+
instructions: {
|
|
41
|
+
type: "string",
|
|
33
42
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
parts: {
|
|
44
|
+
type: "array",
|
|
45
|
+
description:
|
|
46
|
+
"when the section is too large, you can split it into parts, each part should have a title and description. Use it to split the section into subsection. When doing an API documentation, you can do one part for each path. When generating code, you can do one part for each method. When generating an OpenAPI spec, you can do one part for each operation.",
|
|
47
|
+
items: {
|
|
48
|
+
type: "object",
|
|
49
|
+
properties: {
|
|
50
|
+
id: {
|
|
51
|
+
type: "string",
|
|
52
|
+
description:
|
|
53
|
+
"the id of the part, can be a filename if working on a file, a slug if working on a document or path, or a unique identifier if working on a model.",
|
|
44
54
|
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
55
|
+
name: {
|
|
56
|
+
type: "string",
|
|
57
|
+
description:
|
|
58
|
+
"The name or title of the part, should be the path in the OpenAPI spec, of the title of the section/part.",
|
|
48
59
|
},
|
|
49
60
|
/*
|
|
50
61
|
"description": {
|
|
51
62
|
"type": "string"
|
|
52
63
|
},
|
|
53
64
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
65
|
+
instructions: {
|
|
66
|
+
type: "string",
|
|
67
|
+
},
|
|
57
68
|
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
]
|
|
62
|
-
}
|
|
63
|
-
}
|
|
69
|
+
required: ["id", "name"],
|
|
70
|
+
},
|
|
71
|
+
},
|
|
64
72
|
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
"operation"
|
|
69
|
-
]
|
|
70
|
-
}
|
|
71
|
-
}
|
|
73
|
+
required: ["id", "name", "operation"],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
72
76
|
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
]
|
|
76
|
-
}
|
|
77
|
+
required: ["sections"],
|
|
78
|
+
};
|
|
77
79
|
|
|
78
|
-
export async function it_gen_generateToc(
|
|
80
|
+
export async function it_gen_generateToc(
|
|
81
|
+
payload: WorkflowExecutionPayload,
|
|
82
|
+
): Promise<TocIndex> {
|
|
79
83
|
const vars = payload.vars as IterativeGenerationPayload;
|
|
80
84
|
|
|
81
85
|
const schema = vars.toc_schema || defaultTocSchema;
|
|
82
86
|
|
|
83
|
-
const client = getVertesiaClient(payload);
|
|
87
|
+
const client = await getVertesiaClient(payload);
|
|
88
|
+
|
|
89
|
+
const run = await executeWithVars(
|
|
90
|
+
client,
|
|
91
|
+
vars.interaction,
|
|
92
|
+
vars,
|
|
93
|
+
undefined,
|
|
94
|
+
schema,
|
|
95
|
+
);
|
|
84
96
|
|
|
85
|
-
|
|
97
|
+
//Parse the CompletionResult[] to get a Toc object
|
|
98
|
+
const jsonResults = parseCompletionResultsToJson(run.result);
|
|
86
99
|
|
|
87
|
-
const toc =
|
|
100
|
+
const toc: Toc = {
|
|
101
|
+
sections: jsonResults.sections
|
|
102
|
+
};
|
|
88
103
|
|
|
89
|
-
await buildAndPublishMemoryPack(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
104
|
+
await buildAndPublishMemoryPack(
|
|
105
|
+
client,
|
|
106
|
+
`${vars.memory}/output`,
|
|
107
|
+
async () => {
|
|
108
|
+
return {
|
|
109
|
+
toc,
|
|
110
|
+
lastProcessedPart: undefined, // the part index (a number array)
|
|
111
|
+
previouslyGenerated: "",
|
|
112
|
+
} satisfies OutputMemoryMeta;
|
|
113
|
+
},
|
|
114
|
+
);
|
|
96
115
|
|
|
97
116
|
return tocIndex(toc);
|
|
98
117
|
}
|
|
@@ -15,7 +15,7 @@ export interface ExecuteOptions {
|
|
|
15
15
|
result_schema?: Record<string, any>;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export async function execute
|
|
18
|
+
export async function execute(client: VertesiaClient, options: ExecuteOptions): Promise<ExecutionRun> {
|
|
19
19
|
return client.interactions.executeByName(options.interaction, {
|
|
20
20
|
data: {
|
|
21
21
|
...options.memory_mapping,
|
|
@@ -30,7 +30,7 @@ export async function execute<T = any>(client: VertesiaClient, options: ExecuteO
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export function executeWithVars
|
|
33
|
+
export function executeWithVars(client: VertesiaClient, interaction: string, vars: Record<string, any>, mapping?: Record<string, any>, result_schema?: Record<string, any>): Promise<ExecutionRun> {
|
|
34
34
|
if (mapping) {
|
|
35
35
|
mapping = { ...vars.input_mapping, ...mapping };
|
|
36
36
|
} else {
|
package/src/utils/blobs.ts
CHANGED
|
@@ -14,7 +14,9 @@ export async function fetchBlobAsStream(client: VertesiaClient, blobUri: string)
|
|
|
14
14
|
} catch (err: any) {
|
|
15
15
|
if (err.message.includes("not found")) {
|
|
16
16
|
//TODO improve error handling with a fetch fail error class in the client
|
|
17
|
-
throw new DocumentNotFoundError(`
|
|
17
|
+
throw new DocumentNotFoundError(`Not found at ${blobUri}: ${err.message}`, []);
|
|
18
|
+
} else if (err.message.includes("forbidden")) {
|
|
19
|
+
throw new DocumentNotFoundError(`Forbidden at ${blobUri}: ${err.message}`);
|
|
18
20
|
} else {
|
|
19
21
|
throw new Error(`Failed to download blob ${blobUri}: ${err.message}`);
|
|
20
22
|
}
|
package/src/utils/client.ts
CHANGED
|
@@ -2,31 +2,45 @@
|
|
|
2
2
|
* get a zeno client for a given token
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
decodeJWT,
|
|
7
|
+
VertesiaClient,
|
|
8
|
+
VertesiaClientProps,
|
|
9
|
+
} from "@vertesia/client";
|
|
6
10
|
import { WorkflowExecutionBaseParams } from "@vertesia/common";
|
|
7
11
|
import { WorkflowParamNotFoundError } from "../errors.js";
|
|
8
12
|
|
|
9
|
-
|
|
10
13
|
export function getVertesiaClient(payload: WorkflowExecutionBaseParams) {
|
|
11
14
|
return new VertesiaClient(getVertesiaClientOptions(payload));
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
export function getVertesiaClientOptions(
|
|
17
|
+
export function getVertesiaClientOptions(
|
|
18
|
+
payload: WorkflowExecutionBaseParams,
|
|
19
|
+
): VertesiaClientProps {
|
|
15
20
|
if (!payload.auth_token) {
|
|
16
|
-
throw new WorkflowParamNotFoundError(
|
|
21
|
+
throw new WorkflowParamNotFoundError(
|
|
22
|
+
"Authentication Token is missing from WorkflowExecutionPayload.authToken",
|
|
23
|
+
);
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
if (!payload.config?.studio_url) {
|
|
20
|
-
throw new WorkflowParamNotFoundError(
|
|
27
|
+
throw new WorkflowParamNotFoundError(
|
|
28
|
+
"Content Store URL is missing from WorkflowExecutionPayload.servers.storeUrl",
|
|
29
|
+
);
|
|
21
30
|
}
|
|
22
31
|
|
|
23
32
|
if (!payload.config?.store_url) {
|
|
24
|
-
throw new WorkflowParamNotFoundError(
|
|
33
|
+
throw new WorkflowParamNotFoundError(
|
|
34
|
+
"Content Store URL is missing from WorkflowExecutionPayload.servers.storeUrl",
|
|
35
|
+
);
|
|
25
36
|
}
|
|
26
37
|
|
|
38
|
+
const token = decodeJWT(payload.auth_token);
|
|
39
|
+
|
|
27
40
|
return {
|
|
28
41
|
serverUrl: payload.config.studio_url,
|
|
29
42
|
storeUrl: payload.config.store_url,
|
|
30
|
-
|
|
43
|
+
tokenServerUrl: token.iss,
|
|
44
|
+
apikey: payload.auth_token,
|
|
31
45
|
};
|
|
32
|
-
}
|
|
46
|
+
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createDocumentTypeFromInteractionRun = createDocumentTypeFromInteractionRun;
|
|
4
|
-
const activity_1 = require("@temporalio/activity");
|
|
5
|
-
const projections_js_1 = require("../../dsl/projections.js");
|
|
6
|
-
const ActivityContext_js_1 = require("../../dsl/setup/ActivityContext.js");
|
|
7
|
-
const errors_js_1 = require("../../errors.js");
|
|
8
|
-
async function createDocumentTypeFromInteractionRun(payload) {
|
|
9
|
-
const { params, client } = await (0, ActivityContext_js_1.setupActivity)(payload);
|
|
10
|
-
if (!params.run) {
|
|
11
|
-
throw new errors_js_1.ActivityParamNotFoundError("run", payload.activity);
|
|
12
|
-
}
|
|
13
|
-
const genTypeRes = params.run.result;
|
|
14
|
-
if (!genTypeRes.document_type) {
|
|
15
|
-
activity_1.log.error("No name generated for type: " + JSON.stringify(genTypeRes), genTypeRes);
|
|
16
|
-
throw new Error("No name generated for type");
|
|
17
|
-
}
|
|
18
|
-
activity_1.log.info("Generated schema for type", genTypeRes.metadata_schema);
|
|
19
|
-
const typeData = {
|
|
20
|
-
name: genTypeRes.document_type,
|
|
21
|
-
object_schema: genTypeRes.metadata_schema,
|
|
22
|
-
is_chunkable: !!genTypeRes.is_chunkable,
|
|
23
|
-
};
|
|
24
|
-
const type = await client.types.create(typeData);
|
|
25
|
-
if (params.updateObjectId) {
|
|
26
|
-
await client.objects.update(params.updateObjectId, {
|
|
27
|
-
type: type.id,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
return (0, projections_js_1.projectResult)(payload, params, type, { id: type.id, name: type.name });
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=createDocumentTypeFromInteractionRun.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createDocumentTypeFromInteractionRun.js","sourceRoot":"","sources":["../../../../src/activities/advanced/createDocumentTypeFromInteractionRun.ts"],"names":[],"mappings":";;AAuBA,oFA8BC;AApDD,mDAA2C;AAC3C,6DAAyD;AACzD,2EAAmE;AACnE,+CAA6D;AAmBtD,KAAK,UAAU,oCAAoC,CAAC,OAAgF;IACvI,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,kCAAa,EAA6C,OAAO,CAAC,CAAC;IAEpG,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QACd,MAAM,IAAI,sCAA0B,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;IAErC,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;QAC5B,cAAG,CAAC,KAAK,CAAC,8BAA8B,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC,CAAC;QACnF,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAClD,CAAC;IAED,cAAG,CAAC,IAAI,CAAC,2BAA2B,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC;IAClE,MAAM,QAAQ,GAAmC;QAC7C,IAAI,EAAE,UAAU,CAAC,aAAa;QAC9B,aAAa,EAAE,UAAU,CAAC,eAAe;QACzC,YAAY,EAAE,CAAC,CAAC,UAAU,CAAC,YAAY;KAC1C,CAAA;IAED,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAEjD,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;QACxB,MAAM,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,EAAE;SAChB,CAAC,CAAC;IACP,CAAC;IAED,OAAO,IAAA,8BAAa,EAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AAClF,CAAC"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createOrUpdateDocumentFromInteractionRun = createOrUpdateDocumentFromInteractionRun;
|
|
4
|
-
const activity_1 = require("@temporalio/activity");
|
|
5
|
-
const common_1 = require("@vertesia/common");
|
|
6
|
-
const ActivityContext_js_1 = require("../../dsl/setup/ActivityContext.js");
|
|
7
|
-
const errors_js_1 = require("../../errors.js");
|
|
8
|
-
async function createOrUpdateDocumentFromInteractionRun(payload) {
|
|
9
|
-
const { params, client } = await (0, ActivityContext_js_1.setupActivity)(payload);
|
|
10
|
-
const runId = params.run_id;
|
|
11
|
-
const objectTypeName = params.object_type;
|
|
12
|
-
if (!runId) {
|
|
13
|
-
throw new errors_js_1.ActivityParamNotFoundError("run_id", payload.activity);
|
|
14
|
-
}
|
|
15
|
-
if (!objectTypeName && !params.update_existing_id) {
|
|
16
|
-
throw new errors_js_1.ActivityParamNotFoundError("object_type", payload.activity);
|
|
17
|
-
}
|
|
18
|
-
activity_1.log.info("Creating document from interaction result", { runId, objectTypeName });
|
|
19
|
-
const run = await client.runs.retrieve(runId).catch((e) => {
|
|
20
|
-
throw new errors_js_1.DocumentNotFoundError(`Error fetching run ${runId}: ${e.message}`);
|
|
21
|
-
});
|
|
22
|
-
const type = objectTypeName ?
|
|
23
|
-
await client.types.getTypeByName(objectTypeName).catch((e) => {
|
|
24
|
-
throw new errors_js_1.DocumentNotFoundError(`Error fetching type ${objectTypeName}: ${e.message}`);
|
|
25
|
-
})
|
|
26
|
-
: undefined;
|
|
27
|
-
const result = run.result;
|
|
28
|
-
const resultIsObject = typeof result === 'object';
|
|
29
|
-
const inputData = run.parameters;
|
|
30
|
-
let name;
|
|
31
|
-
if (resultIsObject) {
|
|
32
|
-
name = result['name'] || result["title"] || inputData['name'] || params.fallback_name || 'Untitled';
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
name = inputData['name'] || params.fallback_name || 'Untitled';
|
|
36
|
-
}
|
|
37
|
-
const docPayload = {
|
|
38
|
-
name,
|
|
39
|
-
parent: params.parent ?? undefined,
|
|
40
|
-
properties: resultIsObject ? result : {},
|
|
41
|
-
text: !resultIsObject ? result : undefined,
|
|
42
|
-
type: type?.id,
|
|
43
|
-
status: common_1.ContentObjectStatus.completed,
|
|
44
|
-
generation_run_info: {
|
|
45
|
-
id: run.id,
|
|
46
|
-
date: new Date().toISOString(),
|
|
47
|
-
model: run.modelId,
|
|
48
|
-
target: resultIsObject ? 'properties' : 'text'
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
if (params.update_text_from_property) {
|
|
52
|
-
const text = docPayload.properties[params.update_text_from_property];
|
|
53
|
-
if (text) {
|
|
54
|
-
docPayload.text = text;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
//create or update the document
|
|
58
|
-
let newDoc = false;
|
|
59
|
-
let doc = undefined;
|
|
60
|
-
if (params.update_existing_id) {
|
|
61
|
-
activity_1.log.info(`Updating existing document ${params.update_existing_id}`);
|
|
62
|
-
doc = await client.objects.update(params.update_existing_id, docPayload);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
activity_1.log.info(`Creating new document of type ${objectTypeName}`);
|
|
66
|
-
doc = await client.objects.create(docPayload);
|
|
67
|
-
newDoc = true;
|
|
68
|
-
}
|
|
69
|
-
activity_1.log.info(`Document ${objectTypeName + ' '}${doc.id}(${doc.name}) ${newDoc ? 'created' : 'updated'}`);
|
|
70
|
-
return { id: doc.id, isNew: newDoc, type: name };
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=createOrUpdateDocumentFromInteractionRun.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createOrUpdateDocumentFromInteractionRun.js","sourceRoot":"","sources":["../../../../src/activities/advanced/createOrUpdateDocumentFromInteractionRun.ts"],"names":[],"mappings":"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"}
|