[ACS-8202] basic flow getting ai response for one or more selected files (#9944)

* ACS-8202 Getting list of agents

* ACS-8202 Mocked agents, used base api from hxi connector

* ACS-8202 Search Ai service

* ACS-8202 Small correction and mocked data

* ACS-8202 Renamed variable

* ACS-8202 Added documentation

* ACS-8202 Addressed PR comments

* ACS-8202 Type change

* ACS-8202 Reverted unwatend change

* ACS-8202 Reverted unwanted change
This commit is contained in:
AleksanderSklorz
2024-07-16 15:12:13 +02:00
committed by Aleksander Sklorz
parent 7506c109d8
commit fd32667c1a
33 changed files with 1018 additions and 4 deletions

View File

@@ -0,0 +1,162 @@
# SearchAiApi
| Method | HTTP request | Description |
|-------------------------|--------------------|-------------------------------------|
| [ask](#ask) | **GET** /questions | Ask a question to the AI. |
| [getAnswer](#getAnswer) | **GET** /answers | Get an answer to specific question. |
## ask
Ask a question to the AI.
A list is returned in the response body. For example:
```json
[
{
"question": "Some question",
"questionId": "Some question id",
"restrictionQuery": "Some restriction query"
}
]
```
**Example**
```javascript
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'
}]).then((questionInformation) => {
console.log('API called successfully. Returned data: ' + questionInformation);
});
```
**Parameters**
| Name | Type | Description |
|---------------|---------------------------------------|-----------------------|
| **questions** | [QuestionRequest](#QuestionRequest)[] | The questions to ask. |
**Return type**: [QuestionModel](#QuestionModel)[]
## getAnswer
Get an answer to specific question.
A paginated list is returned in the response body. For example:
```json
{
"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**
```javascript
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**: [AiAnswerPaging](#AiAnswerPaging)
# Models
## AiAnswerPaging
**Properties**
| Name | Type |
|------|-------------------------------------------|
| list | [AiAnswerPagingList](#AiAnswerPagingList) |
## AiAnswerPagingList
**Properties**
| Name | Type |
|----------------|-----------------------------------|
| **pagination** | [Pagination](Pagination.md) |
| **entries** | [AiAnswerEntry[]](#AiAnswerEntry) |
## AiAnswerEntry
**Properties**
| Name | Type |
|-----------|-----------------------|
| **entry** | [AiAnswer](#AiAnswer) |
## AiAnswer
**Properties**
| Name | Type |
|----------------|-------------------------------------------|
| **answer** | string |
| **questionId** | string |
| **references** | [AiAnswerReference](#AiAnswerReference)[] |
## AiAnswerReference
**Properties**
| Name | Type |
|-------------------|--------|
| **referenceId** | string |
| **referenceText** | string |
## QuestionModel
**Properties**
| Name | Type |
|----------------------|--------|
| **question** | string |
| **questionId** | string |
| **restrictionQuery** | string |
## QuestionRequest
**Properties**
| Name | Type |
|--------------|----------|
| **question** | string |
| **nodeIds** | string[] |