Skip to content

Commit fb50877

Browse files
luancazarinelcaresia
authored andcommitted
New Components - tldr (#14499)
* tldr init * [Components] tldr #14496 Actions - Summarize Text * pnpm update
1 parent d464f21 commit fb50877

File tree

4 files changed

+75
-7
lines changed

4 files changed

+75
-7
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import tldr from "../../tldr.app.mjs";
2+
3+
export default {
4+
key: "tldr-summarize-text",
5+
name: "Summarize Text",
6+
description: "Reads in a piece of text and distills the main points. [See the documentation](https://runtldr.com/documentation)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
tldr,
11+
inputText: {
12+
type: "string",
13+
label: "Text to Summarize",
14+
description: "The text that needs to be summarized.",
15+
},
16+
responseStyle: {
17+
type: "string",
18+
label: "Response Style",
19+
description: "Style of the response (e.g., Funny, Serious).",
20+
},
21+
responseLength: {
22+
type: "integer",
23+
label: "Response Length",
24+
description: "Length of the response summary.",
25+
},
26+
},
27+
async run({ $ }) {
28+
const response = await this.tldr.summarize({
29+
$,
30+
data: {
31+
inputText: this.inputText,
32+
responseLength: this.responseLength,
33+
responseStyle: this.responseStyle,
34+
},
35+
});
36+
37+
$.export("$summary", `Successfully summarized the text with the following input: "${this.inputText}"`);
38+
return response;
39+
},
40+
};

components/tldr/package.json

Lines changed: 5 additions & 2 deletions
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
}
15-
}
18+
}

components/tldr/tldr.app.mjs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "tldr",
4-
propDefinitions: {},
56
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
7+
_headers() {
8+
return {
9+
"Authorization": `Bearer ${this.$auth.api_key}`,
10+
"Content-Type": "application/json",
11+
};
12+
},
13+
_baseUrl() {
14+
return "https://runtldr.com/apis/v1";
15+
},
16+
_makeRequest({
17+
$ = this, path, ...opts
18+
}) {
19+
return axios($, {
20+
url: this._baseUrl() + path,
21+
headers: this._headers(),
22+
...opts,
23+
});
24+
},
25+
summarize(opts = {}) {
26+
return this._makeRequest({
27+
method: "POST",
28+
path: "/summarize",
29+
...opts,
30+
});
931
},
1032
},
1133
};

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)