Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apollo-ai-api-client

Package Overview
Dependencies
Maintainers
4
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-ai-api-client - npm Package Compare versions

Comparing version 0.1.27 to 0.2.0

5

lib/apollo.ai/ApolloAiClient.d.ts

@@ -39,3 +39,2 @@ export interface IAutoAbstractResponse {

language?: ClusteringLanguage;
skipAbstract?: boolean;
}

@@ -69,4 +68,4 @@ export interface IContinuesClusteringInput {

autoabstract(headline: string, text: string, maxCharacters?: number, keywords?: string[], maxSentences?: number, debug?: boolean): Promise<IAutoAbstractResponse>;
clustering(articles: IClusteringArticle[], threshold?: number, language?: ClusteringLanguage): Promise<IClusteringResponse>;
continuedClustering(newArticles: IArticle[] | string[], presentArticles?: IContinuesClusteringResultItem[], options?: IContinuesClusteringOptions): Promise<any>;
clustering(articles: IClusteringArticle[], threshold?: number, language?: ClusteringLanguage): Promise<IClusteringResponse[]>;
continuedClustering(newArticles: IArticle[] | string[], presentArticles?: IContinuesClusteringResultItem[], options?: IContinuesClusteringOptions): Promise<IClusteringResponse[]>;
}

172

lib/apollo.ai/ApolloAiClient.js
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -27,99 +19,91 @@ const node_fetch_1 = require("node-fetch");

executeAutoabstract(body, debug = false) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield node_fetch_1.default(this.apolloApiEndpoint + this.autoAbstractEndpoint, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + this.apiKey,
},
body: JSON.stringify(Object.assign({ debug }, body)),
});
return node_fetch_1.default(this.apolloApiEndpoint + this.autoAbstractEndpoint, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + this.apiKey,
},
body: JSON.stringify(Object.assign({ debug }, body)),
}).then((response) => {
if (response.status !== 200) {
throw Error('Received invalid response from autoabstract endpoint');
return Promise.reject({ message: 'Received invalid response from autoabstract endpoint', error: response.text() });
}
return yield response.json();
});
}
autoabstractUrl(url, maxCharacters = 400, keywords, maxSentences, debug) {
return __awaiter(this, void 0, void 0, function* () {
const body = {
url,
keywords: keywords ? keywords.join(',') : '',
};
if (maxSentences) {
body.maxSentences = maxSentences;
}
else {
body.maxCharacters = maxCharacters;
return response.json();
}
return yield this.executeAutoabstract(body, debug);
}).catch((err) => {
return Promise.reject({ message: 'Received invalid response from autoabstract endpoint', error: err });
});
}
autoabstractUrl(url, maxCharacters = 400, keywords, maxSentences, debug) {
const body = {
url,
keywords: keywords ? keywords.join(',') : '',
};
if (maxSentences) {
body.maxSentences = maxSentences;
}
else {
body.maxCharacters = maxCharacters;
}
return this.executeAutoabstract(body, debug);
}
autoabstract(headline, text, maxCharacters = 400, keywords, maxSentences, debug) {
return __awaiter(this, void 0, void 0, function* () {
const body = {
headline,
text,
keywords: keywords ? keywords.join(',') : '',
};
if (maxSentences) {
body.maxSentences = maxSentences;
}
else {
body.maxCharacters = maxCharacters;
}
return yield this.executeAutoabstract(body, debug);
});
const body = {
headline,
text,
keywords: keywords ? keywords.join(',') : '',
};
if (maxSentences) {
body.maxSentences = maxSentences;
}
else {
body.maxCharacters = maxCharacters;
}
return this.executeAutoabstract(body, debug);
}
clustering(articles, threshold = 0.8, language = ClusteringLanguage.de) {
return __awaiter(this, void 0, void 0, function* () {
const url = new url_1.URL(this.apolloApiEndpoint + this.clusteringEndpoint);
url.searchParams.append('threshold', threshold.toString());
url.searchParams.append('language', language);
const collectionResult = yield node_fetch_1.default(url.toString(), {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + this.apiKey,
},
body: JSON.stringify(articles),
timeout: 300000,
});
const clusterResult = yield collectionResult.json();
return clusterResult;
});
const url = new url_1.URL(this.apolloApiEndpoint + this.clusteringEndpoint);
url.searchParams.append('threshold', threshold.toString());
url.searchParams.append('language', language);
return node_fetch_1.default(url.toString(), {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + this.apiKey,
},
body: JSON.stringify(articles),
timeout: 300000,
}).then((clusteringResult) => clusteringResult.json());
}
continuedClustering(newArticles, presentArticles = [], options = {}) {
return __awaiter(this, void 0, void 0, function* () {
const parameters = { newArticles };
if (presentArticles && presentArticles.length > 0) {
parameters.result = presentArticles;
}
const url = new url_1.URL(this.apolloApiEndpoint + this.combinedApiEndpoint);
if (options.abstractMaxChars !== undefined) {
url.searchParams.append('maxChars', options.abstractMaxChars.toString());
}
if (options.keywords) {
url.searchParams.append('keywords', options.keywords.join(','));
}
if (options.threshold !== undefined) {
url.searchParams.append('threshold', options.threshold.toString());
}
if (options.language) {
url.searchParams.append('language', options.language);
}
const clusteringResult = yield node_fetch_1.default(url.toString(), {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + this.apiKey,
},
body: JSON.stringify(parameters),
timeout: 300000,
});
return yield clusteringResult.json();
});
const parameters = { newArticles };
if (presentArticles && presentArticles.length > 0) {
parameters.result = presentArticles;
}
const url = new url_1.URL(this.apolloApiEndpoint + this.combinedApiEndpoint);
if (options.abstractMaxChars !== undefined) {
url.searchParams.append('maxChars', options.abstractMaxChars.toString());
}
if (options.keywords) {
url.searchParams.append('keywords', options.keywords.join(','));
}
if (options.threshold !== undefined) {
url.searchParams.append('threshold', options.threshold.toString());
}
if (options.language) {
url.searchParams.append('language', options.language);
}
return node_fetch_1.default(url.toString(), {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + this.apiKey,
},
body: JSON.stringify(parameters),
timeout: 300000,
}).then((clusteringResult) => clusteringResult.json());
}

@@ -126,0 +110,0 @@ }

{
"name": "apollo-ai-api-client",
"version": "0.1.27",
"version": "0.2.0",
"description": "Client for the apollo.ai auto abstract api.",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc