11import { BaseEndpoint , EndpointResponse } from "./baseEndpoint" ;
22import { ApiSettings } from "./apiSettings" ;
3- import { InputSource } from "../input" ;
3+ import { InputSource , LocalInputSource } from "../input" ;
44import { URLSearchParams } from "url" ;
55import FormData from "form-data" ;
6- import { LocalInputSource } from "../input" ;
76import { RequestOptions } from "https" ;
87import { isValidSyncResponse } from "./responseValidation" ;
98import { handleError } from "./error" ;
@@ -35,13 +34,7 @@ export class WorkflowEndpoint extends BaseEndpoint {
3534 if ( params . pageOptions !== undefined ) {
3635 await super . cutDocPages ( params . inputDoc , params . pageOptions ) ;
3736 }
38- const response = await this . #workflowReqPost(
39- params . inputDoc ,
40- params . alias ,
41- params . priority ,
42- params . fullText ,
43- params . publicUrl
44- ) ;
37+ const response = await this . #workflowReqPost( params ) ;
4538 if ( ! isValidSyncResponse ( response ) ) {
4639 handleError ( this . urlRoot , response , response . messageObj ?. statusMessage ) ;
4740 }
@@ -51,20 +44,18 @@ export class WorkflowEndpoint extends BaseEndpoint {
5144
5245 /**
5346 * Make a request to POST a document for workflow.
54- * @param input Input document.
55- * @param alias Alias for the document.
56- * @param priority Priority for the document.
57- * @param fullText Whether to include the fulltext in the response.
58- * @param publicUrl Optional verification Url.
47+ *
48+ * @param {WorkflowParams } params parameters relating to prediction options.
5949 */
60- #workflowReqPost(
61- input : InputSource ,
62- alias : string | null = null ,
63- priority : ExecutionPriority | null = null ,
64- fullText : boolean = false ,
65- publicUrl : string | null = null
66- ) : Promise < EndpointResponse > {
67- return this . sendFileForPrediction ( input , alias , priority , fullText , publicUrl ) ;
50+ #workflowReqPost( params : WorkflowParams ) : Promise < EndpointResponse > {
51+ return this . sendFileForPrediction (
52+ params . inputDoc ,
53+ params . alias ,
54+ params . priority ,
55+ params . fullText ,
56+ params . publicUrl ,
57+ params . rag
58+ ) ;
6859 }
6960
7061 /**
@@ -81,6 +72,7 @@ export class WorkflowEndpoint extends BaseEndpoint {
8172 priority : ExecutionPriority | null = null ,
8273 fullText : boolean = false ,
8374 publicUrl : string | null = null ,
75+ rag : boolean | null = null ,
8476 ) : Promise < EndpointResponse > {
8577 return new Promise ( ( resolve , reject ) => {
8678 const searchParams = new URLSearchParams ( ) ;
@@ -89,6 +81,10 @@ export class WorkflowEndpoint extends BaseEndpoint {
8981 searchParams . append ( "full_text_ocr" , "true" ) ;
9082 }
9183
84+ if ( rag ) {
85+ searchParams . append ( "rag" , "true" ) ;
86+ }
87+
9288 const form = new FormData ( ) ;
9389 if ( input instanceof LocalInputSource && input . fileObject instanceof Buffer ) {
9490 form . append ( "document" , input . fileObject , {
0 commit comments