Files
alfresco-ng2-components/lib/js-api/src/api/content-rest-api/docs/SearchAiApi.md
AleksanderSklorz 0a717d612f [ACS-8664] generic question redirection to hx insight (#10174)
* ACS-8664 Loading HX insight url

* ACS-8664 Added documentation for loading config of Knowledge Retrieval

* ACS-8664 Unit tests

* ACS-8664 Fixed unit tests

* ACS-8664 Fixed unit tests after rebase

* ACS-8664 Addressed comment
2024-09-09 13:11:41 +02:00

5.0 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:

{
    "list": {
        "pagination": {
            "count": 2,
            "hasMoreItems": false,
            "totalItems": 2,
            "skipCount": 0,
            "maxItems": 100
        },
        "entries": [
            {
                "entry": {
                    "answer": "Some answer",
                    "questionId": "Some question id",
                    "references": [
                        {
                            "referenceId": "Some reference id",
                            "referenceText": "Some reference text"
                        }
                    ]
                }
            }
        ]
    }
}

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
questionId string
references AiAnswerReference[]

AiAnswerReference

Properties

Name Type
referenceId string
referenceText string

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