From ff39a67cdd86653ace9ade0700d01a70aecb4ecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Tue, 27 May 2025 12:24:52 +0200 Subject: [PATCH] :memo: add RAG sample code for OTS products --- docs/code_samples/workflow_ots_rag.txt | 32 ++++++++++++++++++++++++++ docs/code_samples/workflow_polling.txt | 5 ++-- 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 docs/code_samples/workflow_ots_rag.txt diff --git a/docs/code_samples/workflow_ots_rag.txt b/docs/code_samples/workflow_ots_rag.txt new file mode 100644 index 000000000..782b89dc7 --- /dev/null +++ b/docs/code_samples/workflow_ots_rag.txt @@ -0,0 +1,32 @@ +const mindee = require("mindee"); +// for TS or modules: +// import * as mindee from "mindee"; + +const workflowId: string = "workflow-id"; + +// Init a new client +const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); + +// Load a file from disk +const inputSource = mindeeClient.docFromPath( + "/path/to/the/file.ext" +); + +// Configure the RAG-enabled workflow +const workflowParams = { + rag: true, + workflowId: workflowId +}; + +// Parse the file asynchronously on a workflow queue +const asyncApiResponse = mindeeClient.enqueueAndParse( + mindee.product.FinancialDocumentV1, + inputSource, + workflowParams +); + +// Handle the response Promise +asyncApiResponse.then((resp) => { + // print a string summary + console.log(resp.document?.toString()); +}); diff --git a/docs/code_samples/workflow_polling.txt b/docs/code_samples/workflow_polling.txt index e0e01cfaa..81cb0883b 100644 --- a/docs/code_samples/workflow_polling.txt +++ b/docs/code_samples/workflow_polling.txt @@ -18,6 +18,7 @@ const customEndpoint = mindeeClient.createEndpoint( "my-version" // Defaults to "1" ); +// Configure the RAG-enabled workflow const workflowParams = { rag: true, workflowId: workflowId, @@ -29,12 +30,10 @@ const asyncApiResponse = mindeeClient.enqueueAndParse( mindee.product.GeneratedV1, inputSource, workflowParams - // Optionally: send an alias & priority - // { alias: "my-alias", priority: ExecutionPriority.low } ); // Handle the response Promise asyncApiResponse.then((resp) => { // print a string summary console.log(resp.document?.toString()); -}); \ No newline at end of file +});