Methods
call(user, text, sentence_splitopt, sentence_overlapopt, 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 | The input text from which the question-answer pairs will be generated. | ||
sentence_split |
number |
<optional> |
3 | The number of sentences of each chunk when splitting the input text. |
sentence_overlap |
boolean |
<optional> |
false | Whether to overlap adjacent chunks by 1 sentence. For example, with sentence_split 3 and sentence_overlap=true : [[s1, s2, s3], [s3, s4, s5], [s5, s6, s7]] |
engine |
string |
<optional> |
null | The LLM engine to be used. |
- Source:
Returns:
qna_list - dictionary list
A list of dictionaries representing question-answer pairs. Each dictionary contains the fields question, answer and chunk_index which is the index of the chunk the question-answer pair was generated from. chunk_index maps to the chunk with the same value in the key index.
chunks - dictionary list
A list of dictionaries representing the chunks as they were split from the original according to the splitting parameters given in the request. Each dictionary contains the fields text, index as well as the span_start and span_end fields which are the starting and ending position of the chunk in the originally provided text.
A list of dictionaries representing question-answer pairs. Each dictionary contains the fields question, answer and chunk_index which is the index of the chunk the question-answer pair was generated from. chunk_index maps to the chunk with the same value in the key index.
chunks - dictionary list
A list of dictionaries representing the chunks as they were split from the original according to the splitting parameters given in the request. Each dictionary contains the fields text, index as well as the span_start and span_end fields which are the starting and ending position of the chunk in the originally provided text.
- Type
- Promise.<Object>
Example
import { SoffosServices } from "soffosai";
const my_apiKey = "Token <put your api key here>";
const service = new SoffosServices.QuestionAndAnswerGenerationService({apiKey:my_apiKey});
let response = await service.call(
"me again",
"AI and specifically NLP is a very powerful component to any application that makes \
it powerful, interesting and creative. However, implementing the NLP components can \
sometimes be hard, or very costly in cases where an NLP engineering team has to be \
hired to build it. Especially, since NLP keeps evolving at an absurd rate, it might \
be impossible for a developer to keep up with the advancements in terms of work that \
needs to be done or money that need to be spent to keep their NLP at a state where it \
can compete with similar apps out there. Here at Soffos we have packaged several \
high-level functionalities as modules, some of which require multiple types of NLP and \
complex logic, for developers to use out-of-the-box, as is, removing the need to develop \
it themselves. Moreover, Soffos continuously updates their modules to match the state of \
the art. Developers will never need to maintain any AI/NLP related component of their \
application. All they need is to be creative, come up with ideas, and combine our modules \
however they desire to come up with amazing intelligent applications."
);
console.log(JSON.stringify(response, null, 2));
// returns
// {
// "qna_list": [
// {
// "question": "What is NLP?",
// "answer": "NLP stands for Natural Language Processing, which is a branch of Artificial Intelligence that deals with understanding and generating human language.",
// "chunk_index": 0
// },
// {
// "question": "What makes NLP powerful?",
// "answer": "NLP is powerful because it can understand and generate human language, which makes it a powerful component to any application.",
// "chunk_index": 0
// },
// {
// "question": "What can be difficult about implementing NLP components?",
// "answer": "Implementing NLP components can be difficult because it can be hard to keep up with the advancements in terms of work that needs to be done or money that need to be spent to keep their NLP at a state where it can compete with similar apps out there.",
// "chunk_index": 0
// },
// {
// "question": "What does Soffos offer developers?",
// "answer": "Soffos offers developers high-level functionalities packaged as modules, which require multiple types of NLP and complex logic, for developers to use out-of-the-box, as is, removing the need to develop it themselves.",
// "chunk_index": 1
// },
// {
// "question": "Does Soffos maintain AI/NLP related components?",
// "answer": "Yes, Soffos continuously updates their modules to match the state of the art and developers will never need to maintain any
// AI/NLP related component of their application.",
// "chunk_index": 1
// },
// {
// "question": "What is required to create intelligent applications?",
// "answer": "Creativity, ideas, and the ability to combine modules.",
// "chunk_index": 2
// }
// ],
// "chunks": [
// {
// "text": "AI and specifically NLP is a very powerful component to any application that makes it powerful, interesting and creative. However, implementing the NLP components can sometimes be hard, or very costly in cases where an NLP engineering team has to be hired to build it. Especially, since NLP keeps evolving at an absurd rate, it might be impossible for a developer to keep up with the advancements in terms of work that needs to be done or money that need to be spent to keep their NLP at a state where it can compete with similar apps out there.",
// "span_start": 0,
// "span_end": 545,
// "index": 0
// },
// {
// "text": "Here at Soffos we have packaged several high-level functionalities as modules, some of which require multiple types of NLP and complex logic, for developers to use out-of-the-box, as is, removing the need to develop it themselves. Moreover, Soffos continuously updates their modules to match the state of the art. Developers will never need to maintain any AI/NLP related component of their application.",
// "span_start": 546,
// "span_end": 949,
// "index": 1
// },
// {
// "text": "All they need is to be creative, come up with ideas, and combine our modules however they desire to come up with amazing intelligent applications.",
// "span_start": 950,
// "span_end": 1096,
// "index": 2
// }
// ],
// "cost": {
// "api_call_cost": 0.005,
// "character_volume_cost": 0.05945,
// "total_cost": 0.06445
// },
// "charged_character_count": 1189,
// "unit_price": "0.000050"
// }
setInputConfigs(name, text, sentence_splitopt, sentence_overlapopt, 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 | The input text from which the question-answer pairs will be generated. | ||
sentence_split |
number | InputConfig |
<optional> |
3 | The number of sentences of each chunk when splitting the input text. |
sentence_overlap |
boolean | InputConfig |
<optional> |
false | Whether to overlap adjacent chunks by 1 sentence. For example, with sentence_split 3 and sentence_overlap=true : [[s1, s2, s3], [s3, s4, s5], [s5, s6, s7]] |
engine |
string |
<optional> |
null | The LLM engine to be used. |
- Source: