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.2.2 to 0.2.3

6

lib/apollo.ai/ApolloAiClient.d.ts

@@ -46,3 +46,3 @@ export interface IAutoAbstractResponse {

export interface IContinuousClustering {
newArticles?: IArticle[] | string[];
newArticles?: Array<IArticle | string>;
result?: IContinuousClusteringResultItem[];

@@ -77,6 +77,6 @@ }

private executeAutoabstract;
autoabstractUrl(url: string, maxCharacters?: number, keywords?: string[], maxSentences?: number, debug?: boolean): Promise<IAutoAbstractResponse>;
autoabstractUrl(endpointUrl: string, maxCharacters?: number, keywords?: string[], maxSentences?: number, debug?: boolean): Promise<IAutoAbstractResponse>;
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?: IContinuousClusteringResultItem[], options?: IContinuousClusteringOptions): Promise<IContinuousClusteringResponse>;
continuedClustering(newArticles: Array<IArticle | string>, presentArticles?: IContinuousClusteringResultItem[], options?: IContinuousClusteringOptions): Promise<IContinuousClusteringResponse>;
}

@@ -5,2 +5,3 @@ "use strict";

const url_1 = require("url");
const _ = require("lodash");
var ClusteringLanguage;

@@ -40,5 +41,5 @@ (function (ClusteringLanguage) {

}
autoabstractUrl(url, maxCharacters = 400, keywords, maxSentences, debug) {
autoabstractUrl(endpointUrl, maxCharacters = 400, keywords, maxSentences, debug) {
const body = {
url,
url: endpointUrl,
keywords: keywords ? keywords.join(',') : '',

@@ -69,6 +70,6 @@ };

clustering(articles, threshold = 0.8, language = ClusteringLanguage.de) {
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(), {
const endpointUrl = new url_1.URL(this.apolloApiEndpoint + this.clusteringEndpoint);
endpointUrl.searchParams.append('threshold', threshold.toString());
endpointUrl.searchParams.append('language', language);
return node_fetch_1.default(endpointUrl.toString(), {
method: 'POST',

@@ -89,2 +90,25 @@ headers: {

}
else {
parameters.result = [];
}
const newArticleIds = newArticles.map((nA) => {
if (typeof nA === 'string') {
return nA;
}
else {
return nA.id;
}
});
const presentArticleIds = presentArticles.map((pA, index) => {
if (pA && pA.article && pA.article.id) {
return pA.article.id;
}
else {
throw new Error('Invalid present Article' + pA + ' at position ' + index);
}
});
const duplicates = _.intersection(newArticleIds, presentArticleIds);
if (duplicates.length !== 0) {
throw new Error('Passing the same article in newArticles and presentArticles is not allowed.');
}
const url = new url_1.URL(this.apolloApiEndpoint + this.combinedApiEndpoint);

@@ -112,3 +136,11 @@ if (options.abstractMaxChars !== undefined) {

timeout: 300000,
}).then((clusteringResult) => clusteringResult.json());
}).then((clusteringResult) => {
return clusteringResult.json().catch((e) => {
console.log(e);
return Promise.reject(e);
});
}, (error) => {
console.log(error);
return Promise.reject(error);
});
}

@@ -115,0 +147,0 @@ }

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

@@ -29,9 +29,11 @@ "keywords": [

"dependencies": {
"node-fetch": "^1.7.1"
"lodash": "^4.17.11",
"node-fetch": "^2.2.0"
},
"devDependencies": {
"@types/node": "^8.0.14",
"@types/node-fetch": "^1.6.7",
"tslint": "^5.4.3",
"typescript": "^2.4.0"
"@types/lodash": "^4.14.116",
"@types/node": "^10.11.0",
"@types/node-fetch": "^2.1.2",
"tslint": "^5.11.0",
"typescript": "^3.0.3"
},

@@ -38,0 +40,0 @@ "engines": {

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