Skip to content

[Components] universal_summarizer_by_kagi #12416 #16451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import app from "../../universal_summarizer_by_kagi.app.mjs";

export default {
key: "universal_summarizer_by_kagi-summarize-document",
name: "Summarize Document",
description: "Summarizes the content of a URL. [See the documentation](https://help.kagi.com/kagi/api/summarizer.html#summarize-document)",
version: "0.0.1",
type: "action",
props: {
app,
url: {
propDefinition: [
app,
"url",
],
},
engine: {
propDefinition: [
app,
"engine",
],
},
summaryType: {
propDefinition: [
app,
"summaryType",
],
},
targetLanguage: {
propDefinition: [
app,
"targetLanguage",
],
},
cache: {
propDefinition: [
app,
"cache",
],
},
},

async run({ $ }) {
const response = await this.app.summarizeDocument({
$,
params: {
url: this.url,
engine: this.engine,
summary_type: this.summaryType,
target_language: this.targetLanguage,
cache: this.cache,
},
});
$.export("$summary", "Successfully summarized the content of the URL");
return response;
},
};
153 changes: 153 additions & 0 deletions components/universal_summarizer_by_kagi/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
export default {
SUMMARY_TYPES:
[
{
label: "summary (default) – Paragraph(s) of summary prose",
value: "summary",
},
{
label: "takeaway – Bulleted list of key points",
value: "takeaway",
},
],
LANGUAGE_OPTIONS: [
{
label: "Bulgarian",
value: "BG",
},
{
label: "Czech",
value: "CS",
},
{
label: "Danish",
value: "DA",
},
{
label: "German",
value: "DE",
},
{
label: "Greek",
value: "EL",
},
{
label: "English",
value: "EN",
},
{
label: "Spanish",
value: "ES",
},
{
label: "Estonian",
value: "ET",
},
{
label: "Finnish",
value: "FI",
},
{
label: "French",
value: "FR",
},
{
label: "Hungarian",
value: "HU",
},
{
label: "Indonesian",
value: "ID",
},
{
label: "Italian",
value: "IT",
},
{
label: "Japanese",
value: "JA",
},
{
label: "Korean",
value: "KO",
},
{
label: "Lithuanian",
value: "LT",
},
{
label: "Latvian",
value: "LV",
},
{
label: "Norwegian",
value: "NB",
},
{
label: "Dutch",
value: "NL",
},
{
label: "Polish",
value: "PL",
},
{
label: "Portuguese",
value: "PT",
},
{
label: "Romanian",
value: "RO",
},
{
label: "Russian",
value: "RU",
},
{
label: "Slovak",
value: "SK",
},
{
label: "Slovenian",
value: "SL",
},
{
label: "Swedish",
value: "SV",
},
{
label: "Turkish",
value: "TR",
},
{
label: "Ukrainian",
value: "UK",
},
{
label: "Chinese (simplified)",
value: "ZH",
},
{
label: "Chinese (traditional)",
value: "ZH-HANT",
},
],
ENGINE_OPTIONS: [
{
label: "Friendly, descriptive, fast summary",
value: "cecil",
},
{
label: "Formal, technical, analytical summary",
value: "agnes",
},
{
label: "Same as Agnes (Soon-to-be-deprecated)",
value: "daphne",
},
{
label: "Enterprise-grade, best-in-class summary",
value: "muriel",
},
],
};
Original file line number Diff line number Diff line change
@@ -1,11 +1,69 @@
import { axios } from "@pipedream/platform";
import constants from "./common/constants.mjs";

export default {
type: "app",
app: "universal_summarizer_by_kagi",
propDefinitions: {},
propDefinitions: {
url: {
type: "string",
label: "URL",
description: "A URL to a document to summarize",
},
engine: {
type: "string",
label: "Summarization Engine",
description: "Select the summarization engine",
options: constants.ENGINE_OPTIONS,
optional: true,
},
summaryType: {
type: "string",
label: "Summary Type",
description: "Type of summary output",
options: constants.SUMMARY_TYPES,
optional: true,
},
targetLanguage: {
type: "string",
label: "Target Language",
description: "Desired output language",
options: constants.LANGUAGE_OPTIONS,
optional: true,
},
cache: {
type: "boolean",
label: "Cache",
description: "Whether to allow cached requests & responses. Default is true",
optional: true,
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://kagi.com/api/v0";
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
headers,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
headers: {
"Authorization": `Bot ${this.$auth.api_key}`,
...headers,
},
});
},

async summarizeDocument(args = {}) {
return this._makeRequest({
path: "/summarize",
...args,
});
},
},
};
Loading