@vertesia/workflow 0.42.2
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/LICENSE +13 -0
- package/README.md +24 -0
- package/bin/bundle-workflows.mjs +26 -0
- package/lib/cjs/activities/advanced/createDocumentTypeFromInteractionRun.js +32 -0
- package/lib/cjs/activities/advanced/createDocumentTypeFromInteractionRun.js.map +1 -0
- package/lib/cjs/activities/advanced/createOrUpdateDocumentFromInteractionRun.js +66 -0
- package/lib/cjs/activities/advanced/createOrUpdateDocumentFromInteractionRun.js.map +1 -0
- package/lib/cjs/activities/advanced/updateDocumentFromInteractionRun.js +18 -0
- package/lib/cjs/activities/advanced/updateDocumentFromInteractionRun.js.map +1 -0
- package/lib/cjs/activities/chunkDocument.js +79 -0
- package/lib/cjs/activities/chunkDocument.js.map +1 -0
- package/lib/cjs/activities/createDocumentFromOther.js +64 -0
- package/lib/cjs/activities/createDocumentFromOther.js.map +1 -0
- package/lib/cjs/activities/executeInteraction.js +135 -0
- package/lib/cjs/activities/executeInteraction.js.map +1 -0
- package/lib/cjs/activities/extractDocumentText.js +140 -0
- package/lib/cjs/activities/extractDocumentText.js.map +1 -0
- package/lib/cjs/activities/generateDocumentProperties.js +59 -0
- package/lib/cjs/activities/generateDocumentProperties.js.map +1 -0
- package/lib/cjs/activities/generateEmbeddings.js +292 -0
- package/lib/cjs/activities/generateEmbeddings.js.map +1 -0
- package/lib/cjs/activities/generateImageRendition.js +104 -0
- package/lib/cjs/activities/generateImageRendition.js.map +1 -0
- package/lib/cjs/activities/generateOrAssignContentType.js +103 -0
- package/lib/cjs/activities/generateOrAssignContentType.js.map +1 -0
- package/lib/cjs/activities/getObjectFromStore.js +20 -0
- package/lib/cjs/activities/getObjectFromStore.js.map +1 -0
- package/lib/cjs/activities/index.js +54 -0
- package/lib/cjs/activities/index.js.map +1 -0
- package/lib/cjs/activities/media/processPdfWithTextract.js +102 -0
- package/lib/cjs/activities/media/processPdfWithTextract.js.map +1 -0
- package/lib/cjs/activities/media/transcribeMediaWithGladia.js +51 -0
- package/lib/cjs/activities/media/transcribeMediaWithGladia.js.map +1 -0
- package/lib/cjs/activities/notifyWebhook.js +34 -0
- package/lib/cjs/activities/notifyWebhook.js.map +1 -0
- package/lib/cjs/activities/setDocumentStatus.js +15 -0
- package/lib/cjs/activities/setDocumentStatus.js.map +1 -0
- package/lib/cjs/conversion/TextractProcessor.js +416 -0
- package/lib/cjs/conversion/TextractProcessor.js.map +1 -0
- package/lib/cjs/conversion/image.js +22 -0
- package/lib/cjs/conversion/image.js.map +1 -0
- package/lib/cjs/conversion/mutool.js +147 -0
- package/lib/cjs/conversion/mutool.js.map +1 -0
- package/lib/cjs/conversion/pandoc.js +39 -0
- package/lib/cjs/conversion/pandoc.js.map +1 -0
- package/lib/cjs/conversion/pdf.js +13 -0
- package/lib/cjs/conversion/pdf.js.map +1 -0
- package/lib/cjs/dsl/conditions.js +81 -0
- package/lib/cjs/dsl/conditions.js.map +1 -0
- package/lib/cjs/dsl/dsl-workflow.js +223 -0
- package/lib/cjs/dsl/dsl-workflow.js.map +1 -0
- package/lib/cjs/dsl/projections.js +59 -0
- package/lib/cjs/dsl/projections.js.map +1 -0
- package/lib/cjs/dsl/setup/ActivityContext.js +96 -0
- package/lib/cjs/dsl/setup/ActivityContext.js.map +1 -0
- package/lib/cjs/dsl/setup/fetch/DataProvider.js +51 -0
- package/lib/cjs/dsl/setup/fetch/DataProvider.js.map +1 -0
- package/lib/cjs/dsl/setup/fetch/index.js +16 -0
- package/lib/cjs/dsl/setup/fetch/index.js.map +1 -0
- package/lib/cjs/dsl/setup/fetch/providers.js +67 -0
- package/lib/cjs/dsl/setup/fetch/providers.js.map +1 -0
- package/lib/cjs/dsl/test/test-child-workflow.js +10 -0
- package/lib/cjs/dsl/test/test-child-workflow.js.map +1 -0
- package/lib/cjs/dsl/validation.js +122 -0
- package/lib/cjs/dsl/validation.js.map +1 -0
- package/lib/cjs/dsl/vars.js +341 -0
- package/lib/cjs/dsl/vars.js.map +1 -0
- package/lib/cjs/dsl/walk.js +100 -0
- package/lib/cjs/dsl/walk.js.map +1 -0
- package/lib/cjs/errors.js +36 -0
- package/lib/cjs/errors.js.map +1 -0
- package/lib/cjs/index.js +43 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/iterative-generation/activities/extractToc.js +47 -0
- package/lib/cjs/iterative-generation/activities/extractToc.js.map +1 -0
- package/lib/cjs/iterative-generation/activities/finalizeOutput.js +69 -0
- package/lib/cjs/iterative-generation/activities/finalizeOutput.js.map +1 -0
- package/lib/cjs/iterative-generation/activities/generatePart.js +73 -0
- package/lib/cjs/iterative-generation/activities/generatePart.js.map +1 -0
- package/lib/cjs/iterative-generation/activities/generateToc.js +91 -0
- package/lib/cjs/iterative-generation/activities/generateToc.js.map +1 -0
- package/lib/cjs/iterative-generation/activities/index.js +12 -0
- package/lib/cjs/iterative-generation/activities/index.js.map +1 -0
- package/lib/cjs/iterative-generation/iterativeGenerationWorkflow.js +55 -0
- package/lib/cjs/iterative-generation/iterativeGenerationWorkflow.js.map +1 -0
- package/lib/cjs/iterative-generation/types.js +5 -0
- package/lib/cjs/iterative-generation/types.js.map +1 -0
- package/lib/cjs/iterative-generation/utils.js +118 -0
- package/lib/cjs/iterative-generation/utils.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/result-types.js +10 -0
- package/lib/cjs/result-types.js.map +1 -0
- package/lib/cjs/system/generateObjectText.js +89 -0
- package/lib/cjs/system/generateObjectText.js.map +1 -0
- package/lib/cjs/system/notifyWebhookWorkflow.js +52 -0
- package/lib/cjs/system/notifyWebhookWorkflow.js.map +1 -0
- package/lib/cjs/system/recalculateEmbeddingsWorkflow.js +37 -0
- package/lib/cjs/system/recalculateEmbeddingsWorkflow.js.map +1 -0
- package/lib/cjs/utils/auth.js +15 -0
- package/lib/cjs/utils/auth.js.map +1 -0
- package/lib/cjs/utils/blobs.js +63 -0
- package/lib/cjs/utils/blobs.js.map +1 -0
- package/lib/cjs/utils/client.js +25 -0
- package/lib/cjs/utils/client.js.map +1 -0
- package/lib/cjs/utils/expand-vars.js +33 -0
- package/lib/cjs/utils/expand-vars.js.map +1 -0
- package/lib/cjs/utils/memory.js +72 -0
- package/lib/cjs/utils/memory.js.map +1 -0
- package/lib/cjs/utils/tokens.js +38 -0
- package/lib/cjs/utils/tokens.js.map +1 -0
- package/lib/cjs/vars.js +20 -0
- package/lib/cjs/vars.js.map +1 -0
- package/lib/cjs/workflows.js +17 -0
- package/lib/cjs/workflows.js.map +1 -0
- package/lib/esm/activities/advanced/createDocumentTypeFromInteractionRun.js +29 -0
- package/lib/esm/activities/advanced/createDocumentTypeFromInteractionRun.js.map +1 -0
- package/lib/esm/activities/advanced/createOrUpdateDocumentFromInteractionRun.js +63 -0
- package/lib/esm/activities/advanced/createOrUpdateDocumentFromInteractionRun.js.map +1 -0
- package/lib/esm/activities/advanced/updateDocumentFromInteractionRun.js +15 -0
- package/lib/esm/activities/advanced/updateDocumentFromInteractionRun.js.map +1 -0
- package/lib/esm/activities/chunkDocument.js +76 -0
- package/lib/esm/activities/chunkDocument.js.map +1 -0
- package/lib/esm/activities/createDocumentFromOther.js +58 -0
- package/lib/esm/activities/createDocumentFromOther.js.map +1 -0
- package/lib/esm/activities/executeInteraction.js +131 -0
- package/lib/esm/activities/executeInteraction.js.map +1 -0
- package/lib/esm/activities/extractDocumentText.js +137 -0
- package/lib/esm/activities/extractDocumentText.js.map +1 -0
- package/lib/esm/activities/generateDocumentProperties.js +56 -0
- package/lib/esm/activities/generateDocumentProperties.js.map +1 -0
- package/lib/esm/activities/generateEmbeddings.js +256 -0
- package/lib/esm/activities/generateEmbeddings.js.map +1 -0
- package/lib/esm/activities/generateImageRendition.js +98 -0
- package/lib/esm/activities/generateImageRendition.js.map +1 -0
- package/lib/esm/activities/generateOrAssignContentType.js +100 -0
- package/lib/esm/activities/generateOrAssignContentType.js.map +1 -0
- package/lib/esm/activities/getObjectFromStore.js +17 -0
- package/lib/esm/activities/getObjectFromStore.js.map +1 -0
- package/lib/esm/activities/index.js +21 -0
- package/lib/esm/activities/index.js.map +1 -0
- package/lib/esm/activities/media/processPdfWithTextract.js +98 -0
- package/lib/esm/activities/media/processPdfWithTextract.js.map +1 -0
- package/lib/esm/activities/media/transcribeMediaWithGladia.js +48 -0
- package/lib/esm/activities/media/transcribeMediaWithGladia.js.map +1 -0
- package/lib/esm/activities/notifyWebhook.js +31 -0
- package/lib/esm/activities/notifyWebhook.js.map +1 -0
- package/lib/esm/activities/setDocumentStatus.js +12 -0
- package/lib/esm/activities/setDocumentStatus.js.map +1 -0
- package/lib/esm/conversion/TextractProcessor.js +409 -0
- package/lib/esm/conversion/TextractProcessor.js.map +1 -0
- package/lib/esm/conversion/image.js +16 -0
- package/lib/esm/conversion/image.js.map +1 -0
- package/lib/esm/conversion/mutool.js +139 -0
- package/lib/esm/conversion/mutool.js.map +1 -0
- package/lib/esm/conversion/pandoc.js +36 -0
- package/lib/esm/conversion/pandoc.js.map +1 -0
- package/lib/esm/conversion/pdf.js +7 -0
- package/lib/esm/conversion/pdf.js.map +1 -0
- package/lib/esm/dsl/conditions.js +75 -0
- package/lib/esm/dsl/conditions.js.map +1 -0
- package/lib/esm/dsl/dsl-workflow.js +216 -0
- package/lib/esm/dsl/dsl-workflow.js.map +1 -0
- package/lib/esm/dsl/projections.js +55 -0
- package/lib/esm/dsl/projections.js.map +1 -0
- package/lib/esm/dsl/setup/ActivityContext.js +91 -0
- package/lib/esm/dsl/setup/ActivityContext.js.map +1 -0
- package/lib/esm/dsl/setup/fetch/DataProvider.js +47 -0
- package/lib/esm/dsl/setup/fetch/DataProvider.js.map +1 -0
- package/lib/esm/dsl/setup/fetch/index.js +12 -0
- package/lib/esm/dsl/setup/fetch/index.js.map +1 -0
- package/lib/esm/dsl/setup/fetch/providers.js +61 -0
- package/lib/esm/dsl/setup/fetch/providers.js.map +1 -0
- package/lib/esm/dsl/test/test-child-workflow.js +5 -0
- package/lib/esm/dsl/test/test-child-workflow.js.map +1 -0
- package/lib/esm/dsl/validation.js +118 -0
- package/lib/esm/dsl/validation.js.map +1 -0
- package/lib/esm/dsl/vars.js +335 -0
- package/lib/esm/dsl/vars.js.map +1 -0
- package/lib/esm/dsl/walk.js +96 -0
- package/lib/esm/dsl/walk.js.map +1 -0
- package/lib/esm/errors.js +30 -0
- package/lib/esm/errors.js.map +1 -0
- package/lib/esm/index.js +25 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/iterative-generation/activities/extractToc.js +44 -0
- package/lib/esm/iterative-generation/activities/extractToc.js.map +1 -0
- package/lib/esm/iterative-generation/activities/finalizeOutput.js +66 -0
- package/lib/esm/iterative-generation/activities/finalizeOutput.js.map +1 -0
- package/lib/esm/iterative-generation/activities/generatePart.js +70 -0
- package/lib/esm/iterative-generation/activities/generatePart.js.map +1 -0
- package/lib/esm/iterative-generation/activities/generateToc.js +88 -0
- package/lib/esm/iterative-generation/activities/generateToc.js.map +1 -0
- package/lib/esm/iterative-generation/activities/index.js +5 -0
- package/lib/esm/iterative-generation/activities/index.js.map +1 -0
- package/lib/esm/iterative-generation/iterativeGenerationWorkflow.js +52 -0
- package/lib/esm/iterative-generation/iterativeGenerationWorkflow.js.map +1 -0
- package/lib/esm/iterative-generation/types.js +2 -0
- package/lib/esm/iterative-generation/types.js.map +1 -0
- package/lib/esm/iterative-generation/utils.js +109 -0
- package/lib/esm/iterative-generation/utils.js.map +1 -0
- package/lib/esm/result-types.js +7 -0
- package/lib/esm/result-types.js.map +1 -0
- package/lib/esm/system/generateObjectText.js +86 -0
- package/lib/esm/system/generateObjectText.js.map +1 -0
- package/lib/esm/system/notifyWebhookWorkflow.js +49 -0
- package/lib/esm/system/notifyWebhookWorkflow.js.map +1 -0
- package/lib/esm/system/recalculateEmbeddingsWorkflow.js +34 -0
- package/lib/esm/system/recalculateEmbeddingsWorkflow.js.map +1 -0
- package/lib/esm/utils/auth.js +8 -0
- package/lib/esm/utils/auth.js.map +1 -0
- package/lib/esm/utils/blobs.js +52 -0
- package/lib/esm/utils/blobs.js.map +1 -0
- package/lib/esm/utils/client.js +22 -0
- package/lib/esm/utils/client.js.map +1 -0
- package/lib/esm/utils/expand-vars.js +30 -0
- package/lib/esm/utils/expand-vars.js.map +1 -0
- package/lib/esm/utils/memory.js +60 -0
- package/lib/esm/utils/memory.js.map +1 -0
- package/lib/esm/utils/tokens.js +34 -0
- package/lib/esm/utils/tokens.js.map +1 -0
- package/lib/esm/vars.js +4 -0
- package/lib/esm/vars.js.map +1 -0
- package/lib/esm/workflows.js +9 -0
- package/lib/esm/workflows.js.map +1 -0
- package/lib/types/activities/advanced/createDocumentTypeFromInteractionRun.d.ts +17 -0
- package/lib/types/activities/advanced/createDocumentTypeFromInteractionRun.d.ts.map +1 -0
- package/lib/types/activities/advanced/createOrUpdateDocumentFromInteractionRun.d.ts +29 -0
- package/lib/types/activities/advanced/createOrUpdateDocumentFromInteractionRun.d.ts.map +1 -0
- package/lib/types/activities/advanced/updateDocumentFromInteractionRun.d.ts +19 -0
- package/lib/types/activities/advanced/updateDocumentFromInteractionRun.d.ts.map +1 -0
- package/lib/types/activities/chunkDocument.d.ts +18 -0
- package/lib/types/activities/chunkDocument.d.ts.map +1 -0
- package/lib/types/activities/createDocumentFromOther.d.ts +21 -0
- package/lib/types/activities/createDocumentFromOther.d.ts.map +1 -0
- package/lib/types/activities/executeInteraction.d.ts +40 -0
- package/lib/types/activities/executeInteraction.d.ts.map +1 -0
- package/lib/types/activities/extractDocumentText.d.ts +9 -0
- package/lib/types/activities/extractDocumentText.d.ts.map +1 -0
- package/lib/types/activities/generateDocumentProperties.d.ts +32 -0
- package/lib/types/activities/generateDocumentProperties.d.ts.map +1 -0
- package/lib/types/activities/generateEmbeddings.d.ts +49 -0
- package/lib/types/activities/generateEmbeddings.d.ts.map +1 -0
- package/lib/types/activities/generateImageRendition.d.ts +17 -0
- package/lib/types/activities/generateImageRendition.d.ts.map +1 -0
- package/lib/types/activities/generateOrAssignContentType.d.ts +44 -0
- package/lib/types/activities/generateOrAssignContentType.d.ts.map +1 -0
- package/lib/types/activities/getObjectFromStore.d.ts +14 -0
- package/lib/types/activities/getObjectFromStore.d.ts.map +1 -0
- package/lib/types/activities/index.d.ts +21 -0
- package/lib/types/activities/index.d.ts.map +1 -0
- package/lib/types/activities/media/processPdfWithTextract.d.ts +26 -0
- package/lib/types/activities/media/processPdfWithTextract.d.ts.map +1 -0
- package/lib/types/activities/media/transcribeMediaWithGladia.d.ts +14 -0
- package/lib/types/activities/media/transcribeMediaWithGladia.d.ts.map +1 -0
- package/lib/types/activities/notifyWebhook.d.ts +17 -0
- package/lib/types/activities/notifyWebhook.d.ts.map +1 -0
- package/lib/types/activities/setDocumentStatus.d.ts +15 -0
- package/lib/types/activities/setDocumentStatus.d.ts.map +1 -0
- package/lib/types/conversion/TextractProcessor.d.ts +45 -0
- package/lib/types/conversion/TextractProcessor.d.ts.map +1 -0
- package/lib/types/conversion/image.d.ts +9 -0
- package/lib/types/conversion/image.d.ts.map +1 -0
- package/lib/types/conversion/mutool.d.ts +19 -0
- package/lib/types/conversion/mutool.d.ts.map +1 -0
- package/lib/types/conversion/pandoc.d.ts +2 -0
- package/lib/types/conversion/pandoc.d.ts.map +1 -0
- package/lib/types/conversion/pdf.d.ts +2 -0
- package/lib/types/conversion/pdf.d.ts.map +1 -0
- package/lib/types/dsl/conditions.d.ts +2 -0
- package/lib/types/dsl/conditions.d.ts.map +1 -0
- package/lib/types/dsl/dsl-workflow.d.ts +5 -0
- package/lib/types/dsl/dsl-workflow.d.ts.map +1 -0
- package/lib/types/dsl/projections.d.ts +4 -0
- package/lib/types/dsl/projections.d.ts.map +1 -0
- package/lib/types/dsl/setup/ActivityContext.d.ts +14 -0
- package/lib/types/dsl/setup/ActivityContext.d.ts.map +1 -0
- package/lib/types/dsl/setup/fetch/DataProvider.d.ts +9 -0
- package/lib/types/dsl/setup/fetch/DataProvider.d.ts.map +1 -0
- package/lib/types/dsl/setup/fetch/index.d.ts +6 -0
- package/lib/types/dsl/setup/fetch/index.d.ts.map +1 -0
- package/lib/types/dsl/setup/fetch/providers.d.ts +25 -0
- package/lib/types/dsl/setup/fetch/providers.d.ts.map +1 -0
- package/lib/types/dsl/test/test-child-workflow.d.ts +4 -0
- package/lib/types/dsl/test/test-child-workflow.d.ts.map +1 -0
- package/lib/types/dsl/validation.d.ts +4 -0
- package/lib/types/dsl/validation.d.ts.map +1 -0
- package/lib/types/dsl/vars.d.ts +48 -0
- package/lib/types/dsl/vars.d.ts.map +1 -0
- package/lib/types/dsl/walk.d.ts +18 -0
- package/lib/types/dsl/walk.d.ts.map +1 -0
- package/lib/types/errors.d.ts +16 -0
- package/lib/types/errors.d.ts.map +1 -0
- package/lib/types/index.d.ts +24 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/iterative-generation/activities/extractToc.d.ts +10 -0
- package/lib/types/iterative-generation/activities/extractToc.d.ts.map +1 -0
- package/lib/types/iterative-generation/activities/finalizeOutput.d.ts +3 -0
- package/lib/types/iterative-generation/activities/finalizeOutput.d.ts.map +1 -0
- package/lib/types/iterative-generation/activities/generatePart.d.ts +3 -0
- package/lib/types/iterative-generation/activities/generatePart.d.ts.map +1 -0
- package/lib/types/iterative-generation/activities/generateToc.d.ts +4 -0
- package/lib/types/iterative-generation/activities/generateToc.d.ts.map +1 -0
- package/lib/types/iterative-generation/activities/index.d.ts +5 -0
- package/lib/types/iterative-generation/activities/index.d.ts.map +1 -0
- package/lib/types/iterative-generation/iterativeGenerationWorkflow.d.ts +3 -0
- package/lib/types/iterative-generation/iterativeGenerationWorkflow.d.ts.map +1 -0
- package/lib/types/iterative-generation/types.d.ts +79 -0
- package/lib/types/iterative-generation/types.d.ts.map +1 -0
- package/lib/types/iterative-generation/utils.d.ts +27 -0
- package/lib/types/iterative-generation/utils.d.ts.map +1 -0
- package/lib/types/result-types.d.ts +22 -0
- package/lib/types/result-types.d.ts.map +1 -0
- package/lib/types/system/generateObjectText.d.ts +4 -0
- package/lib/types/system/generateObjectText.d.ts.map +1 -0
- package/lib/types/system/notifyWebhookWorkflow.d.ts +6 -0
- package/lib/types/system/notifyWebhookWorkflow.d.ts.map +1 -0
- package/lib/types/system/recalculateEmbeddingsWorkflow.d.ts +40 -0
- package/lib/types/system/recalculateEmbeddingsWorkflow.d.ts.map +1 -0
- package/lib/types/utils/auth.d.ts +4 -0
- package/lib/types/utils/auth.d.ts.map +1 -0
- package/lib/types/utils/blobs.d.ts +8 -0
- package/lib/types/utils/blobs.d.ts.map +1 -0
- package/lib/types/utils/client.d.ts +7 -0
- package/lib/types/utils/client.d.ts.map +1 -0
- package/lib/types/utils/expand-vars.d.ts +8 -0
- package/lib/types/utils/expand-vars.d.ts.map +1 -0
- package/lib/types/utils/memory.d.ts +12 -0
- package/lib/types/utils/memory.d.ts.map +1 -0
- package/lib/types/utils/tokens.d.ts +11 -0
- package/lib/types/utils/tokens.d.ts.map +1 -0
- package/lib/types/vars.d.ts +3 -0
- package/lib/types/vars.d.ts.map +1 -0
- package/lib/types/workflows.d.ts +9 -0
- package/lib/types/workflows.d.ts.map +1 -0
- package/lib/workflows-bundle.js +18394 -0
- package/package.json +109 -0
- package/src/activities/advanced/createDocumentTypeFromInteractionRun.ts +54 -0
- package/src/activities/advanced/createOrUpdateDocumentFromInteractionRun.ts +97 -0
- package/src/activities/advanced/updateDocumentFromInteractionRun.ts +34 -0
- package/src/activities/chunkDocument.ts +124 -0
- package/src/activities/createDocumentFromOther.ts +92 -0
- package/src/activities/executeInteraction.ts +191 -0
- package/src/activities/extractDocumentText.ts +174 -0
- package/src/activities/generateDocumentProperties.ts +93 -0
- package/src/activities/generateEmbeddings.ts +345 -0
- package/src/activities/generateImageRendition.ts +134 -0
- package/src/activities/generateOrAssignContentType.ts +152 -0
- package/src/activities/getObjectFromStore.ts +31 -0
- package/src/activities/index.ts +21 -0
- package/src/activities/media/processPdfWithTextract.ts +141 -0
- package/src/activities/media/transcribeMediaWithGladia.ts +83 -0
- package/src/activities/notifyWebhook.test.ts +32 -0
- package/src/activities/notifyWebhook.ts +51 -0
- package/src/activities/setDocumentStatus.ts +25 -0
- package/src/conversion/TextractProcessor.ts +505 -0
- package/src/conversion/image.test.ts +26 -0
- package/src/conversion/image.ts +22 -0
- package/src/conversion/mutool.test.ts +74 -0
- package/src/conversion/mutool.ts +180 -0
- package/src/conversion/pandoc.test.ts +22 -0
- package/src/conversion/pandoc.ts +44 -0
- package/src/conversion/pdf.test.ts +35 -0
- package/src/conversion/pdf.ts +8 -0
- package/src/dsl/conditions.ts +76 -0
- package/src/dsl/dsl-workflow.test.ts +58 -0
- package/src/dsl/dsl-workflow.ts +235 -0
- package/src/dsl/ms.d.ts +11 -0
- package/src/dsl/projections.test.ts +159 -0
- package/src/dsl/projections.ts +72 -0
- package/src/dsl/setup/ActivityContext.ts +106 -0
- package/src/dsl/setup/fetch/DataProvider.ts +45 -0
- package/src/dsl/setup/fetch/index.ts +19 -0
- package/src/dsl/setup/fetch/providers.ts +67 -0
- package/src/dsl/test/test-child-workflow.ts +6 -0
- package/src/dsl/validation.test.ts +257 -0
- package/src/dsl/validation.ts +125 -0
- package/src/dsl/vars.test.ts +245 -0
- package/src/dsl/vars.ts +340 -0
- package/src/dsl/walk.test.ts +81 -0
- package/src/dsl/walk.ts +103 -0
- package/src/dsl/workflow-exec-child.test.ts +182 -0
- package/src/dsl/workflow-fetch.test.ts +135 -0
- package/src/dsl/workflow-import.test.ts +89 -0
- package/src/dsl/workflow.test.ts +110 -0
- package/src/errors.ts +24 -0
- package/src/index.ts +27 -0
- package/src/iterative-generation/activities/extractToc.ts +49 -0
- package/src/iterative-generation/activities/finalizeOutput.ts +77 -0
- package/src/iterative-generation/activities/generatePart.ts +82 -0
- package/src/iterative-generation/activities/generateToc.ts +98 -0
- package/src/iterative-generation/activities/index.ts +4 -0
- package/src/iterative-generation/iterativeGenerationWorkflow.ts +67 -0
- package/src/iterative-generation/types.ts +99 -0
- package/src/iterative-generation/utils.ts +123 -0
- package/src/result-types.ts +25 -0
- package/src/system/generateObjectText.ts +109 -0
- package/src/system/notifyWebhookWorkflow.ts +64 -0
- package/src/system/recalculateEmbeddingsWorkflow.ts +46 -0
- package/src/utils/auth.ts +10 -0
- package/src/utils/blobs.ts +58 -0
- package/src/utils/client.ts +31 -0
- package/src/utils/expand-vars.ts +31 -0
- package/src/utils/memory.ts +66 -0
- package/src/utils/tokens.ts +44 -0
- package/src/vars.ts +3 -0
- package/src/workflows.ts +9 -0
@@ -0,0 +1,191 @@
|
|
1
|
+
import { ComposableClient } from "@vertesia/client";
|
2
|
+
import { DSLActivityExecutionPayload, DSLActivitySpec, ExecutionRun, ExecutionRunStatus, InteractionExecutionConfiguration, RunSearchPayload } from "@vertesia/common";
|
3
|
+
import { activityInfo, log } from "@temporalio/activity";
|
4
|
+
import { projectResult } from "../dsl/projections.js";
|
5
|
+
import { setupActivity } from "../dsl/setup/ActivityContext.js";
|
6
|
+
import { TruncateSpec, truncByMaxTokens } from "../utils/tokens.js";
|
7
|
+
import { ModelOptions } from "@llumiverse/core";
|
8
|
+
|
9
|
+
//Example:
|
10
|
+
//@ts-ignore
|
11
|
+
const JSON: DSLActivitySpec = {
|
12
|
+
name: 'executeInteraction',
|
13
|
+
import: ["defaultModel", "guidlineId", "docTypeId"],
|
14
|
+
params: {
|
15
|
+
defaultModel: "${model}",
|
16
|
+
interactionName: "GenerateSummary",
|
17
|
+
model: "${defaultModel ?? 'gpt4'}",
|
18
|
+
environment: "13456",
|
19
|
+
max_tokens: 100,
|
20
|
+
temperature: 0.5,
|
21
|
+
tags: ["test"],
|
22
|
+
result_schema: "${docType.object_schema}",
|
23
|
+
prompt_data: {
|
24
|
+
documents: "${documents}",
|
25
|
+
guidline: "${guidline.text}"
|
26
|
+
}
|
27
|
+
},
|
28
|
+
fetch: {
|
29
|
+
documents: {
|
30
|
+
type: "document",
|
31
|
+
query: {
|
32
|
+
id: { $in: "${objectIds}" },
|
33
|
+
},
|
34
|
+
select: "+text",
|
35
|
+
},
|
36
|
+
guidline: {
|
37
|
+
type: "document",
|
38
|
+
limit: 1,
|
39
|
+
query: {
|
40
|
+
id: "${guidlineId}",
|
41
|
+
},
|
42
|
+
select: "+text",
|
43
|
+
on_not_found: "throw"
|
44
|
+
},
|
45
|
+
docType: {
|
46
|
+
type: "document_type",
|
47
|
+
limit: 1,
|
48
|
+
query: {
|
49
|
+
id: "${docTypeId}",
|
50
|
+
},
|
51
|
+
select: "+object_schema",
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
export interface InteractionExecutionParams extends ModelOptions{
|
57
|
+
/**
|
58
|
+
* The environment to use. If not specified the project default environment will be used.
|
59
|
+
* If the latter is not specified an exeption will be thrown.
|
60
|
+
*/
|
61
|
+
environment?: string;
|
62
|
+
/**
|
63
|
+
* The model to use. If not specified the project default model will be used.
|
64
|
+
* If the latter is not specified the default model of the environment will be used.
|
65
|
+
* If the latter is not specified an exeption will be thrown.
|
66
|
+
*/
|
67
|
+
model?: string;
|
68
|
+
|
69
|
+
/**
|
70
|
+
* Force a JSON schema for the result
|
71
|
+
*/
|
72
|
+
result_schema?: any;
|
73
|
+
|
74
|
+
/**
|
75
|
+
* Tags to add to the execution run
|
76
|
+
*/
|
77
|
+
tags?: string[];
|
78
|
+
|
79
|
+
/**
|
80
|
+
* Wether or not to include the previous error in the interaction prompt data
|
81
|
+
*/
|
82
|
+
include_previous_error?: boolean;
|
83
|
+
}
|
84
|
+
|
85
|
+
|
86
|
+
export interface ExecuteInteractionParams extends InteractionExecutionParams {
|
87
|
+
interactionName: string;
|
88
|
+
prompt_data: Record<string, any>;
|
89
|
+
truncate?: Record<string, TruncateSpec>
|
90
|
+
}
|
91
|
+
|
92
|
+
export interface ExecuteInteraction extends DSLActivitySpec<ExecuteInteractionParams> {
|
93
|
+
name: 'executeInteraction';
|
94
|
+
}
|
95
|
+
|
96
|
+
export async function executeInteraction(payload: DSLActivityExecutionPayload) {
|
97
|
+
const {
|
98
|
+
client, params
|
99
|
+
} = await setupActivity<ExecuteInteractionParams>(payload);
|
100
|
+
|
101
|
+
const { interactionName, prompt_data } = params;
|
102
|
+
|
103
|
+
if (params.truncate) {
|
104
|
+
const truncate = params.truncate;
|
105
|
+
for (const [key, value] of Object.entries(truncate)) {
|
106
|
+
prompt_data[key] = truncByMaxTokens(prompt_data[key], value);
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
const res = await executeInteractionFromActivity(client, interactionName, params, prompt_data, payload.debug_mode);
|
111
|
+
|
112
|
+
return projectResult(payload, params, res, {
|
113
|
+
runId: res.id,
|
114
|
+
status: res.status,
|
115
|
+
result: res.result,
|
116
|
+
});
|
117
|
+
|
118
|
+
}
|
119
|
+
|
120
|
+
export async function executeInteractionFromActivity(client: ComposableClient, interactionName: string, params: InteractionExecutionParams, prompt_data: any, debug?: boolean) {
|
121
|
+
const userTags = params.tags;
|
122
|
+
const info = activityInfo();
|
123
|
+
const runId = info.workflowExecution.runId;
|
124
|
+
let tags = ["workflow", `tmpRunId:${runId}`]; //TODO use wf:wfName
|
125
|
+
if (userTags) {
|
126
|
+
tags = tags.concat(userTags);
|
127
|
+
}
|
128
|
+
|
129
|
+
let previousStudioExecutionRun: ExecutionRun | undefined = undefined;
|
130
|
+
if (params.include_previous_error) {
|
131
|
+
//retrieve last failed run if any
|
132
|
+
if (info.attempt > 1) {
|
133
|
+
log.info("Retrying, searching for previous run", { tags: ["tmpRunId:" + runId] });
|
134
|
+
const payload: RunSearchPayload = {
|
135
|
+
query: { tags: ["tmpRunId:" + info.workflowExecution.runId] },
|
136
|
+
limit: 1,
|
137
|
+
};
|
138
|
+
const previousRun = await client.runs.search(payload).then((res) => {
|
139
|
+
log.info("Search results", { results: res });
|
140
|
+
return res ? res[0] ?? undefined : undefined
|
141
|
+
});
|
142
|
+
|
143
|
+
if (previousRun) {
|
144
|
+
log.info("Found previous run", { previousRun });
|
145
|
+
previousStudioExecutionRun = await client.runs.retrieve(previousRun.id);
|
146
|
+
}
|
147
|
+
}
|
148
|
+
}
|
149
|
+
if (debug && previousStudioExecutionRun?.error) {
|
150
|
+
log.info(`Found previous run error`, { error: previousStudioExecutionRun?.error });
|
151
|
+
}
|
152
|
+
|
153
|
+
const config: InteractionExecutionConfiguration = {
|
154
|
+
environment: params.environment,
|
155
|
+
model: params.model,
|
156
|
+
max_tokens: params.max_tokens,
|
157
|
+
temperature: params.temperature
|
158
|
+
}
|
159
|
+
const data = {
|
160
|
+
...prompt_data,
|
161
|
+
previous_error: previousStudioExecutionRun?.error,
|
162
|
+
}
|
163
|
+
|
164
|
+
const result_schema = params.result_schema;
|
165
|
+
|
166
|
+
if (debug) {
|
167
|
+
log.info(`About to execute interaction ${interactionName}`, { config, data, result_schema, tags });
|
168
|
+
}
|
169
|
+
|
170
|
+
const res = await client.interactions.executeByName(interactionName, {
|
171
|
+
config,
|
172
|
+
data,
|
173
|
+
result_schema,
|
174
|
+
tags,
|
175
|
+
stream: false,
|
176
|
+
}).catch((err) => {
|
177
|
+
log.error(`Error executing interaction ${interactionName}`, { err });
|
178
|
+
throw new Error(`Interaction Execution failed ${interactionName}: ${err.message}`);
|
179
|
+
});
|
180
|
+
|
181
|
+
if (debug) {
|
182
|
+
log.info(`Interaction executed ${interactionName}`, res);
|
183
|
+
}
|
184
|
+
|
185
|
+
if (res.error || res.status === ExecutionRunStatus.failed) {
|
186
|
+
log.error(`Error executing interaction ${interactionName}`, { error: res.error });
|
187
|
+
throw new Error(`Interaction Execution failed ${interactionName}: ${res.error}`);
|
188
|
+
}
|
189
|
+
|
190
|
+
return res;
|
191
|
+
}
|
@@ -0,0 +1,174 @@
|
|
1
|
+
import { ContentObject, CreateContentObjectPayload, DSLActivityExecutionPayload, DSLActivitySpec } from '@vertesia/common';
|
2
|
+
import { log } from "@temporalio/activity";
|
3
|
+
import { mutoolPdfToText } from '../conversion/mutool.js';
|
4
|
+
import { manyToMarkdown } from '../conversion/pandoc.js';
|
5
|
+
import { trasformPdfToMarkdown } from '../conversion/pdf.js';
|
6
|
+
import { setupActivity } from "../dsl/setup/ActivityContext.js";
|
7
|
+
import { NoDocumentFound } from '../errors.js';
|
8
|
+
import { TextExtractionResult, TextExtractionStatus } from '../result-types.js';
|
9
|
+
import { fetchBlobAsBuffer, md5 } from '../utils/blobs.js';
|
10
|
+
import { countTokens } from '../utils/tokens.js';
|
11
|
+
|
12
|
+
//@ts-ignore
|
13
|
+
const JSON: DSLActivitySpec = {
|
14
|
+
name: 'extractDocumentText',
|
15
|
+
}
|
16
|
+
|
17
|
+
// doesn't have any own param
|
18
|
+
export type ExtractDocumentTextParams = never;
|
19
|
+
|
20
|
+
export interface ExtractDocumentText extends DSLActivitySpec<ExtractDocumentTextParams> {
|
21
|
+
name: 'extractDocumentText';
|
22
|
+
projection?: never;
|
23
|
+
}
|
24
|
+
|
25
|
+
export async function extractDocumentText(payload: DSLActivityExecutionPayload): Promise<TextExtractionResult> {
|
26
|
+
const { client, objectId } = await setupActivity(payload);
|
27
|
+
|
28
|
+
const r = await client.objects.find({
|
29
|
+
query: { _id: objectId },
|
30
|
+
limit: 1,
|
31
|
+
select: "+text"
|
32
|
+
})
|
33
|
+
const doc = r[0] as ContentObject;
|
34
|
+
if (!doc) {
|
35
|
+
log.error(`Document ${objectId} not found`);
|
36
|
+
throw new NoDocumentFound(`Document ${objectId} not found`, payload.objectIds);
|
37
|
+
}
|
38
|
+
|
39
|
+
log.info(`Extracting text for object ${doc.id}`);
|
40
|
+
|
41
|
+
|
42
|
+
if (!doc.content?.type || !doc.content?.source) {
|
43
|
+
if (doc.text) {
|
44
|
+
return createResponse(doc, doc.text, TextExtractionStatus.skipped, "Text present and no source or type");
|
45
|
+
} else {
|
46
|
+
return createResponse(doc, "", TextExtractionStatus.error, "No source or type found");
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
//skip if text already extracted and proper etag
|
51
|
+
if (doc.text && doc.text.length > 0 && doc.text_etag === doc.content.etag) {
|
52
|
+
return createResponse(doc, doc.text, TextExtractionStatus.skipped, "Text already extracted");
|
53
|
+
}
|
54
|
+
|
55
|
+
let fileBuffer: Buffer;
|
56
|
+
try {
|
57
|
+
fileBuffer = await fetchBlobAsBuffer(client, doc.content.source);
|
58
|
+
} catch (e: any) {
|
59
|
+
log.error(`Error reading file: ${e}`);
|
60
|
+
return createResponse(doc, "", TextExtractionStatus.error, e.message);
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
let txt: string;
|
65
|
+
|
66
|
+
switch (doc.content.type) {
|
67
|
+
|
68
|
+
case 'application/pdf':
|
69
|
+
//if pdf is more than 2MB, use mutool
|
70
|
+
if (fileBuffer.length > 2 * 1024 * 1024) {
|
71
|
+
txt = await mutoolPdfToText(fileBuffer);
|
72
|
+
} else {
|
73
|
+
txt = await trasformPdfToMarkdown(fileBuffer);
|
74
|
+
}
|
75
|
+
break;
|
76
|
+
|
77
|
+
case 'text/plain':
|
78
|
+
txt = fileBuffer.toString('utf8')
|
79
|
+
break;
|
80
|
+
|
81
|
+
//docx
|
82
|
+
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
|
83
|
+
txt = await manyToMarkdown(fileBuffer, 'docx');
|
84
|
+
break;
|
85
|
+
|
86
|
+
//html
|
87
|
+
case 'text/html':
|
88
|
+
txt = await manyToMarkdown(fileBuffer, 'html');
|
89
|
+
break;
|
90
|
+
|
91
|
+
//opendocument
|
92
|
+
case 'application/vnd.oasis.opendocument.text':
|
93
|
+
txt = await manyToMarkdown(fileBuffer, 'odt');
|
94
|
+
break;
|
95
|
+
|
96
|
+
//rtf
|
97
|
+
case 'application/rtf':
|
98
|
+
txt = await manyToMarkdown(fileBuffer, 'rtf');
|
99
|
+
break;
|
100
|
+
|
101
|
+
//markdown
|
102
|
+
case 'text/markdown':
|
103
|
+
txt = fileBuffer.toString('utf8');
|
104
|
+
break;
|
105
|
+
|
106
|
+
//csv
|
107
|
+
case 'text/csv':
|
108
|
+
txt = fileBuffer.toString('utf8');
|
109
|
+
break;
|
110
|
+
|
111
|
+
//typescript
|
112
|
+
case 'application/typescript':
|
113
|
+
txt = fileBuffer.toString('utf8');
|
114
|
+
break;
|
115
|
+
|
116
|
+
//javascript
|
117
|
+
case 'application/javascript':
|
118
|
+
txt = fileBuffer.toString('utf8');
|
119
|
+
break;
|
120
|
+
|
121
|
+
//json
|
122
|
+
case 'application/json':
|
123
|
+
txt = fileBuffer.toString('utf8');
|
124
|
+
break;
|
125
|
+
|
126
|
+
default:
|
127
|
+
if (sniffIfText(fileBuffer)) {
|
128
|
+
txt = fileBuffer.toString('utf8'); //TODO: add charset detection
|
129
|
+
break;
|
130
|
+
}
|
131
|
+
return createResponse(doc, doc.text ?? '', TextExtractionStatus.skipped, `Unsupported mime type: ${doc.content.type}`);
|
132
|
+
}
|
133
|
+
|
134
|
+
|
135
|
+
const tokensData = countTokens(txt);
|
136
|
+
const etag = doc.content.etag ?? md5(txt);
|
137
|
+
|
138
|
+
const updateData: CreateContentObjectPayload = {
|
139
|
+
text: txt,
|
140
|
+
text_etag: etag,
|
141
|
+
tokens: {
|
142
|
+
...tokensData,
|
143
|
+
etag: etag,
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
await client.objects.update(doc.id, updateData);
|
148
|
+
|
149
|
+
return createResponse(doc, txt, TextExtractionStatus.success);
|
150
|
+
}
|
151
|
+
|
152
|
+
function createResponse(doc: ContentObject, text: string, status: TextExtractionStatus, message?: string): TextExtractionResult {
|
153
|
+
return {
|
154
|
+
status,
|
155
|
+
message,
|
156
|
+
tokens: doc.tokens,
|
157
|
+
len: text.length,
|
158
|
+
objectId: doc.id,
|
159
|
+
hasText: !!text,
|
160
|
+
}
|
161
|
+
|
162
|
+
}
|
163
|
+
|
164
|
+
|
165
|
+
//if file is less than 100KB, check if it looks like text
|
166
|
+
function sniffIfText(buf: Buffer) {
|
167
|
+
if (buf.length < 100 * 1024) {
|
168
|
+
const s = buf.toString('utf8');
|
169
|
+
if (s.length > 0) {
|
170
|
+
return true;
|
171
|
+
}
|
172
|
+
}
|
173
|
+
return false;
|
174
|
+
}
|
@@ -0,0 +1,93 @@
|
|
1
|
+
import { DSLActivityExecutionPayload, DSLActivitySpec } from "@vertesia/common";
|
2
|
+
import { log } from "@temporalio/activity";
|
3
|
+
import { setupActivity } from "../dsl/setup/ActivityContext.js";
|
4
|
+
import { TruncateSpec } from "../utils/tokens.js";
|
5
|
+
import { InteractionExecutionParams, executeInteractionFromActivity } from "./executeInteraction.js";
|
6
|
+
|
7
|
+
const INT_EXTRACT_INFORMATION = "sys:ExtractInformation"
|
8
|
+
export interface GenerateDocumentPropertiesParams extends InteractionExecutionParams {
|
9
|
+
typesHint?: string[];
|
10
|
+
/**
|
11
|
+
* truncate the input doc text to the specified max_tokens
|
12
|
+
*/
|
13
|
+
truncate?: TruncateSpec;
|
14
|
+
|
15
|
+
interactionName?: string;
|
16
|
+
|
17
|
+
use_vision?: boolean;
|
18
|
+
}
|
19
|
+
export interface GenerateDocumentProperties extends DSLActivitySpec<GenerateDocumentPropertiesParams> {
|
20
|
+
name: 'generateDocumentProperties';
|
21
|
+
}
|
22
|
+
|
23
|
+
export async function generateDocumentProperties(payload: DSLActivityExecutionPayload) {
|
24
|
+
const context = await setupActivity<GenerateDocumentPropertiesParams>(payload);
|
25
|
+
const { params, client, objectId } = context;
|
26
|
+
const interactionName = params.interactionName ?? INT_EXTRACT_INFORMATION;
|
27
|
+
|
28
|
+
const project = await context.fetchProject();
|
29
|
+
|
30
|
+
const doc = await client.objects.retrieve(objectId, "+text");
|
31
|
+
const type = doc.type ? await client.types.retrieve(doc.type.id) : undefined;
|
32
|
+
|
33
|
+
if (!doc?.text && !params.use_vision && !doc?.content?.type?.startsWith("image/")) {
|
34
|
+
log.warn(`Object ${objectId} not found or text is empty`);
|
35
|
+
return { status: "failed", error: "no-text" }
|
36
|
+
}
|
37
|
+
|
38
|
+
if (!type || !type.object_schema) {
|
39
|
+
log.info(`Object ${objectId} has no schema`);
|
40
|
+
return { document: objectId, status: "skipped", message: "no schema defined on type" };
|
41
|
+
}
|
42
|
+
|
43
|
+
const getImageRef = () => {
|
44
|
+
if (doc.content?.type?.startsWith("image/")) {
|
45
|
+
return "store:" + doc.id;
|
46
|
+
}
|
47
|
+
|
48
|
+
if (params.use_vision && doc.content?.type?.startsWith("application/pdf")) {
|
49
|
+
return "store:" + doc.id;
|
50
|
+
}
|
51
|
+
|
52
|
+
log.info(`Object ${objectId} is not an image or pdf`);
|
53
|
+
return undefined
|
54
|
+
}
|
55
|
+
|
56
|
+
const promptData = {
|
57
|
+
content: doc.text ?? undefined,
|
58
|
+
image: getImageRef() ?? undefined,
|
59
|
+
human_context: project?.configuration?.human_context ?? undefined,
|
60
|
+
}
|
61
|
+
|
62
|
+
log.info(` Extracting information from object ${objectId} with type ${type.name}`, payload.debug_mode ? { params, } : undefined);
|
63
|
+
|
64
|
+
const infoRes = await executeInteractionFromActivity(
|
65
|
+
client,
|
66
|
+
interactionName,
|
67
|
+
{
|
68
|
+
...params,
|
69
|
+
include_previous_error: true,
|
70
|
+
result_schema: type.object_schema,
|
71
|
+
},
|
72
|
+
promptData,
|
73
|
+
payload.debug_mode ?? false
|
74
|
+
);
|
75
|
+
|
76
|
+
log.info(`Extracted information from object ${objectId} with type ${type.name}`, { runId: infoRes.id });
|
77
|
+
await client.objects.update(doc.id, {
|
78
|
+
properties: {
|
79
|
+
...infoRes.result,
|
80
|
+
etag: doc.text_etag
|
81
|
+
},
|
82
|
+
text: infoRes.result.description ?? undefined,
|
83
|
+
generation_run_info: {
|
84
|
+
id: infoRes.id,
|
85
|
+
date: new Date().toISOString(),
|
86
|
+
model: infoRes.modelId,
|
87
|
+
}
|
88
|
+
});
|
89
|
+
|
90
|
+
|
91
|
+
return { status: "completed" };
|
92
|
+
|
93
|
+
}
|