Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add workflow api in Node.js sdk #3584

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion sdks/nodejs-client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ export const routes = {
fileUpload: {
method: "POST",
url: () => `/files/upload`,
}
},
runWorkflow: {
method: "POST",
url: () => `/workflows/run`,
},
};

export class DifyClient {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion sdks/nodejs-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dify-client",
"version": "2.2.1",
"version": "2.3.1",
"description": "This is the Node.js SDK for the Dify.AI API, which allows you to easily integrate Dify.AI into your Node.js applications.",
"main": "index.js",
"type": "module",
Expand Down
Loading