@pipedream/textcortex 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,107 @@
1
+ import app from "../../textcortex.app.mjs";
2
+ import constants from "../../common/constants.mjs";
3
+
4
+ export default {
5
+ key: "textcortex-create-social-media-post",
6
+ name: "Create Social Media Post",
7
+ description: "Create a social media post. [See the documentation](https://docs.textcortex.com/api/paths/texts-social-media-posts/post)",
8
+ type: "action",
9
+ version: "0.0.1",
10
+ props: {
11
+ app,
12
+ context: {
13
+ type: "string",
14
+ label: "Context",
15
+ description: "The context of the social media post.",
16
+ },
17
+ keywords: {
18
+ type: "string[]",
19
+ label: "Keywords",
20
+ description: "Keywords to be included in the post.",
21
+ optional: true,
22
+ },
23
+ maxTokens: {
24
+ propDefinition: [
25
+ app,
26
+ "maxTokens",
27
+ ],
28
+ },
29
+ mode: {
30
+ type: "string",
31
+ label: "Mode",
32
+ description: "The platform, e.g. `twitter` to generate a Tweet. Allowed values: `twitter`, `linkedin`",
33
+ options: Object.values(constants.SOCIAL_MEDIA_MODE),
34
+ },
35
+ model: {
36
+ propDefinition: [
37
+ app,
38
+ "model",
39
+ ],
40
+ },
41
+ n: {
42
+ propDefinition: [
43
+ app,
44
+ "n",
45
+ ],
46
+ },
47
+ sourceLang: {
48
+ propDefinition: [
49
+ app,
50
+ "sourceLang",
51
+ ],
52
+ },
53
+ targetLang: {
54
+ propDefinition: [
55
+ app,
56
+ "targetLang",
57
+ ],
58
+ },
59
+ temperature: {
60
+ propDefinition: [
61
+ app,
62
+ "temperature",
63
+ ],
64
+ },
65
+ },
66
+ methods: {
67
+ createSocialMediaPost(args = {}) {
68
+ return this.app.post({
69
+ path: "/texts/social-media-posts",
70
+ ...args,
71
+ });
72
+ },
73
+ },
74
+ async run({ $: step }) {
75
+ const {
76
+ createSocialMediaPost,
77
+ context,
78
+ keywords,
79
+ maxTokens,
80
+ mode,
81
+ model,
82
+ n,
83
+ sourceLang,
84
+ targetLang,
85
+ temperature,
86
+ } = this;
87
+
88
+ const response = await createSocialMediaPost({
89
+ step,
90
+ data: {
91
+ context,
92
+ keywords,
93
+ max_tokens: maxTokens,
94
+ mode,
95
+ model,
96
+ n,
97
+ source_lang: sourceLang,
98
+ target_lang: targetLang,
99
+ temperature,
100
+ },
101
+ });
102
+
103
+ step.export("$summary", `Successfully created social media post with status \`${response.status}\``);
104
+
105
+ return response;
106
+ },
107
+ };
@@ -0,0 +1,112 @@
1
+ import app from "../../textcortex.app.mjs";
2
+ import constants from "../../common/constants.mjs";
3
+
4
+ export default {
5
+ key: "textcortex-summarize-text",
6
+ name: "Summarize Text",
7
+ description: "Summarize given text. The text can be provided as a string or as a file ID. [See the documentation](https://docs.textcortex.com/api/paths/texts-summarizations/post)",
8
+ type: "action",
9
+ version: "0.0.1",
10
+ props: {
11
+ app,
12
+ fileId: {
13
+ type: "string",
14
+ label: "File ID",
15
+ description: "The ID of the file to summarize. **string<uuid>** Example: `8a0cfb4f-ddc9-436d-91bb-75133c583767`",
16
+ optional: true,
17
+ },
18
+ maxTokens: {
19
+ propDefinition: [
20
+ app,
21
+ "maxTokens",
22
+ ],
23
+ },
24
+ mode: {
25
+ type: "string",
26
+ label: "Mode",
27
+ description: "The summarization mode.",
28
+ options: Object.values(constants.SUMMARIZE_MODE),
29
+ optional: true,
30
+ },
31
+ model: {
32
+ optional: true,
33
+ propDefinition: [
34
+ app,
35
+ "model",
36
+ ],
37
+ },
38
+ n: {
39
+ propDefinition: [
40
+ app,
41
+ "n",
42
+ ],
43
+ },
44
+ sourceLang: {
45
+ propDefinition: [
46
+ app,
47
+ "sourceLang",
48
+ ],
49
+ },
50
+ targetLang: {
51
+ propDefinition: [
52
+ app,
53
+ "targetLang",
54
+ ],
55
+ },
56
+ temperature: {
57
+ propDefinition: [
58
+ app,
59
+ "temperature",
60
+ ],
61
+ },
62
+ text: {
63
+ description: "The text to summarize.",
64
+ optional: true,
65
+ propDefinition: [
66
+ app,
67
+ "text",
68
+ ],
69
+ },
70
+ },
71
+ methods: {
72
+ summarizeText(args = {}) {
73
+ return this.app.post({
74
+ path: "/texts/summarizations",
75
+ ...args,
76
+ });
77
+ },
78
+ },
79
+ async run({ $: step }) {
80
+ const {
81
+ summarizeText,
82
+ fileId,
83
+ maxTokens,
84
+ model,
85
+ mode,
86
+ n,
87
+ sourceLang,
88
+ targetLang,
89
+ temperature,
90
+ text,
91
+ } = this;
92
+
93
+ const response = await summarizeText({
94
+ step,
95
+ data: {
96
+ file_id: fileId,
97
+ max_tokens: maxTokens,
98
+ model,
99
+ mode,
100
+ n,
101
+ source_lang: sourceLang,
102
+ target_lang: targetLang,
103
+ temperature,
104
+ text,
105
+ },
106
+ });
107
+
108
+ step.export("$summary", `Successfully summarized with status \`${response.status}\``);
109
+
110
+ return response;
111
+ },
112
+ };
@@ -0,0 +1,62 @@
1
+ import app from "../../textcortex.app.mjs";
2
+
3
+ export default {
4
+ key: "textcortex-translate-text",
5
+ name: "Translate Text",
6
+ description: "Translate given text into another language. [See the documentation](https://docs.textcortex.com/api/paths/texts-translations/post)",
7
+ type: "action",
8
+ version: "0.0.1",
9
+ props: {
10
+ app,
11
+ text: {
12
+ propDefinition: [
13
+ app,
14
+ "text",
15
+ ],
16
+ },
17
+ sourceLang: {
18
+ description: "The language of the text to translate.",
19
+ propDefinition: [
20
+ app,
21
+ "sourceLang",
22
+ ],
23
+ },
24
+ targetLang: {
25
+ description: "The language to translate to.",
26
+ optional: false,
27
+ propDefinition: [
28
+ app,
29
+ "targetLang",
30
+ ],
31
+ },
32
+ },
33
+ methods: {
34
+ translateText(args = {}) {
35
+ return this.app.post({
36
+ path: "/texts/translations",
37
+ ...args,
38
+ });
39
+ },
40
+ },
41
+ async run({ $: step }) {
42
+ const {
43
+ translateText,
44
+ text,
45
+ sourceLang,
46
+ targetLang,
47
+ } = this;
48
+
49
+ const response = await translateText({
50
+ step,
51
+ data: {
52
+ text,
53
+ source_lang: sourceLang,
54
+ target_lang: targetLang,
55
+ },
56
+ });
57
+
58
+ step.export("$summary", `Successfully translated text from ${sourceLang} to ${targetLang}.`);
59
+
60
+ return response;
61
+ },
62
+ };
@@ -0,0 +1,28 @@
1
+ const BASE_URL = "https://api.textcortex.com";
2
+ const VERSION_PATH = "/v1";
3
+
4
+ const SOCIAL_MEDIA_MODE = {
5
+ TWITTER: "twitter",
6
+ LINKEDIN: "linkedin",
7
+ };
8
+
9
+ const SUMMARIZE_MODE = {
10
+ DEFAULT: "default",
11
+ EMBEDDINGS: "embeddings",
12
+ };
13
+
14
+ const MODEL = {
15
+ VELOX1: "velox-1",
16
+ AECUS1: "aecus-1",
17
+ ALTA1: "alta-1",
18
+ SOPHOS1: "sophos-1",
19
+ CHATSOPHOS1: "chat-sophos-1",
20
+ };
21
+
22
+ export default {
23
+ BASE_URL,
24
+ VERSION_PATH,
25
+ SOCIAL_MEDIA_MODE,
26
+ SUMMARIZE_MODE,
27
+ MODEL,
28
+ };
@@ -0,0 +1,122 @@
1
+ export default {
2
+ EN: {
3
+ label: "English (Default)",
4
+ value: "en",
5
+ },
6
+ AUTO: {
7
+ label: "The API will attempt to detect the language of the text and translate it.",
8
+ value: "auto",
9
+ },
10
+ BG: {
11
+ label: "Bulgarian",
12
+ value: "bg",
13
+ },
14
+ CS: {
15
+ label: "Czech",
16
+ value: "cs",
17
+ },
18
+ DA: {
19
+ label: "Danish",
20
+ value: "da",
21
+ },
22
+ DE: {
23
+ label: "German",
24
+ value: "de",
25
+ },
26
+ EL: {
27
+ label: "Greek",
28
+ value: "el",
29
+ },
30
+ ES: {
31
+ label: "Spanish",
32
+ value: "es",
33
+ },
34
+ ET: {
35
+ label: "Estonian",
36
+ value: "et",
37
+ },
38
+ FI: {
39
+ label: "Finnish",
40
+ value: "fi",
41
+ },
42
+ FR: {
43
+ label: "French",
44
+ value: "fr",
45
+ },
46
+ HU: {
47
+ label: "Hungarian",
48
+ value: "hu",
49
+ },
50
+ ID: {
51
+ label: "Indonesian",
52
+ value: "id",
53
+ },
54
+ IT: {
55
+ label: "Italian",
56
+ value: "it",
57
+ },
58
+ JA: {
59
+ label: "Japanese",
60
+ value: "ja",
61
+ },
62
+ KO: {
63
+ label: "Korean",
64
+ value: "ko",
65
+ },
66
+ LT: {
67
+ label: "Lithuanian",
68
+ value: "lt",
69
+ },
70
+ LV: {
71
+ label: "Latvian",
72
+ value: "lv",
73
+ },
74
+ NB: {
75
+ label: "Norwegian",
76
+ value: "nb",
77
+ },
78
+ NL: {
79
+ label: "Dutch",
80
+ value: "nl",
81
+ },
82
+ PL: {
83
+ label: "Polish",
84
+ value: "pl",
85
+ },
86
+ PT: {
87
+ label: "Portuguese (all Portuguese varieties mixed)",
88
+ value: "pt",
89
+ },
90
+ RO: {
91
+ label: "Romanian",
92
+ value: "ro",
93
+ },
94
+ RU: {
95
+ label: "Russian",
96
+ value: "ru",
97
+ },
98
+ SK: {
99
+ label: "Slovak",
100
+ value: "sk",
101
+ },
102
+ SL: {
103
+ label: "Slovenian",
104
+ value: "sl",
105
+ },
106
+ SV: {
107
+ label: "Swedish",
108
+ value: "sv",
109
+ },
110
+ TR: {
111
+ label: "Turkish",
112
+ value: "tr",
113
+ },
114
+ UK: {
115
+ label: "Ukrainian",
116
+ value: "uk",
117
+ },
118
+ ZH: {
119
+ label: "Chinese",
120
+ value: "zh",
121
+ },
122
+ };
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@pipedream/textcortex",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "description": "Pipedream TextCortex Components",
5
- "main": "dist/app/textcortex.app.mjs",
5
+ "main": "textcortex.app.mjs",
6
6
  "keywords": [
7
7
  "pipedream",
8
8
  "textcortex"
9
9
  ],
10
- "files": [
11
- "dist"
12
- ],
13
10
  "homepage": "https://pipedream.com/apps/textcortex",
14
11
  "author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
12
+ "dependencies": {
13
+ "@pipedream/platform": "^1.5.1"
14
+ },
15
15
  "publishConfig": {
16
16
  "access": "public"
17
17
  }
@@ -0,0 +1,93 @@
1
+ import { axios } from "@pipedream/platform";
2
+ import constants from "./common/constants.mjs";
3
+ import LANG from "./common/language.mjs";
4
+
5
+ export default {
6
+ type: "app",
7
+ app: "textcortex",
8
+ propDefinitions: {
9
+ maxTokens: {
10
+ type: "integer",
11
+ label: "Max Tokens",
12
+ description: "The maximum number of tokens to generate.",
13
+ optional: true,
14
+ default: 512,
15
+ },
16
+ model: {
17
+ type: "string",
18
+ label: "Model",
19
+ description: "The language model to use. Allowed values: `velox-1`, `aecus-1`, `alta-1`, `sophos-1` and `chat-sophos-1`",
20
+ options: Object.values(constants.MODEL),
21
+ default: constants.MODEL.CHATSOPHOS1,
22
+ optional: true,
23
+ },
24
+ n: {
25
+ type: "integer",
26
+ label: "N",
27
+ description: "The number of outputs to generate.",
28
+ default: 1,
29
+ optional: true,
30
+ },
31
+ sourceLang: {
32
+ type: "string",
33
+ label: "Source Language",
34
+ description: "The language of the source text.",
35
+ options: Object.values(LANG),
36
+ default: LANG.EN.value,
37
+ optional: true,
38
+ },
39
+ targetLang: {
40
+ type: "string",
41
+ label: "Target Language",
42
+ description: "The language which the text should be generated in.",
43
+ options: Object.values(LANG),
44
+ default: LANG.EN.value,
45
+ optional: true,
46
+ },
47
+ text: {
48
+ type: "string",
49
+ label: "Text",
50
+ description: "The text to translate.",
51
+ },
52
+ temperature: {
53
+ type: "string",
54
+ label: "Temperature",
55
+ description: "The sampling temperature to be used in text generation. The higher the temperature, the higher the risk of the output to sound \"made up\".",
56
+ default: "0.7",
57
+ optional: true,
58
+ },
59
+ },
60
+ methods: {
61
+ getBaseUrl() {
62
+ return `${constants.BASE_URL}${constants.VERSION_PATH}`;
63
+ },
64
+ getUrl(path, url) {
65
+ return url || `${this.getBaseUrl()}${path}`;
66
+ },
67
+ getHeaders(headers) {
68
+ return {
69
+ "Content-Type": "application/json",
70
+ "Authorization": `Bearer ${this.$auth.api_key}`,
71
+ ...headers,
72
+ };
73
+ },
74
+ makeRequest({
75
+ step = this, path, headers, url, ...args
76
+ } = {}) {
77
+
78
+ const config = {
79
+ headers: this.getHeaders(headers),
80
+ url: this.getUrl(path, url),
81
+ ...args,
82
+ };
83
+
84
+ return axios(step, config);
85
+ },
86
+ post(args = {}) {
87
+ return this.makeRequest({
88
+ method: "post",
89
+ ...args,
90
+ });
91
+ },
92
+ },
93
+ };