|
@@ -37,7 +37,11 @@ export const routes = {
|
|
|
fileUpload: {
|
|
|
method: "POST",
|
|
|
url: () => `/files/upload`,
|
|
|
- }
|
|
|
+ },
|
|
|
+ runWorkflow: {
|
|
|
+ method: "POST",
|
|
|
+ url: () => `/workflows/run`,
|
|
|
+ },
|
|
|
};
|
|
|
|
|
|
export class DifyClient {
|
|
@@ -143,6 +147,21 @@ export class CompletionClient extends DifyClient {
|
|
|
stream
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+ runWorkflow(inputs, user, stream = false, files = null) {
|
|
|
+ const data = {
|
|
|
+ inputs,
|
|
|
+ user,
|
|
|
+ response_mode: stream ? "streaming" : "blocking",
|
|
|
+ };
|
|
|
+ return this.sendRequest(
|
|
|
+ routes.runWorkflow.method,
|
|
|
+ routes.runWorkflow.url(),
|
|
|
+ data,
|
|
|
+ null,
|
|
|
+ stream
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
export class ChatClient extends DifyClient {
|