diff --git a/components/tldr/actions/summarize-text/summarize-text.mjs b/components/tldr/actions/summarize-text/summarize-text.mjs new file mode 100644 index 0000000000000..618b2ea3c80d2 --- /dev/null +++ b/components/tldr/actions/summarize-text/summarize-text.mjs @@ -0,0 +1,40 @@ +import tldr from "../../tldr.app.mjs"; + +export default { + key: "tldr-summarize-text", + name: "Summarize Text", + description: "Reads in a piece of text and distills the main points. [See the documentation](https://runtldr.com/documentation)", + version: "0.0.1", + type: "action", + props: { + tldr, + inputText: { + type: "string", + label: "Text to Summarize", + description: "The text that needs to be summarized.", + }, + responseStyle: { + type: "string", + label: "Response Style", + description: "Style of the response (e.g., Funny, Serious).", + }, + responseLength: { + type: "integer", + label: "Response Length", + description: "Length of the response summary.", + }, + }, + async run({ $ }) { + const response = await this.tldr.summarize({ + $, + data: { + inputText: this.inputText, + responseLength: this.responseLength, + responseStyle: this.responseStyle, + }, + }); + + $.export("$summary", `Successfully summarized the text with the following input: "${this.inputText}"`); + return response; + }, +}; diff --git a/components/tldr/package.json b/components/tldr/package.json index 33f19a0b0e983..a8353a1194f10 100644 --- a/components/tldr/package.json +++ b/components/tldr/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/tldr", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream TLDR Components", "main": "tldr.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } -} \ No newline at end of file +} diff --git a/components/tldr/tldr.app.mjs b/components/tldr/tldr.app.mjs index b093bb357fe12..9cec238fcb7cf 100644 --- a/components/tldr/tldr.app.mjs +++ b/components/tldr/tldr.app.mjs @@ -1,11 +1,33 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "tldr", - propDefinitions: {}, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _headers() { + return { + "Authorization": `Bearer ${this.$auth.api_key}`, + "Content-Type": "application/json", + }; + }, + _baseUrl() { + return "https://runtldr.com/apis/v1"; + }, + _makeRequest({ + $ = this, path, ...opts + }) { + return axios($, { + url: this._baseUrl() + path, + headers: this._headers(), + ...opts, + }); + }, + summarize(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/summarize", + ...opts, + }); }, }, -}; \ No newline at end of file +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7f849c5ef0338..6ce33f30c3426 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10437,7 +10437,10 @@ importers: '@pipedream/platform': 1.5.1 components/tldr: - specifiers: {} + specifiers: + '@pipedream/platform': ^3.0.3 + dependencies: + '@pipedream/platform': 3.0.3 components/tmetric: specifiers: {}