@vertesia/workflow 0.77.0 → 0.78.0-dev-9372725
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
package/package.json
CHANGED
|
@@ -1,128 +1,136 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
"repository": {
|
|
15
|
-
"type": "git",
|
|
16
|
-
"url": "https://github.com/vertesia/composableai.git",
|
|
17
|
-
"directory": "zeno/workflow"
|
|
18
|
-
},
|
|
19
|
-
"license": "Apache-2.0",
|
|
20
|
-
"devDependencies": {
|
|
21
|
-
"@smithy/types": "^3.7.2",
|
|
22
|
-
"@temporalio/proto": "^1.11.5",
|
|
23
|
-
"@temporalio/testing": "^1.11.5",
|
|
24
|
-
"@temporalio/worker": "^1.11.5",
|
|
25
|
-
"@types/jsonwebtoken": "^9.0.7",
|
|
26
|
-
"@types/node": "^22.5.1",
|
|
27
|
-
"@types/papaparse": "^5.3.15",
|
|
28
|
-
"@types/tmp": "^0.2.6",
|
|
29
|
-
"ts-dual-module": "^0.6.3",
|
|
30
|
-
"vitest": "^3.0.9"
|
|
31
|
-
},
|
|
32
|
-
"dependencies": {
|
|
33
|
-
"@aws-sdk/client-s3": "^3.693.0",
|
|
34
|
-
"@aws-sdk/client-textract": "^3.693.0",
|
|
35
|
-
"@aws-sdk/credential-providers": "^3.693.0",
|
|
36
|
-
"@temporalio/activity": "^1.11.5",
|
|
37
|
-
"@temporalio/workflow": "^1.11.5",
|
|
38
|
-
"@types/json-schema": "^7.0.15",
|
|
39
|
-
"fast-deep-equal": "^3.1.3",
|
|
40
|
-
"jsonwebtoken": "^9.0.2",
|
|
41
|
-
"mime": "^4.0.0",
|
|
42
|
-
"ms": "3.0.0-canary.1",
|
|
43
|
-
"node-web-stream-adapters": "^0.2.1",
|
|
44
|
-
"p-limit": "^6.2.0",
|
|
45
|
-
"papaparse": "^5.4.1",
|
|
46
|
-
"seedrandom": "^3.0.5",
|
|
47
|
-
"sharp": "^0.33.4",
|
|
48
|
-
"tiktoken": "^1.0.15",
|
|
49
|
-
"tmp": "^0.2.3",
|
|
50
|
-
"tmp-promise": "^3.0.3",
|
|
51
|
-
"yaml": "^2.6.0",
|
|
52
|
-
"@llumiverse/common": "0.22.0",
|
|
53
|
-
"@vertesia/common": "0.77.0",
|
|
54
|
-
"@vertesia/client": "0.77.0",
|
|
55
|
-
"@vertesia/api-fetch-client": "0.77.0",
|
|
56
|
-
"@vertesia/memory": "0.48.0"
|
|
57
|
-
},
|
|
58
|
-
"ts_dual_module": {
|
|
59
|
-
"outDir": "lib",
|
|
60
|
-
"exports": {
|
|
61
|
-
"activities": "./activities/index.js",
|
|
62
|
-
"dsl-activities": "./activities/index-dsl.js",
|
|
63
|
-
"workflows": "./workflows",
|
|
64
|
-
"workflows-bundle": "./workflows-bundle.js",
|
|
65
|
-
"vars": "./vars"
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
"exports": {
|
|
69
|
-
".": {
|
|
70
|
-
"types": "./lib/types/index.d.ts",
|
|
71
|
-
"import": "./lib/esm/index.js",
|
|
72
|
-
"require": "./lib/cjs/index.js"
|
|
2
|
+
"name": "@vertesia/workflow",
|
|
3
|
+
"version": "0.78.0-dev-9372725",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Vertesia workflow DSL",
|
|
6
|
+
"main": "./lib/esm/index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib",
|
|
9
|
+
"src"
|
|
10
|
+
],
|
|
11
|
+
"bin": {
|
|
12
|
+
"bundle-workflows": "./bin/bundle-workflows.mjs"
|
|
73
13
|
},
|
|
74
|
-
"
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
14
|
+
"scripts": {
|
|
15
|
+
"test": "vitest run",
|
|
16
|
+
"build": "pnpm exec tsmod build && node ./bin/bundle-workflows.mjs lib/esm/workflows.js lib/workflows-bundle.js",
|
|
17
|
+
"clean": "rm -rf ./lib tsconfig.tsbuildinfo"
|
|
78
18
|
},
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
19
|
+
"license": "Apache-2.0",
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@smithy/types": "^3.7.2",
|
|
22
|
+
"@temporalio/proto": "^1.11.5",
|
|
23
|
+
"@temporalio/testing": "^1.11.5",
|
|
24
|
+
"@temporalio/worker": "^1.11.5",
|
|
25
|
+
"@types/jsonwebtoken": "^9.0.7",
|
|
26
|
+
"@types/node": "^22.5.1",
|
|
27
|
+
"@types/papaparse": "^5.3.15",
|
|
28
|
+
"@types/tmp": "^0.2.6",
|
|
29
|
+
"ts-dual-module": "^0.6.3",
|
|
30
|
+
"vitest": "^3.0.9"
|
|
83
31
|
},
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@aws-sdk/client-s3": "^3.693.0",
|
|
34
|
+
"@aws-sdk/client-textract": "^3.693.0",
|
|
35
|
+
"@aws-sdk/credential-providers": "^3.693.0",
|
|
36
|
+
"@llumiverse/common": "workspace:*",
|
|
37
|
+
"@temporalio/activity": "^1.11.5",
|
|
38
|
+
"@temporalio/workflow": "^1.11.5",
|
|
39
|
+
"@types/json-schema": "^7.0.15",
|
|
40
|
+
"@vertesia/api-fetch-client": "workspace:*",
|
|
41
|
+
"@vertesia/client": "workspace:*",
|
|
42
|
+
"@vertesia/common": "workspace:*",
|
|
43
|
+
"@vertesia/memory": "workspace:*",
|
|
44
|
+
"fast-deep-equal": "^3.1.3",
|
|
45
|
+
"jsonwebtoken": "^9.0.2",
|
|
46
|
+
"mime": "^4.0.0",
|
|
47
|
+
"ms": "3.0.0-canary.1",
|
|
48
|
+
"node-web-stream-adapters": "^0.2.1",
|
|
49
|
+
"p-limit": "^6.2.0",
|
|
50
|
+
"papaparse": "^5.4.1",
|
|
51
|
+
"seedrandom": "^3.0.5",
|
|
52
|
+
"sharp": "^0.33.4",
|
|
53
|
+
"tiktoken": "^1.0.15",
|
|
54
|
+
"tmp": "^0.2.4",
|
|
55
|
+
"tmp-promise": "^3.0.3",
|
|
56
|
+
"yaml": "^2.6.0"
|
|
88
57
|
},
|
|
89
|
-
"
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
58
|
+
"ts_dual_module": {
|
|
59
|
+
"outDir": "lib",
|
|
60
|
+
"exports": {
|
|
61
|
+
"activities": "./activities/index.js",
|
|
62
|
+
"dsl-activities": "./activities/index-dsl.js",
|
|
63
|
+
"workflows": "./workflows",
|
|
64
|
+
"workflows-bundle": "./workflows-bundle.js",
|
|
65
|
+
"vars": "./vars"
|
|
66
|
+
}
|
|
93
67
|
},
|
|
94
|
-
"
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
68
|
+
"exports": {
|
|
69
|
+
".": {
|
|
70
|
+
"types": "./lib/types/index.d.ts",
|
|
71
|
+
"import": "./lib/esm/index.js",
|
|
72
|
+
"require": "./lib/cjs/index.js"
|
|
73
|
+
},
|
|
74
|
+
"./vars": {
|
|
75
|
+
"types": "./lib/types/vars.d.ts",
|
|
76
|
+
"import": "./lib/esm/vars.js",
|
|
77
|
+
"require": "./lib/cjs/vars.js"
|
|
78
|
+
},
|
|
79
|
+
"./activities": {
|
|
80
|
+
"types": "./lib/types/activities/index.d.ts",
|
|
81
|
+
"import": "./lib/esm/activities/index.js",
|
|
82
|
+
"require": "./lib/cjs/activities/index.js"
|
|
83
|
+
},
|
|
84
|
+
"./dsl-activities": {
|
|
85
|
+
"types": "./lib/types/activities/index-dsl.d.ts",
|
|
86
|
+
"import": "./lib/esm/activities/index-dsl.js",
|
|
87
|
+
"require": "./lib/cjs/activities/index-dsl.js"
|
|
88
|
+
},
|
|
89
|
+
"./workflows": {
|
|
90
|
+
"types": "./lib/types/workflows.d.ts",
|
|
91
|
+
"import": "./lib/esm/workflows.js",
|
|
92
|
+
"require": "./lib/cjs/workflows.js"
|
|
93
|
+
},
|
|
94
|
+
"./dsl": {
|
|
95
|
+
"types": "./lib/types/dsl.d.ts",
|
|
96
|
+
"import": "./lib/esm/dsl.js",
|
|
97
|
+
"require": "./lib/cjs/dsl.js"
|
|
98
|
+
},
|
|
99
|
+
"./workflows-bundle": {
|
|
100
|
+
"import": "./lib/workflows-bundle.js"
|
|
101
|
+
},
|
|
102
|
+
"./errors": {
|
|
103
|
+
"types": "./lib/types/errors.d.ts",
|
|
104
|
+
"import": "./lib/esm/errors.js",
|
|
105
|
+
"require": "./lib/cjs/errors.js"
|
|
106
|
+
}
|
|
98
107
|
},
|
|
99
|
-
"
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
"
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
108
|
+
"repository": {
|
|
109
|
+
"type": "git",
|
|
110
|
+
"url": "https://github.com/vertesia/composableai.git",
|
|
111
|
+
"directory": "packages/workflow"
|
|
112
|
+
},
|
|
113
|
+
"types": "./lib/types/index.d.ts",
|
|
114
|
+
"typesVersions": {
|
|
115
|
+
"*": {
|
|
116
|
+
"activities": [
|
|
117
|
+
"./lib/types/activities/index.d.ts"
|
|
118
|
+
],
|
|
119
|
+
"dsl-activities": [
|
|
120
|
+
"./lib/types/activities/index-dsl.d.ts"
|
|
121
|
+
],
|
|
122
|
+
"workflows": [
|
|
123
|
+
"./lib/types/workflows.d.ts"
|
|
124
|
+
],
|
|
125
|
+
"dsl": [
|
|
126
|
+
"./lib/types/dsl.d.ts"
|
|
127
|
+
],
|
|
128
|
+
"vars": [
|
|
129
|
+
"./lib/types/dsl/vars.d.ts"
|
|
130
|
+
],
|
|
131
|
+
"errors": [
|
|
132
|
+
"./lib/types/errors.d.ts"
|
|
133
|
+
]
|
|
134
|
+
}
|
|
121
135
|
}
|
|
122
|
-
|
|
123
|
-
"scripts": {
|
|
124
|
-
"test": "vitest run",
|
|
125
|
-
"build": "pnpm exec tsmod build && node ./bin/bundle-workflows.mjs lib/esm/workflows.js lib/workflows-bundle.js",
|
|
126
|
-
"clean": "rm -rf ./lib tsconfig.tsbuildinfo"
|
|
127
|
-
}
|
|
128
|
-
}
|
|
136
|
+
}
|
|
@@ -3,6 +3,7 @@ import { log } from "@temporalio/activity";
|
|
|
3
3
|
import { projectResult } from "../../dsl/projections.js";
|
|
4
4
|
import { setupActivity } from "../../dsl/setup/ActivityContext.js";
|
|
5
5
|
import { ActivityParamNotFoundError } from "../../errors.js";
|
|
6
|
+
import { parseCompletionResultsToJson } from "@llumiverse/common";
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
export interface CreateDocumentTypeFromInteractionRunParams {
|
|
@@ -30,16 +31,18 @@ export async function createDocumentTypeFromInteractionRun(payload: DSLActivityE
|
|
|
30
31
|
|
|
31
32
|
const genTypeRes = params.run.result;
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
const jsonResult = parseCompletionResultsToJson(params.run.result);
|
|
35
|
+
|
|
36
|
+
if (!jsonResult.document_type) {
|
|
34
37
|
log.error("No name generated for type: " + JSON.stringify(genTypeRes), genTypeRes);
|
|
35
38
|
throw new Error("No name generated for type");
|
|
36
39
|
}
|
|
37
40
|
|
|
38
|
-
log.info("Generated schema for type",
|
|
41
|
+
log.info("Generated schema for type", jsonResult.metadata_schema);
|
|
39
42
|
const typeData: CreateContentObjectTypePayload = {
|
|
40
|
-
name:
|
|
41
|
-
object_schema:
|
|
42
|
-
is_chunkable: !!
|
|
43
|
+
name: jsonResult.document_type,
|
|
44
|
+
object_schema: jsonResult.metadata_schema,
|
|
45
|
+
is_chunkable: !!jsonResult.is_chunkable,
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
const type = await client.types.create(typeData);
|
|
@@ -2,6 +2,7 @@ import { log } from "@temporalio/activity";
|
|
|
2
2
|
import { ContentObjectStatus, DSLActivityExecutionPayload, DSLActivitySpec } from "@vertesia/common";
|
|
3
3
|
import { setupActivity } from "../../dsl/setup/ActivityContext.js";
|
|
4
4
|
import { ActivityParamNotFoundError, DocumentNotFoundError } from "../../errors.js";
|
|
5
|
+
import { parseCompletionResultsToJson, completionResultToString } from "@llumiverse/common";
|
|
5
6
|
|
|
6
7
|
interface CreateOrUpdateObjectFromInteractionRunParams {
|
|
7
8
|
/**
|
|
@@ -68,28 +69,23 @@ export async function createOrUpdateDocumentFromInteractionRun(payload: DSLActiv
|
|
|
68
69
|
|
|
69
70
|
|
|
70
71
|
const result = run.result;
|
|
71
|
-
const
|
|
72
|
+
const jsonResult = parseCompletionResultsToJson(run.result);
|
|
72
73
|
const inputData = run.parameters;
|
|
73
74
|
|
|
74
|
-
|
|
75
|
-
if (resultIsObject) {
|
|
76
|
-
name = result['name'] || result["title"] || inputData['name'] || params.fallback_name || 'Untitled';
|
|
77
|
-
} else {
|
|
78
|
-
name = inputData['name'] || params.fallback_name || 'Untitled';
|
|
79
|
-
}
|
|
75
|
+
const name = jsonResult['name'] || jsonResult["title"] || inputData['name'] || params.fallback_name || 'Untitled';
|
|
80
76
|
|
|
81
77
|
const docPayload = {
|
|
82
78
|
name,
|
|
83
79
|
parent: params.parent ?? undefined,
|
|
84
|
-
properties:
|
|
85
|
-
text: !
|
|
80
|
+
properties: jsonResult ? jsonResult : {},
|
|
81
|
+
text: !jsonResult ? result.map(completionResultToString).join('\n') : undefined,
|
|
86
82
|
type: type?.id,
|
|
87
83
|
status: ContentObjectStatus.completed,
|
|
88
84
|
generation_run_info: {
|
|
89
85
|
id: run.id,
|
|
90
86
|
date: new Date().toISOString(),
|
|
91
87
|
model: run.modelId,
|
|
92
|
-
target:
|
|
88
|
+
target: jsonResult ? 'properties' : 'text'
|
|
93
89
|
}
|
|
94
90
|
};
|
|
95
91
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DSLActivityExecutionPayload, DSLActivitySpec, ExecutionRun } from "@vertesia/common";
|
|
2
2
|
import { setupActivity } from "../../dsl/setup/ActivityContext.js";
|
|
3
3
|
import { ActivityParamNotFoundError } from "../../errors.js";
|
|
4
|
+
import { parseCompletionResultsToJson } from "@llumiverse/common";
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
export interface UpdateDocumentFromInteractionRunParams {
|
|
@@ -28,7 +29,9 @@ export async function updateDocumentFromInteractionRun(payload: DSLActivityExecu
|
|
|
28
29
|
return { status: "failed", error: "no-props" };
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
const jsonResult = parseCompletionResultsToJson(params.run.result);
|
|
33
|
+
|
|
34
|
+
await client.objects.update(objectId, jsonResult);
|
|
32
35
|
|
|
33
36
|
return { status: "success" };
|
|
34
37
|
}
|
|
@@ -3,6 +3,7 @@ import { DSLActivityExecutionPayload, DSLActivitySpec } from "@vertesia/common";
|
|
|
3
3
|
import { setupActivity } from "../dsl/setup/ActivityContext.js";
|
|
4
4
|
import { DocPart } from "../utils/chunks.js";
|
|
5
5
|
import { InteractionExecutionParams, executeInteractionFromActivity } from "./executeInteraction.js";
|
|
6
|
+
import { parseCompletionResultsToJson } from "@llumiverse/common";
|
|
6
7
|
|
|
7
8
|
const INT_CHUNK_DOCUMENT = "sys:ChunkDocument"
|
|
8
9
|
|
|
@@ -82,7 +83,9 @@ export async function chunkDocument(payload: DSLActivityExecutionPayload<ChunkDo
|
|
|
82
83
|
content: instrumented
|
|
83
84
|
});
|
|
84
85
|
|
|
85
|
-
const
|
|
86
|
+
const jsonResult = parseCompletionResultsToJson(res.result);
|
|
87
|
+
|
|
88
|
+
const parts = jsonResult.parts as DocPart[];
|
|
86
89
|
if (!parts || parts.length === 0) {
|
|
87
90
|
log.warn('No parts found for object ID: ' + objectId, res);
|
|
88
91
|
return { id: objectId, status: "failed", parts: [], message: "no parts found" }
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from "@vertesia/common";
|
|
14
14
|
import { projectResult } from "../dsl/projections.js";
|
|
15
15
|
import { setupActivity } from "../dsl/setup/ActivityContext.js";
|
|
16
|
-
import { ActivityParamInvalidError, ActivityParamNotFoundError } from "../errors.js";
|
|
16
|
+
import { ActivityParamInvalidError, ActivityParamNotFoundError, ResourceExhaustedError } from "../errors.js";
|
|
17
17
|
import { TruncateSpec, truncByMaxTokens } from "../utils/tokens.js";
|
|
18
18
|
import { Readable } from "stream";
|
|
19
19
|
|
|
@@ -98,6 +98,11 @@ export interface InteractionExecutionParams {
|
|
|
98
98
|
* Options to control generation
|
|
99
99
|
*/
|
|
100
100
|
model_options?: ModelOptions;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* activity won't be retried if it fails due to resource exhaustion (429)
|
|
104
|
+
*/
|
|
105
|
+
exit_on_resource_exhaustion?: boolean;
|
|
101
106
|
}
|
|
102
107
|
|
|
103
108
|
/**
|
|
@@ -153,11 +158,11 @@ export async function executeInteraction(payload: DSLActivityExecutionPayload<Ex
|
|
|
153
158
|
|
|
154
159
|
// Handle image uploads if the result contains base64 images
|
|
155
160
|
if (res.output_modality === Modalities.image) {
|
|
156
|
-
const images = res.result.
|
|
161
|
+
const images = res.result.filter((r: { type: string; }) => r.type === 'image');
|
|
157
162
|
const uploadedImages = await Promise.all(
|
|
158
|
-
images.map((image: string, index: number) => {
|
|
163
|
+
images.map((image: { value: string; }, index: number) => {
|
|
159
164
|
// Extract base64 data and create buffer
|
|
160
|
-
const base64Data = image.replace(/^data:image\/[a-z]+;base64,/, "");
|
|
165
|
+
const base64Data = image.value.replace(/^data:image\/[a-z]+;base64,/, "");
|
|
161
166
|
const buffer = Buffer.from(base64Data, 'base64');
|
|
162
167
|
|
|
163
168
|
// Generate filename
|
|
@@ -177,7 +182,7 @@ export async function executeInteraction(payload: DSLActivityExecutionPayload<Ex
|
|
|
177
182
|
return client.files.uploadFile(source);
|
|
178
183
|
})
|
|
179
184
|
);
|
|
180
|
-
res.result
|
|
185
|
+
res.result = uploadedImages.map(file => ({ type: "image", value: file }));
|
|
181
186
|
}
|
|
182
187
|
|
|
183
188
|
return projectResult(payload, params, res, {
|
|
@@ -187,15 +192,17 @@ export async function executeInteraction(payload: DSLActivityExecutionPayload<Ex
|
|
|
187
192
|
});
|
|
188
193
|
|
|
189
194
|
} catch (error: any) {
|
|
190
|
-
log.error(
|
|
191
|
-
if (error.
|
|
195
|
+
log.error(`Failed to execute interaction ${interactionName}`, { error });
|
|
196
|
+
if (error.statusCode === 429 && params.exit_on_resource_exhaustion) {
|
|
197
|
+
throw new ResourceExhaustedError(error.statusCode, "Resource exhausted - rate limit exceeded");
|
|
198
|
+
} else if (error.message.includes("Failed to validate merged prompt schema")) {
|
|
192
199
|
//issue with the input data, don't retry
|
|
193
200
|
throw new ActivityParamInvalidError("prompt_data", payload.activity, error.message);
|
|
194
201
|
} else if (error.message.includes("modelId: Path `modelId` is required")) {
|
|
195
202
|
//issue with the input data, don't retry
|
|
196
203
|
throw new ActivityParamInvalidError("model", payload.activity, error.message);
|
|
197
204
|
} else {
|
|
198
|
-
throw error;
|
|
205
|
+
throw new Error(`Interaction Execution failed ${interactionName}: ${error.message}`);
|
|
199
206
|
}
|
|
200
207
|
}
|
|
201
208
|
}
|
|
@@ -270,7 +277,7 @@ export async function executeInteractionFromActivity(
|
|
|
270
277
|
})
|
|
271
278
|
.catch((err) => {
|
|
272
279
|
log.error(`Error executing interaction ${interactionName}`, { err });
|
|
273
|
-
throw
|
|
280
|
+
throw err;
|
|
274
281
|
});
|
|
275
282
|
|
|
276
283
|
if (debug) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { log } from "@temporalio/activity";
|
|
2
2
|
import { DSLActivityExecutionPayload, DSLActivitySpec } from "@vertesia/common";
|
|
3
3
|
import { setupActivity } from "../dsl/setup/ActivityContext.js";
|
|
4
|
-
import { TruncateSpec } from "../utils/tokens.js";
|
|
4
|
+
import { TruncateSpec, truncByMaxTokens } from "../utils/tokens.js";
|
|
5
5
|
import { InteractionExecutionParams, executeInteractionFromActivity } from "./executeInteraction.js";
|
|
6
|
+
import { parseCompletionResultsToJson } from "@llumiverse/common";
|
|
6
7
|
|
|
7
8
|
const INT_EXTRACT_INFORMATION = "sys:ExtractInformation";
|
|
8
9
|
export interface GenerateDocumentPropertiesParams extends InteractionExecutionParams {
|
|
@@ -55,8 +56,12 @@ export async function generateDocumentProperties(
|
|
|
55
56
|
return undefined;
|
|
56
57
|
};
|
|
57
58
|
|
|
59
|
+
const content = doc.text
|
|
60
|
+
? truncByMaxTokens(doc.text, params.truncate || 30000)
|
|
61
|
+
: undefined;
|
|
62
|
+
|
|
58
63
|
const promptData = {
|
|
59
|
-
content:
|
|
64
|
+
content: content,
|
|
60
65
|
image: getImageRef() ?? undefined,
|
|
61
66
|
human_context: project?.configuration?.human_context ?? undefined,
|
|
62
67
|
};
|
|
@@ -84,11 +89,12 @@ export async function generateDocumentProperties(
|
|
|
84
89
|
return undefined;
|
|
85
90
|
}
|
|
86
91
|
let text = "";
|
|
87
|
-
|
|
88
|
-
|
|
92
|
+
const jsonResult = parseCompletionResultsToJson(infoRes.result);
|
|
93
|
+
if (jsonResult.title) {
|
|
94
|
+
text += jsonResult.title + "\n";
|
|
89
95
|
}
|
|
90
|
-
if (
|
|
91
|
-
text +=
|
|
96
|
+
if (jsonResult.description) {
|
|
97
|
+
text += jsonResult.description;
|
|
92
98
|
}
|
|
93
99
|
if (text) {
|
|
94
100
|
return text;
|
|
@@ -100,7 +106,7 @@ export async function generateDocumentProperties(
|
|
|
100
106
|
log.info(`Extracted information from object ${objectId} with type ${type.name}`, { runId: infoRes.id });
|
|
101
107
|
await client.objects.update(doc.id, {
|
|
102
108
|
properties: {
|
|
103
|
-
...infoRes.result,
|
|
109
|
+
...parseCompletionResultsToJson(infoRes.result),
|
|
104
110
|
etag: doc.text_etag,
|
|
105
111
|
},
|
|
106
112
|
text: getText(),
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
InteractionExecutionParams,
|
|
16
16
|
executeInteractionFromActivity,
|
|
17
17
|
} from "./executeInteraction.js";
|
|
18
|
+
import { parseCompletionResultsToJson } from "@llumiverse/common";
|
|
18
19
|
|
|
19
20
|
const INT_SELECT_DOCUMENT_TYPE = "sys:SelectDocumentType";
|
|
20
21
|
const INT_GENERATE_METADATA_MODEL = "sys:GenerateMetadataModel";
|
|
@@ -119,7 +120,7 @@ export async function generateOrAssignContentType(
|
|
|
119
120
|
|
|
120
121
|
log.info(
|
|
121
122
|
"Execute SelectDocumentType interaction on content with \nexisting types - passing full types: " +
|
|
122
|
-
|
|
123
|
+
existing_types.filter((t) => !t.tags?.includes("system")),
|
|
123
124
|
);
|
|
124
125
|
|
|
125
126
|
const res = await executeInteractionFromActivity(
|
|
@@ -133,12 +134,15 @@ export async function generateOrAssignContentType(
|
|
|
133
134
|
},
|
|
134
135
|
);
|
|
135
136
|
|
|
136
|
-
|
|
137
|
+
const jsonResult = parseCompletionResultsToJson(res.result);
|
|
138
|
+
|
|
139
|
+
log.info("Selected Content Type Result: " + JSON.stringify(jsonResult));
|
|
140
|
+
|
|
137
141
|
|
|
138
142
|
//if type is not identified or not present in the database, generate a new type
|
|
139
143
|
let selectedType: { id: string; name: string } | undefined = undefined;
|
|
140
144
|
|
|
141
|
-
selectedType = types.find((t) => t.name ===
|
|
145
|
+
selectedType = types.find((t) => t.name === jsonResult.document_type);
|
|
142
146
|
|
|
143
147
|
if (!selectedType) {
|
|
144
148
|
log.warn("Document type not identified: starting type generation");
|
|
@@ -153,7 +157,7 @@ export async function generateOrAssignContentType(
|
|
|
153
157
|
|
|
154
158
|
if (!selectedType) {
|
|
155
159
|
log.error("Type not found: ", res.result);
|
|
156
|
-
throw new Error("Type not found: " +
|
|
160
|
+
throw new Error("Type not found: " + jsonResult.document_type);
|
|
157
161
|
}
|
|
158
162
|
|
|
159
163
|
//update object with selected type
|
|
@@ -193,18 +197,20 @@ async function generateNewType(
|
|
|
193
197
|
},
|
|
194
198
|
);
|
|
195
199
|
|
|
196
|
-
|
|
200
|
+
const jsonResult = parseCompletionResultsToJson(genTypeRes.result);
|
|
201
|
+
|
|
202
|
+
if (!jsonResult.document_type) {
|
|
197
203
|
log.error("No name generated for type", genTypeRes);
|
|
198
204
|
throw new Error("No name generated for type");
|
|
199
205
|
}
|
|
200
206
|
|
|
201
|
-
log.info("Generated schema for type",
|
|
207
|
+
log.info("Generated schema for type", jsonResult.metadata_schema);
|
|
202
208
|
const typeData: CreateContentObjectTypePayload = {
|
|
203
|
-
name:
|
|
204
|
-
description:
|
|
205
|
-
object_schema:
|
|
206
|
-
is_chunkable:
|
|
207
|
-
table_layout:
|
|
209
|
+
name: jsonResult.document_type,
|
|
210
|
+
description: jsonResult.document_type_description,
|
|
211
|
+
object_schema: jsonResult.metadata_schema,
|
|
212
|
+
is_chunkable: jsonResult.is_chunkable,
|
|
213
|
+
table_layout: jsonResult.table_layout,
|
|
208
214
|
};
|
|
209
215
|
|
|
210
216
|
const type = await client.types.create(typeData);
|
|
@@ -17,4 +17,4 @@ export { convertPdfToStructuredText } from "./media/processPdfWithTextract.js";
|
|
|
17
17
|
export { transcribeMedia } from "./media/transcribeMediaWithGladia.js";
|
|
18
18
|
export { notifyWebhook } from "./notifyWebhook.js";
|
|
19
19
|
export { setDocumentStatus } from "./setDocumentStatus.js";
|
|
20
|
-
export {
|
|
20
|
+
export { checkRateLimit } from "./rateLimiter.js";
|