mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
* [ACS-9564] Corrected models after change of Knowledge Retrieval answer structure * [ACS-9564] Changed id * [ACS-9564] Fixed unit tests
5.7 KiB
5.7 KiB
SearchAiApi
Method | HTTP request | Description |
---|---|---|
ask | GET /questions | Ask a question to the AI. |
getAnswer | GET /answers/-default- | Get an answer to specific question. |
getConfig | GET /config/-default- | Get the knowledge retrieval configuration. |
ask
Ask a question to the AI. A list is returned in the response body. For example:
[
{
"question": "Some question",
"questionId": "Some question id",
"restrictionQuery": "Some restriction query"
}
]
Example
import { AlfrescoApi, AgentsApi } from '@alfresco/js-api';
const alfrescoApi = new AlfrescoApi(/*..*/);
const searchAiApi = new SearchAiApi(alfrescoApi);
searchAiApi.ask([{
question: 'Some question',
restrictionQuery: 'Some restriction query',
agentId: 'Some agent id'
}]).then((questionInformation) => {
console.log('API called successfully. Returned data: ' + questionInformation);
});
Parameters
Name | Type | Description |
---|---|---|
questions | QuestionRequest[] | The questions to ask. |
Return type: QuestionModel[]
getAnswer
Get an answer to specific question. A paginated list is returned in the response body. For example:
{
"entry": {
"answer": "Some answer",
"question": "Some question",
"complete": true,
"objectReferences": [
{
"objectId": "some-object-id",
"references": [
{
"referenceId": "some-reference-id1",
"rankScore": 0.031,
"rank": 2
},
{
"referenceId": "some-reference-id2",
"rankScore": 0.031,
"rank": 1
},
{
"referenceId": "some-reference-id3",
"rankScore": 0.028,
"rank": 3
}
]
}
]
}
}
Example
import { AlfrescoApi, AgentsApi } from '@alfresco/js-api';
const alfrescoApi = new AlfrescoApi(/*..*/);
const searchAiApi = new SearchAiApi(alfrescoApi);
searchAiApi.getAnswer('some question id').then((answer) => {
console.log('API called successfully. Returned data: ' + answer);
});
Parameters
Name | Type | Description |
---|---|---|
questionId | string | The ID of the question to get an answer for. |
Return type: AiAnswerEntry
getConfig
Get the knowledge retrieval configuration. For example:
{
"entry": {
"knowledgeRetrievalUrl": "https://some-url"
}
}
Example
import { AlfrescoApi, AgentsApi } from '@alfresco/js-api';
const alfrescoApi = new AlfrescoApi(/*..*/);
const searchAiApi = new SearchAiApi(alfrescoApi);
searchAiApi.getConfig().then((answer) => {
console.log('API called successfully. Returned data: ', answer.entry.knowledgeRetrievalUrl);
});
Return type: KnowledgeRetrievalConfigEntry
Models
AiAnswerEntry
Properties
Name | Type |
---|---|
entry | AiAnswer |
AiAnswer
Properties
Name | Type |
---|---|
answer | string |
question | string |
complete | boolean |
objectReferences | AiAnswerObjectReference[] |
AiAnswerObjectReference
Properties
Name | Type |
---|---|
objectId | string |
references | AiAnswerReference[] |
AiAnswerReference
Properties
Name | Type |
---|---|
referenceId | string |
rankScore | number |
rank | number |
QuestionModel
Properties
Name | Type |
---|---|
question | string |
questionId | string |
restrictionQuery | RestrictionQuery |
RestrictionQuery
Properties
Name | Type |
---|---|
nodesIds | string[] |
QuestionRequest
Properties
Name | Type |
---|---|
question | string |
nodeIds | string[] |
agentId | string |
KnowledgeRetrievalConfigEntry
Properties
Name | Type |
---|---|
entry | KnowledgeRetrievalConfig |
KnowledgeRetrievalConfig
Properties
Name | Type |
---|---|
knowledgeRetrievalUrl | string |