Skip to content

Commit 501c121

Browse files
authored
[Components] undetectable_ai #12425 (#13135)
* Added actions * Requested changes done
1 parent 4090039 commit 501c121

File tree

7 files changed

+224
-7
lines changed

7 files changed

+224
-7
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import app from "../../undetectable_ai.app.mjs";
2+
3+
export default {
4+
key: "undetectable_ai-list-documents",
5+
name: "List Documents",
6+
description: "Retrieve the IDs of documents associated with your account. [See the documentation](https://docs.undetectable.ai/#list-documents)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
page: {
12+
propDefinition: [
13+
app,
14+
"page",
15+
],
16+
optional: true,
17+
},
18+
},
19+
async run({ $ }) {
20+
const response = await this.app.listDocuments({
21+
$,
22+
data: {
23+
page: this.page,
24+
},
25+
});
26+
27+
$.export("$summary", `Successfully retrieved '${response.documents.length}' documents`);
28+
29+
return response;
30+
},
31+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import app from "../../undetectable_ai.app.mjs";
2+
3+
export default {
4+
key: "undetectable_ai-retrieve-document",
5+
name: "Retrieve Document",
6+
description: "Retrieve the document object for a submitted piece of content. [See the documentation](https://docs.undetectable.ai/#retrieve-document)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
id: {
12+
propDefinition: [
13+
app,
14+
"id",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.app.retrieveDocument({
20+
$,
21+
data: {
22+
id: this.id,
23+
},
24+
});
25+
26+
$.export("$summary", `Successfully retrieved document with ID '${response.id}'`);
27+
28+
return response;
29+
},
30+
};
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import app from "../../undetectable_ai.app.mjs";
2+
3+
export default {
4+
key: "undetectable_ai-submit-document",
5+
name: "Submit Document",
6+
description: "Submit document for humanization. [See the documentation](https://docs.undetectable.ai/#submit-document)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
content: {
12+
propDefinition: [
13+
app,
14+
"content",
15+
],
16+
},
17+
readability: {
18+
propDefinition: [
19+
app,
20+
"readability",
21+
],
22+
},
23+
purpose: {
24+
propDefinition: [
25+
app,
26+
"purpose",
27+
],
28+
},
29+
strength: {
30+
propDefinition: [
31+
app,
32+
"strength",
33+
],
34+
},
35+
},
36+
async run({ $ }) {
37+
const response = await this.app.submitDocument({
38+
$,
39+
data: {
40+
content: this.content,
41+
readability: this.readability,
42+
purpose: this.purpose,
43+
strength: this.strength,
44+
},
45+
});
46+
47+
$.export("$summary", `Successfully submited document for humanization. ID: '${response.id}'`);
48+
49+
return response;
50+
},
51+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export default {
2+
PURPOSE_OPTIONS: [
3+
"General Writing",
4+
"Essay",
5+
"Article",
6+
"Marketing Material",
7+
"Story",
8+
"Cover Letter",
9+
"Report",
10+
"Business Material",
11+
"Legal Material",
12+
],
13+
READABILITY_OPTIONS: [
14+
"High School",
15+
"University",
16+
"Doctorate",
17+
"Journalist",
18+
"Marketing",
19+
],
20+
STRENGTH_OPTIONS: [
21+
"Quality",
22+
"Balanced",
23+
"More Human",
24+
],
25+
};

components/undetectable_ai/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/undetectable_ai",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Undetectable AI Components",
55
"main": "undetectable_ai.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.0"
1417
}
15-
}
18+
}
Lines changed: 78 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,85 @@
1+
import { axios } from "@pipedream/platform";
2+
import constants from "./common/constants.mjs";
3+
14
export default {
25
type: "app",
36
app: "undetectable_ai",
4-
propDefinitions: {},
7+
propDefinitions: {
8+
content: {
9+
type: "string",
10+
label: "Content",
11+
description: "The document you want to humanize. Minimum 50 characters, maximum 15,000 characters",
12+
},
13+
readability: {
14+
type: "string",
15+
label: "Readability",
16+
description: "Readability of the humanized document",
17+
options: constants.READABILITY_OPTIONS,
18+
},
19+
purpose: {
20+
type: "string",
21+
label: "Purpose",
22+
description: "Purpose of the humanized document",
23+
options: constants.PURPOSE_OPTIONS,
24+
},
25+
strength: {
26+
type: "string",
27+
label: "Strength",
28+
description: "Increases aggressiveness of humanization algorithms",
29+
optional: true,
30+
options: constants.STRENGTH_OPTIONS,
31+
},
32+
id: {
33+
type: "string",
34+
label: "Document ID",
35+
description: "The ID of the document object submitted for humanization",
36+
},
37+
page: {
38+
type: "string",
39+
label: "Page",
40+
description: "The page number for pagination. Starts at 0. Each page contains upto 250 documents",
41+
},
42+
},
543
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
44+
_baseUrl() {
45+
return "https://api.undetectable.ai";
46+
},
47+
async _makeRequest(opts = {}) {
48+
const {
49+
$ = this,
50+
path,
51+
headers,
52+
...otherOpts
53+
} = opts;
54+
return axios($, {
55+
...otherOpts,
56+
url: this._baseUrl() + path,
57+
headers: {
58+
...headers,
59+
"api-key": `${this.$auth.api_key}`,
60+
},
61+
});
62+
},
63+
async submitDocument(args = {}) {
64+
return this._makeRequest({
65+
method: "post",
66+
path: "/submit",
67+
...args,
68+
});
69+
},
70+
async retrieveDocument(args = {}) {
71+
return this._makeRequest({
72+
method: "post",
73+
path: "/document",
74+
...args,
75+
});
76+
},
77+
async listDocuments(args = {}) {
78+
return this._makeRequest({
79+
method: "post",
80+
path: "/list",
81+
...args,
82+
});
983
},
1084
},
1185
};

pnpm-lock.yaml

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)