Methods
call(user, text, typesopt, nopt, 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 extract keywords from. | ||
types |
Array.<string> |
<optional> |
["topic"] | List of types of keywords to extract. Supported types: topic: Tags relating to the subject matter of the text. domain: Tags relating to the domain of the text. For example, "AI", or "Science fiction". In some cases, domain tags might be similar to topic tags. audience: Tags relating to the type of audience the text is intended for. entity: Entities such as people, places, products, etc. mentioned in the text. |
n |
number |
<optional> |
10 | The number of tags to be generated for each of the specified tag types. |
engine |
string |
<optional> |
null | The LLM engine to be used. |
- Source:
Returns:
tags - dictionary dictionary
A dictionary containing the tags grouped by the type of tag. A confidence score is provided also for each tag.
A dictionary containing the tags grouped by the type of tag. A confidence score is provided also for each tag.
- Type
- Promise.<Object>
Example
import { SoffosServices } from "soffosai";
const my_apiKey = "Token <put your api key here>";
const service = new SoffosServices.TagGenerationService({apiKey:my_apiKey});
let response = await service.call(
"Client 12345",
"The paper presents the design and implementation of a restaurant recommender system \
using sentiment analysis and deep learning models...",
["topic", "domain", "audience", "entity"],
5
);
console.log(JSON.stringify(response, null, 2));
// returns
// {
// "tags": {
// "entity": [
// {
// "tag": "TripAdvisor",
// "score": 0.95
// },
// {
// "tag": "LSTM",
// "score": 0.9
// },
// {
// "tag": "restaurant recommender system",
// "score": 0.88
// },
// {
// "tag": "user reviews",
// "score": 0.85
// },
// {
// "tag": "deep learning models",
// "score": 0.83
// }
// ],
// "domain": [
// {
// "tag": "sentiment analysis",
// "score": 0.92
// },
// {
// "tag": "information filtering",
// "score": 0.89
// },
// {
// "tag": "recommendation systems",
// "score": 0.87
// },
// {
// "tag": "machine learning",
// "score": 0.84
// },
// {
// "tag": "natural language processing",
// "score": 0.82
// }
// ],
// "topic": [
// {
// "tag": "food",
// "score": 0.91
// },
// {
// "tag": "service",
// "score": 0.9
// },
// {
// "tag": "ambiance",
// "score": 0.89
// },
// {
// "tag": "user preferences",
// "score": 0.88
// },
// {
// "tag": "information overload",
// "score": 0.86
// }
// ],
// "audience": [
// {
// "tag": "restaurant goers",
// "score": 0.93
// },
// {
// "tag": "food enthusiasts",
// "score": 0.91
// },
// {
// "tag": "travelers",
// "score": 0.89
// },
// {
// "tag": "review readers",
// "score": 0.87
// },
// {
// "tag": "tech researchers",
// "score": 0.85
// }
// ]
// },
// "cost": {
// "api_call_cost": 0.005,
// "character_volume_cost": 0.00745,
// "total_cost": 0.01245
// },
// "engine": "gpt-4o",
// "charged_character_count": 149,
// "unit_price": "0.000050"
// }
setInputConfigs(name, text, typesopt, n, 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 extract keywords from. | ||
types |
Array.<string> | InputConfig |
<optional> |
["topic"] | List of types of keywords to extract. Supported types: topic: Tags relating to the subject matter of the text. domain: Tags relating to the domain of the text. For example, "AI", or "Science fiction". In some cases, domain tags might be similar to topic tags. audience: Tags relating to the type of audience the text is intended for. entity: Entities such as people, places, products, etc. mentioned in the text. |
n |
number | InputConfig | 10 | The number of tags to be generated for each of the specified tag types. | |
engine |
string |
<optional> |
null | The LLM engine to be used. |
- Source: