Class: SummarizationService

SummarizationService()

The summarization module utilizes Natural Language Generation (NLG) to generate an abstractive summary of a specified length. In contrast to extractive summarization methods, which simply calculate the centrality of sentences or passages in the original text and concatenate the highest rated ones, abstractive summaries are often more concise and accurate. The end result isn't necessarily a sum of word-for-word copies of passages from the original text, but a combination of all key points formulated as a new text.

Constructor

new SummarizationService()

Source:

Methods

call(user, text, sent_length, engineopt) → {Promise.<Object>}

Parameters:
Name Type Attributes Default Description
user string The ID of the user accessing the Soffos API. Soffos assumes that the owner of the api is an application (app) and that app has users. Soffos API will accept any string.
text string Text to be summarized.
sent_length number The desired sentence length of the summary. The service will respond with a 403 error if the value is larger than the number of sentences in the text.
engine string <optional>
null The LLM engine to be used.
Source:
Returns:
summary - string
The summary.
error - string
When the specified sent_length is larger than the number of sentences, the service will return a 403 error along with a json with the error field and the error message.
Type
Promise.<Object>
Example
import { SoffosServices } from "soffosai";

const my_apiKey = "Token <put your api key here>";
const service = new SoffosServices.SummarizationService({apiKey:my_apiKey});
let response = await service.call(
    "client 23456",
    "Ludwig van Beethoven (baptised 17 December 1770 – 26 March 1827) was a German \
    composer and pianist. ... After some months of bedridden illness, he died in 1827. \
    Beethoven's works remain mainstays of the classical music repertoire.",
    3
);
console.log(JSON.stringify(response, null, 2));
    
// returns
// {
//     "summary": "Ludwig van Beethoven was a German composer and pianist. He composed many works that remain mainstays of the classical music repertoire. After a period of illness, he died in 1827.",
//     "cost": {
//       "api_call_cost": 0.005,
//       "character_volume_cost": 0.0119,
//       "total_cost": 0.0169
//     },
//     "charged_character_count": 238,
//     "unit_price": "0.000050"
// }

setInputConfigs(name, text, sent_length, engineopt)

Parameters:
Name Type Attributes Default Description
name string Reference name of this Service. It will be used by the Pipeline to reference this Service.
text string | InputConfig Text to be summarized.
sent_length number | InputConfig The desired sentence length of the summary. The service will respond with a 403 error if the value is larger than the number of sentences in the text.
engine string <optional>
null The LLM engine to be used.
Source: