Skip to content

Commit 442e171

Browse files
committed
tldr init
1 parent 9a24ee0 commit 442e171

File tree

3 files changed

+94
-4
lines changed

3 files changed

+94
-4
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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.{{ts}}",
8+
type: "action",
9+
props: {
10+
tldr,
11+
inputText: {
12+
propDefinition: [
13+
tldr,
14+
"inputText",
15+
],
16+
},
17+
responseStyle: {
18+
propDefinition: [
19+
tldr,
20+
"responseStyle",
21+
],
22+
},
23+
responseLength: {
24+
propDefinition: [
25+
tldr,
26+
"responseLength",
27+
],
28+
},
29+
},
30+
async run({ $ }) {
31+
const response = await this.tldr.summarize({
32+
inputText: this.inputText,
33+
responseLength: this.responseLength || undefined,
34+
responseStyle: this.responseStyle || undefined,
35+
});
36+
37+
const summary = response.output.summary;
38+
$.export("$summary", `Successfully summarized the text with the following summary: "${summary}"`);
39+
return response.output;
40+
},
41+
};

components/tldr/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"publishConfig": {
1313
"access": "public"
1414
}
15-
}
15+
}

components/tldr/tldr.app.mjs

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,60 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "tldr",
4-
propDefinitions: {},
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+
},
525
methods: {
6-
// this.$auth contains connected account data
726
authKeys() {
827
console.log(Object.keys(this.$auth));
928
},
29+
_baseUrl() {
30+
return "https://runtldr.com";
31+
},
32+
async _makeRequest(opts = {}) {
33+
const {
34+
$ = this, method = "POST", path = "/", headers, ...otherOpts
35+
} = opts;
36+
return axios($, {
37+
...otherOpts,
38+
method,
39+
url: this._baseUrl() + path,
40+
headers: {
41+
...headers,
42+
"Authorization": `Bearer ${this.$auth.api_key}`,
43+
"Content-Type": "application/json",
44+
},
45+
});
46+
},
47+
async summarize({
48+
inputText, responseLength, responseStyle,
49+
}) {
50+
return this._makeRequest({
51+
path: "/summarize",
52+
data: {
53+
inputText,
54+
responseLength,
55+
responseStyle,
56+
},
57+
});
58+
},
1059
},
11-
};
60+
};

0 commit comments

Comments
 (0)