mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-06-04 11:14:10 +08:00
feat: add workflow api in Node.js sdk (#3584)
This commit is contained in:
parent
c2acb2be60
commit
80e390b906
@ -37,7 +37,11 @@ export const routes = {
|
|||||||
fileUpload: {
|
fileUpload: {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: () => `/files/upload`,
|
url: () => `/files/upload`,
|
||||||
}
|
},
|
||||||
|
runWorkflow: {
|
||||||
|
method: "POST",
|
||||||
|
url: () => `/workflows/run`,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export class DifyClient {
|
export class DifyClient {
|
||||||
@ -143,6 +147,21 @@ export class CompletionClient extends DifyClient {
|
|||||||
stream
|
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 {
|
export class ChatClient extends DifyClient {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dify-client",
|
"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.",
|
"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",
|
"main": "index.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user