Skip to content

Commit ae9bcaf

Browse files
authored
[Components] universal_summarizer_by_kagi #12416 (#16451)
* Added actions * Bump package.json
1 parent 8b43be2 commit ae9bcaf

File tree

4 files changed

+273
-5
lines changed

4 files changed

+273
-5
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import app from "../../universal_summarizer_by_kagi.app.mjs";
2+
3+
export default {
4+
key: "universal_summarizer_by_kagi-summarize-document",
5+
name: "Summarize Document",
6+
description: "Summarizes the content of a URL. [See the documentation](https://help.kagi.com/kagi/api/summarizer.html#summarize-document)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
url: {
12+
propDefinition: [
13+
app,
14+
"url",
15+
],
16+
},
17+
engine: {
18+
propDefinition: [
19+
app,
20+
"engine",
21+
],
22+
},
23+
summaryType: {
24+
propDefinition: [
25+
app,
26+
"summaryType",
27+
],
28+
},
29+
targetLanguage: {
30+
propDefinition: [
31+
app,
32+
"targetLanguage",
33+
],
34+
},
35+
cache: {
36+
propDefinition: [
37+
app,
38+
"cache",
39+
],
40+
},
41+
},
42+
43+
async run({ $ }) {
44+
const response = await this.app.summarizeDocument({
45+
$,
46+
params: {
47+
url: this.url,
48+
engine: this.engine,
49+
summary_type: this.summaryType,
50+
target_language: this.targetLanguage,
51+
cache: this.cache,
52+
},
53+
});
54+
$.export("$summary", "Successfully summarized the content of the URL");
55+
return response;
56+
},
57+
};
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
export default {
2+
SUMMARY_TYPES:
3+
[
4+
{
5+
label: "summary (default) – Paragraph(s) of summary prose",
6+
value: "summary",
7+
},
8+
{
9+
label: "takeaway – Bulleted list of key points",
10+
value: "takeaway",
11+
},
12+
],
13+
LANGUAGE_OPTIONS: [
14+
{
15+
label: "Bulgarian",
16+
value: "BG",
17+
},
18+
{
19+
label: "Czech",
20+
value: "CS",
21+
},
22+
{
23+
label: "Danish",
24+
value: "DA",
25+
},
26+
{
27+
label: "German",
28+
value: "DE",
29+
},
30+
{
31+
label: "Greek",
32+
value: "EL",
33+
},
34+
{
35+
label: "English",
36+
value: "EN",
37+
},
38+
{
39+
label: "Spanish",
40+
value: "ES",
41+
},
42+
{
43+
label: "Estonian",
44+
value: "ET",
45+
},
46+
{
47+
label: "Finnish",
48+
value: "FI",
49+
},
50+
{
51+
label: "French",
52+
value: "FR",
53+
},
54+
{
55+
label: "Hungarian",
56+
value: "HU",
57+
},
58+
{
59+
label: "Indonesian",
60+
value: "ID",
61+
},
62+
{
63+
label: "Italian",
64+
value: "IT",
65+
},
66+
{
67+
label: "Japanese",
68+
value: "JA",
69+
},
70+
{
71+
label: "Korean",
72+
value: "KO",
73+
},
74+
{
75+
label: "Lithuanian",
76+
value: "LT",
77+
},
78+
{
79+
label: "Latvian",
80+
value: "LV",
81+
},
82+
{
83+
label: "Norwegian",
84+
value: "NB",
85+
},
86+
{
87+
label: "Dutch",
88+
value: "NL",
89+
},
90+
{
91+
label: "Polish",
92+
value: "PL",
93+
},
94+
{
95+
label: "Portuguese",
96+
value: "PT",
97+
},
98+
{
99+
label: "Romanian",
100+
value: "RO",
101+
},
102+
{
103+
label: "Russian",
104+
value: "RU",
105+
},
106+
{
107+
label: "Slovak",
108+
value: "SK",
109+
},
110+
{
111+
label: "Slovenian",
112+
value: "SL",
113+
},
114+
{
115+
label: "Swedish",
116+
value: "SV",
117+
},
118+
{
119+
label: "Turkish",
120+
value: "TR",
121+
},
122+
{
123+
label: "Ukrainian",
124+
value: "UK",
125+
},
126+
{
127+
label: "Chinese (simplified)",
128+
value: "ZH",
129+
},
130+
{
131+
label: "Chinese (traditional)",
132+
value: "ZH-HANT",
133+
},
134+
],
135+
ENGINE_OPTIONS: [
136+
{
137+
label: "Friendly, descriptive, fast summary",
138+
value: "cecil",
139+
},
140+
{
141+
label: "Formal, technical, analytical summary",
142+
value: "agnes",
143+
},
144+
{
145+
label: "Same as Agnes (Soon-to-be-deprecated)",
146+
value: "daphne",
147+
},
148+
{
149+
label: "Enterprise-grade, best-in-class summary",
150+
value: "muriel",
151+
},
152+
],
153+
};

components/universal_summarizer_by_kagi/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/universal_summarizer_by_kagi",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Universal Summarizer by Kagi Components",
55
"main": "universal_summarizer_by_kagi.app.mjs",
66
"keywords": [
Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,69 @@
1+
import { axios } from "@pipedream/platform";
2+
import constants from "./common/constants.mjs";
3+
14
export default {
25
type: "app",
36
app: "universal_summarizer_by_kagi",
4-
propDefinitions: {},
7+
propDefinitions: {
8+
url: {
9+
type: "string",
10+
label: "URL",
11+
description: "A URL to a document to summarize",
12+
},
13+
engine: {
14+
type: "string",
15+
label: "Summarization Engine",
16+
description: "Select the summarization engine",
17+
options: constants.ENGINE_OPTIONS,
18+
optional: true,
19+
},
20+
summaryType: {
21+
type: "string",
22+
label: "Summary Type",
23+
description: "Type of summary output",
24+
options: constants.SUMMARY_TYPES,
25+
optional: true,
26+
},
27+
targetLanguage: {
28+
type: "string",
29+
label: "Target Language",
30+
description: "Desired output language",
31+
options: constants.LANGUAGE_OPTIONS,
32+
optional: true,
33+
},
34+
cache: {
35+
type: "boolean",
36+
label: "Cache",
37+
description: "Whether to allow cached requests & responses. Default is true",
38+
optional: true,
39+
},
40+
},
541
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
42+
_baseUrl() {
43+
return "https://kagi.com/api/v0";
44+
},
45+
async _makeRequest(opts = {}) {
46+
const {
47+
$ = this,
48+
path,
49+
headers,
50+
...otherOpts
51+
} = opts;
52+
return axios($, {
53+
...otherOpts,
54+
url: this._baseUrl() + path,
55+
headers: {
56+
"Authorization": `Bot ${this.$auth.api_key}`,
57+
...headers,
58+
},
59+
});
60+
},
61+
62+
async summarizeDocument(args = {}) {
63+
return this._makeRequest({
64+
path: "/summarize",
65+
...args,
66+
});
967
},
1068
},
1169
};

0 commit comments

Comments
 (0)