apollo-ai-api-client
Advanced tools
Comparing version 0.1.6 to 0.1.8
@@ -9,6 +9,25 @@ export interface IAutoAbstractResponse { | ||
} | ||
export interface IClusteringResponse { | ||
status: number; | ||
message: string; | ||
data: IClusteringArticle[][]; | ||
} | ||
export interface IClusteringArticle { | ||
identifier: string; | ||
title: string; | ||
content: string; | ||
link?: string; | ||
publication_date?: string; | ||
image?: string; | ||
} | ||
export declare enum ClusteringLanguage { | ||
en = "en", | ||
de = "de" | ||
} | ||
export declare class ApolloAiClient { | ||
protected apiKey: string; | ||
apolloApiEndpoint: string; | ||
constructor(apiKey: string); | ||
autoabstract(headline: string, text: string, maxCharacters?: number, keywords?: string[]): Promise<IAutoAbstractResponse>; | ||
clustering(articles: IClusteringArticle[], threshold?: number, language?: ClusteringLanguage): Promise<IClusteringResponse>; | ||
} |
@@ -12,5 +12,12 @@ "use strict"; | ||
const node_fetch_1 = require("node-fetch"); | ||
const URL = require("url"); | ||
var ClusteringLanguage; | ||
(function (ClusteringLanguage) { | ||
ClusteringLanguage["en"] = "en"; | ||
ClusteringLanguage["de"] = "de"; | ||
})(ClusteringLanguage = exports.ClusteringLanguage || (exports.ClusteringLanguage = {})); | ||
class ApolloAiClient { | ||
constructor(apiKey) { | ||
this.apiKey = apiKey; | ||
this.apolloApiEndpoint = 'https://api.apollo.ai/'; | ||
} | ||
@@ -28,3 +35,3 @@ autoabstract(headline, text, maxCharacters = 400, keywords) { | ||
} | ||
const response = yield node_fetch_1.default('https://api.apollo.ai/autoabstract', { | ||
const response = yield node_fetch_1.default(this.apolloApiEndpoint + 'autoabstract', { | ||
method: 'POST', | ||
@@ -44,4 +51,24 @@ headers: { | ||
} | ||
clustering(articles, threshold = 0.8, language = ClusteringLanguage.de) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const url = new URL.URL(this.apolloApiEndpoint + 'clustering'); | ||
url.searchParams.append('threshold', threshold.toString()); | ||
url.searchParams.append('language', language); | ||
console.log('Requesting: ' + url.toString()); | ||
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; | ||
}); | ||
} | ||
} | ||
exports.ApolloAiClient = ApolloAiClient; | ||
//# sourceMappingURL=ApolloAiClient.js.map |
{ | ||
"name": "apollo-ai-api-client", | ||
"version": "0.1.6", | ||
"version": "0.1.8", | ||
"description": "Client for the apollo.ai auto abstract api.", | ||
"keywords": ["api client", "text processing", "auto abstract"], | ||
"keywords": [ | ||
"api client", | ||
"text processing", | ||
"auto abstract" | ||
], | ||
"homepage": "https://www.apollo.ai", | ||
"author": "APOLLO.AI", | ||
"license": "MIT", | ||
"repository" : { | ||
"type" : "git", | ||
"url" : "https://github.com/IWAtech/apollo.ai-api-client.git" | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/IWAtech/apollo.ai-api-client.git" | ||
}, | ||
@@ -21,3 +25,3 @@ "private": false, | ||
"clean": "rm -rf lib", | ||
"lint": "tslint -c tslint.json verbose \"src/**/*.ts\"", | ||
"lint": "tslint -c tslint.json \"src/**/*.ts\"", | ||
"build": "yarn run lint && echo Using TypeScript && tsc --version && tsc --pretty -p ." | ||
@@ -24,0 +28,0 @@ }, |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
9018
109