Skip to content

Commit 865a571

Browse files
committed
[Components] tldr #14496
Actions - Summarize Text
1 parent 442e171 commit 865a571

File tree

3 files changed

+36
-61
lines changed

3 files changed

+36
-61
lines changed

components/tldr/actions/summarize-text/summarize-text.mjs

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,37 @@ export default {
44
key: "tldr-summarize-text",
55
name: "Summarize Text",
66
description: "Reads in a piece of text and distills the main points. [See the documentation](https://runtldr.com/documentation)",
7-
version: "0.0.{{ts}}",
7+
version: "0.0.1",
88
type: "action",
99
props: {
1010
tldr,
1111
inputText: {
12-
propDefinition: [
13-
tldr,
14-
"inputText",
15-
],
12+
type: "string",
13+
label: "Text to Summarize",
14+
description: "The text that needs to be summarized.",
1615
},
1716
responseStyle: {
18-
propDefinition: [
19-
tldr,
20-
"responseStyle",
21-
],
17+
type: "string",
18+
label: "Response Style",
19+
description: "Style of the response (e.g., Funny, Serious).",
2220
},
2321
responseLength: {
24-
propDefinition: [
25-
tldr,
26-
"responseLength",
27-
],
22+
type: "integer",
23+
label: "Response Length",
24+
description: "Length of the response summary.",
2825
},
2926
},
3027
async run({ $ }) {
3128
const response = await this.tldr.summarize({
32-
inputText: this.inputText,
33-
responseLength: this.responseLength || undefined,
34-
responseStyle: this.responseStyle || undefined,
29+
$,
30+
data: {
31+
inputText: this.inputText,
32+
responseLength: this.responseLength,
33+
responseStyle: this.responseStyle,
34+
},
3535
});
3636

37-
const summary = response.output.summary;
38-
$.export("$summary", `Successfully summarized the text with the following summary: "${summary}"`);
39-
return response.output;
37+
$.export("$summary", `Successfully summarized the text with the following input: "${this.inputText}"`);
38+
return response;
4039
},
4140
};

components/tldr/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/tldr",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream TLDR Components",
55
"main": "tldr.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
1518
}

components/tldr/tldr.app.mjs

Lines changed: 14 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,30 @@ import { axios } from "@pipedream/platform";
33
export default {
44
type: "app",
55
app: "tldr",
6-
propDefinitions: {
7-
inputText: {
8-
type: "string",
9-
label: "Text to Summarize",
10-
description: "The text that needs to be summarized.",
11-
},
12-
responseStyle: {
13-
type: "string",
14-
label: "Response Style",
15-
description: "Style of the response (e.g., Funny, Serious).",
16-
optional: true,
17-
},
18-
responseLength: {
19-
type: "integer",
20-
label: "Response Length",
21-
description: "Length of the response summary.",
22-
optional: true,
23-
},
24-
},
256
methods: {
26-
authKeys() {
27-
console.log(Object.keys(this.$auth));
7+
_headers() {
8+
return {
9+
"Authorization": `Bearer ${this.$auth.api_key}`,
10+
"Content-Type": "application/json",
11+
};
2812
},
2913
_baseUrl() {
30-
return "https://runtldr.com";
14+
return "https://runtldr.com/apis/v1";
3115
},
32-
async _makeRequest(opts = {}) {
33-
const {
34-
$ = this, method = "POST", path = "/", headers, ...otherOpts
35-
} = opts;
16+
_makeRequest({
17+
$ = this, path, ...opts
18+
}) {
3619
return axios($, {
37-
...otherOpts,
38-
method,
3920
url: this._baseUrl() + path,
40-
headers: {
41-
...headers,
42-
"Authorization": `Bearer ${this.$auth.api_key}`,
43-
"Content-Type": "application/json",
44-
},
21+
headers: this._headers(),
22+
...opts,
4523
});
4624
},
47-
async summarize({
48-
inputText, responseLength, responseStyle,
49-
}) {
25+
summarize(opts = {}) {
5026
return this._makeRequest({
27+
method: "POST",
5128
path: "/summarize",
52-
data: {
53-
inputText,
54-
responseLength,
55-
responseStyle,
56-
},
29+
...opts,
5730
});
5831
},
5932
},

0 commit comments

Comments
 (0)