[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

@@ -369,6 +369,7 @@ for more information about installing and using the source code.
| Name | Description | Source link |
| ---- | ----------- | ----------- |
| [Agent Service](content-services/services/agent.service.md) | Manages agents in Content Services. | [Source](../lib/content-services/src/lib/agent/services/agent.service.ts) |
| [Audit Service](content-services/services/audit.service.md) | Manages Audit apps and entries. | [Source](../lib/content-services/src/lib/audit/audit.service.ts) |
| [Card View Content Update Service](content-services/services/card-view-content-update.service.md) | Manages Card View properties in the content services environment. Implements BaseCardViewContentUpdate. | [Source](../lib/content-services/src/lib/common/services/card-view-content-update.service.ts) | |
| [Category tree datasource service](content-services/services/category-tree-datasource.service.md) | Datasource service for category tree. | [Source](../lib/content-services/src/lib/category/services/category-tree-datasource.service.ts) |
@@ -384,6 +385,7 @@ for more information about installing and using the source code.
| [Node Comments Service](content-services/services/node-comments.service.md) | Adds and retrieves comments for nodes in Content Services. | [Source](../lib/content-services/src/lib/node-comments/services/node-comments.service.ts) |
| [Node permission dialog service](content-services/services/node-permission-dialog.service.md) | Displays dialogs to let the user set node permissions. | [Source](../lib/content-services/src/lib/permission-manager/services/node-permission-dialog.service.ts) |
| [Node Permission service](content-services/services/node-permission.service.md) | Manages role permissions for content nodes. | [Source](../lib/content-services/src/lib/permission-manager/services/node-permission.service.ts) |
| [Search Ai Service](content-services/services/search-ai.service.md) | Manages search AI in Content Services. | [Source](../lib/content-services/src/lib/search-ai/services/search-ai.service.ts) |
| [Search filter service](content-services/services/search-filter.service.md) | Registers widgets for use with the Search Filter component. | [Source](../lib/content-services/src/lib/search/services/search-filter.service.ts) |
| [Search Query Builder service](content-services/services/search-query-builder.service.md) | Stores information from all the custom search and faceted search widgets, compiles and runs the final search query. | [Source](../lib/content-services/src/lib/search/services/search-query-builder.service.ts) |
| [Security Controls service](content-services/services/security-controls.service.md) | Manages security groups & marks in Content Services. | [Source](../lib/content-services/src/lib/security/services/security-controls-groups-marks-security.service.ts) |

View File

@@ -0,0 +1,26 @@
---
Title: Agent service
Added: v6.9.1
Status: Active
Last reviewed: 2024-07-12
---
# [Agent service](../../../lib/content-services/src/lib/agent/services/agent.service.ts "Defined in agent.service.ts")
Manages agents in Content Services.
## Class members
### Methods
- **getAgents**(mocked?: `boolean`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`AgentPaging`](../../../lib/js-api/src/api/content-rest-api/docs/AgentsApi.md#agentpaging)`>`<br/>
Gets all agents.
- _mocked:_ `boolean` - (Optional) Temporary parameter to mock agents. Should be removed when backend implemented. True by default.
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`AgentPaging`](../../../lib/js-api/src/api/content-rest-api/docs/AgentsApi.md#agentpaging)`>` - AgentPaging object containing the agents.
## Details
See the
[Agents API](../../../lib/js-api/src/api/content-rest-api/docs/AgentsApi.md) for more information about the types returned by [Agent
service](agent.service.md) methods and for the implementation of the REST API the service is
based on.

View File

@@ -0,0 +1,40 @@
---
Title: Search Ai service
Added: v6.9.1
Status: Active
Last reviewed: 2024-07-12
---
# [Search Ai service](../../../lib/content-services/src/lib/search-ai/services/search-ai.service.ts "Defined in search-ai.service.ts")
Manages search AI in Content Services.
## Class members
### Methods
- **updateSearchAiInputState**(state: `SearchAiInputState`): `void`<br/>
Update the state of the search AI input.
- _state:_ `SearchAiInputState` - The new state of the search AI input.
- **ask**(question: [`QuestionRequest`](../../../lib/js-api/src/api/content-rest-api/docs/SearchAiApi.md#questionrequest)): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`QuestionModel`](../../../lib/js-api/src/api/content-rest-api/docs/SearchAiApi.md#questionmodel)`>`<br/>
Ask a question to the AI.
- _question:_ [`QuestionRequest`](../../../lib/js-api/src/api/content-rest-api/docs/SearchAiApi.md#questionrequest) - The question to ask.
- _mocked:_ `boolean` - (Optional) temporary parameter to mock returned information about question. Should be removed when backend implemented. True by default.
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`QuestionModel`](../../../lib/js-api/src/api/content-rest-api/docs/SearchAiApi.md#questionmodel)`>` - QuestionModel object containing information about questions.
- **getAnswer**(questionId: `string`, mocked?: `boolean`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`AiAnswerPaging`](../../../lib/js-api/src/api/content-rest-api/docs/SearchAiApi.md#aianswerpaging)`>`<br/>
Get an answer to specific question.
- _questionId:_ `string` - The ID of the question to get an answer for.
- _mocked:_ `boolean` - (Optional) temporary parameter to mock answer on question. Should be removed when backend implemented. True by default.
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`AiAnswerPaging`](../../../lib/js-api/src/api/content-rest-api/docs/SearchAiApi.md#aianswerpaging)`>` - AiAnswerPaging object containing the answer.
- **checkSearchAvailability**(selectedNodesState: `SelectionState`, maxSelectedNodes: `number`): `string`<br/>
Check if using of search is possible (if all conditions are met).
- _selectedNodesState:_ `SelectionState` - information about selected nodes.
- _maxSelectedNodes:_ `number` - max number of selected nodes. Default 100.
- **Returns** `string` - string with error if any condition is not met, empty string otherwise.
## Details
See the
[Search Ai API](../../../lib/js-api/src/api/content-rest-api/docs/SearchAiApi.md) for more information about the types returned by [Search Ai
service](search-ai.service.md) methods and for the implementation of the REST API the service is
based on.

View File

@@ -12,6 +12,7 @@ backend services have been tested with each released version of ADF.
## Versions
- [v6.9.1](#v691)
- [v6.8.0](#v680)
- [v6.7.0](#v670)
- [v6.4.0](#v640)
@@ -46,6 +47,16 @@ backend services have been tested with each released version of ADF.
- [v2.1.0](#v210)
- [v2.0.0](#v200)
## v6.9.1
<!--691 start-->
- [AgentService](content-services/services/agent.service.md)
- [SearchAiService](content-services/services/search-ai.service.md)
<!--691 end-->
## v6.8.0
<!--680 start-->

View File

@@ -0,0 +1,18 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './public-api';

View File

@@ -0,0 +1,18 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './services/agent.service';

View File

@@ -0,0 +1,74 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Injectable } from '@angular/core';
import { AgentPaging, AgentsApi } from '@alfresco/js-api';
import { AlfrescoApiService } from '@alfresco/adf-core';
import { from, Observable, of } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class AgentService {
private _agentsApi: AgentsApi;
private _mocked = true;
get agentsApi(): AgentsApi {
this._agentsApi = this._agentsApi ?? new AgentsApi(this.apiService.getInstance());
return this._agentsApi;
}
set mocked(mocked: boolean) {
this._mocked = mocked;
}
constructor(private apiService: AlfrescoApiService) {}
/**
* Gets all agents.
*
* @returns AgentPaging object containing the agents.
*/
getAgents(): Observable<AgentPaging> {
return this._mocked
? of({
list: {
entries: [
{
entry: {
id: '1',
name: 'HR Agent'
}
},
{
entry: {
id: '2',
name: 'Policy Agent'
}
},
{
entry: {
id: '3',
name: 'Rules & Rates Agent'
}
}
]
}
})
: from(this.agentsApi.getAgents());
}
}

View File

@@ -701,5 +701,15 @@
"JOIN_CANCELED": "Canceled the request to join the library",
"JOIN_REQUESTED": "Request sent to join this library"
}
},
"KNOWLEDGE_RETRIEVAL": {
"SEARCH": {
"WARNINGS": {
"NO_FILES_SELECTED": "Please select some file.",
"TOO_MANY_FILES_SELECTED": "Please select no more than {{ maxFiles }} files.",
"NON_TEXT_FILE_SELECTED": "Only text related files are compatible with AI Agents.",
"FOLDER_SELECTED": "Folders are not compatible with AI Agents."
}
}
}
}

View File

@@ -0,0 +1,18 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './public-api';

View File

@@ -0,0 +1,21 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface SearchAiInputState {
active: boolean;
selectedAgentId?: string;
}

View File

@@ -0,0 +1,19 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './services/search-ai.service';
export * from './models/search-ai-input-state';

View File

@@ -0,0 +1,159 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Injectable } from '@angular/core';
import { AiAnswerPaging, QuestionModel, QuestionRequest, SearchAiApi } from '@alfresco/js-api';
import { AlfrescoApiService } from '@alfresco/adf-core';
import { BehaviorSubject, from, Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { SelectionState } from '@alfresco/adf-extensions';
import { TranslateService } from '@ngx-translate/core';
import { SearchAiInputState } from '../models/search-ai-input-state';
@Injectable({
providedIn: 'root'
})
export class SearchAiService {
private readonly textFileMimeTypes = [
'application/msword',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.oasis.opendocument.text',
'application/rtf',
'text/plain',
'application/pdf'
];
private toggleSearchAiInput = new BehaviorSubject<SearchAiInputState>({
active: false
});
private _searchAiApi: SearchAiApi;
private _mocked = true;
get searchAiApi(): SearchAiApi {
this._searchAiApi = this._searchAiApi ?? new SearchAiApi(this.apiService.getInstance());
return this._searchAiApi;
}
set mocked(mocked: boolean) {
this._mocked = mocked;
}
toggleSearchAiInput$ = this.toggleSearchAiInput.asObservable();
constructor(private apiService: AlfrescoApiService, private translateService: TranslateService) {}
/**
* Update the state of the search AI input.
*
* @param state The new state of the search AI input.
*/
updateSearchAiInputState(state: SearchAiInputState): void {
this.toggleSearchAiInput.next(state);
}
/**
* Ask a question to the AI.
*
* @param question The question to ask.
* @returns QuestionModel object containing information about questions.
*/
ask(question: QuestionRequest): Observable<QuestionModel> {
return this._mocked
? of({
question: 'Some question',
questionId: 'some id',
restrictionQuery: 'Some restriction query'
})
: from(this.searchAiApi.ask([question])).pipe(map((questions) => questions[0]));
}
/**
* Get an answer to specific question.
*
* @param questionId The ID of the question to get an answer for.
* @returns AiAnswerPaging object containing the answer.
*/
getAnswer(questionId: string): Observable<AiAnswerPaging> {
return this._mocked
? of({
list: {
pagination: {
count: 1,
hasMoreItems: false,
totalItems: 1,
skipCount: 0,
maxItems: 100
},
entries: [
{
entry: {
answer: 'Some answer',
questionId: 'some id',
references: [
{
referenceId: '5bccf580-c5de-4d60-a59f-09e553366039',
referenceText: 'some type'
},
{
referenceId: 'fbcf160a-1139-467f-9e57-d17f52db48c3',
referenceText: 'some type'
}
]
}
}
]
}
})
: from(this.searchAiApi.getAnswer(questionId));
}
/**
* Check if using of search is possible (if all conditions are met).
*
* @param selectedNodesState information about selected nodes.
* @param maxSelectedNodes max number of selected nodes. Default 100.
* @returns string with error if any condition is not met, empty string otherwise.
*/
checkSearchAvailability(selectedNodesState: SelectionState, maxSelectedNodes = 100): string {
const messages: {
key: string;
[parameter: string]: number | string;
}[] = [];
if (selectedNodesState.count === 0) {
messages.push({
key: 'KNOWLEDGE_RETRIEVAL.SEARCH.WARNINGS.NO_FILES_SELECTED'
});
}
if (selectedNodesState.count > maxSelectedNodes) {
messages.push({
key: 'KNOWLEDGE_RETRIEVAL.SEARCH.WARNINGS.TOO_MANY_FILES_SELECTED',
maxFiles: maxSelectedNodes
});
}
if (selectedNodesState.nodes.some((node) => !node.entry.isFolder && !this.textFileMimeTypes.includes(node.entry.content.mimeType))) {
messages.push({
key: 'KNOWLEDGE_RETRIEVAL.SEARCH.WARNINGS.NON_TEXT_FILE_SELECTED'
});
}
if (selectedNodesState.nodes.some((node) => node.entry.isFolder)) {
messages.push({
key: 'KNOWLEDGE_RETRIEVAL.SEARCH.WARNINGS.FOLDER_SELECTED'
});
}
return messages.map((message) => this.translateService.instant(message.key, message)).join(' ');
}
}

View File

@@ -49,6 +49,8 @@ export * from './lib/prediction/index';
export * from './lib/legal-hold/index';
export * from './lib/api-factories';
export * from './lib/mock/alfresco-api.service.mock';
export * from './lib/agent/index';
export * from './lib/search-ai/index';
export * from './lib/content.module';
export * from './lib/material.module';

View File

@@ -18,11 +18,12 @@ adf-unsaved-changes-dialog {
&-discard-changes-button {
color: var(--theme-warn-color-default-contrast);
background-color: var(--adf-danger-button-background);
background-color: var(--adf-error-color);
min-width: 143px;
}
&-cancel-button, &-discard-changes-button {
&-cancel-button,
&-discard-changes-button {
padding: 4px 14px;
height: 32px;
display: flex;

View File

@@ -86,7 +86,7 @@
--adf-header-icon-button-hover-color: $adf-ref-header-icon-color,
--adf-header-icon-button-pressed-color: $adf-ref-header-icon-color,
--adf-header-icon-button-disabled-color: $adf-ref-header-icon-color,
--adf-danger-button-background: $adf-danger-button-background,
--adf-error-color: $adf-error-color,
--adf-secondary-button-background: $adf-secondary-button-background,
--adf-display-external-property-widget-preview-selection-color: mat.get-color-from-palette($foreground, secondary-text)

View File

@@ -25,5 +25,5 @@ $adf-ref-metadata-property-panel-label-color: rgba(33, 33, 33, 0.24);
$adf-ref-metadata-property-panel-title-color: rgb(33, 33, 33);
$adf-ref-header-icon-color: inherit;
$adf-ref-header-icon-border-radius: 50%;
$adf-danger-button-background: #ba1b1b;
$adf-error-color: #ba1b1b;
$adf-secondary-button-background: #2121210d;

View File

@@ -0,0 +1,35 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AgentPaging } from '../model/agentPaging';
import { BaseApi } from '../../hxi-connector-api/api/base.api';
/**
* Agents Api.
*/
export class AgentsApi extends BaseApi {
/**
* Gets all agents.
*
* @returns AgentPaging object containing the agents.
*/
getAgents(): Promise<AgentPaging> {
return this.get({
path: '/agents'
});
}
}

View File

@@ -18,6 +18,7 @@
export * from './types';
export * from './actions.api';
export * from './activities.api';
export * from './agents.api';
export * from './audit.api';
export * from './categories.api';
export * from './comments.api';
@@ -32,6 +33,7 @@ export * from './probes.api';
export * from './queries.api';
export * from './ratings.api';
export * from './renditions.api';
export * from './search-ai.api';
export * from './sharedlinks.api';
export * from './sites.api';
export * from './tags.api';

View File

@@ -0,0 +1,57 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { QuestionModel } from '../model/questionModel';
import { BaseApi } from '../../hxi-connector-api/api/base.api';
import { QuestionRequest } from '../model/questionRequest';
import { AiAnswerPaging } from '../model/aiAnswerPaging';
/**
* Search AI API.
*/
export class SearchAiApi extends BaseApi {
/**
* Ask a question to the AI.
*
* @param questions The questions to ask.
* @returns QuestionModel object containing information about questions.
*/
ask(questions: QuestionRequest[]): Promise<QuestionModel[]> {
return this.get({
path: 'questions',
bodyParam: questions.map((question) => ({
...question,
restrictionQuery: question.nodeIds.join(',')
}))
});
}
/**
* Get an answer to specific question.
*
* @param questionId The ID of the question to get an answer for.
* @returns AiAnswerPaging object containing the answer.
*/
getAnswer(questionId: string): Promise<AiAnswerPaging> {
return this.get({
path: 'answers',
queryParams: {
questionId
}
});
}
}

View File

@@ -0,0 +1,83 @@
# AgentsApi
| Method | HTTP request | Description |
|-------------------------|-----------------|------------------|
| [getAgents](#getAgents) | **GET** /agents | Gets all agents. |
## getAgents
Gets all agents.
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": {
"id": "Some id",
"name": "Some name"
}
}
]
}
}
```
**Example**
```javascript
import { AlfrescoApi, AgentsApi } from '@alfresco/js-api';
const alfrescoApi = new AlfrescoApi(/*..*/);
const agentsApi = new AgentsApi(alfrescoApi);
agentsApi.getAgents().then((agents) => {
console.log('API called successfully. Returned data: ' + agents);
});
```
**Return type**: [AgentPaging](#AgentPaging)
# Models
## AgentPaging
**Properties**
| Name | Type |
|------|-------------------------------------|
| list | [AgentPagingList](#AgentPagingList) |
## AgentPagingList
**Properties**
| Name | Type |
|----------------|-----------------------------|
| **pagination** | [Pagination](Pagination.md) |
| **entries** | [AgentEntry[]](#AgentEntry) |
## AgentEntry
**Properties**
| Name | Type |
|-----------|-----------------|
| **entry** | [Agent](#Agent) |
## Agent
**Properties**
| Name | Type |
|----------|--------|
| **id** | string |
| **name** | string |

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[] |

View File

@@ -0,0 +1,21 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface Agent {
id: string;
name: string;
}

View File

@@ -0,0 +1,22 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Agent } from './agent';
export interface AgentEntry {
entry: Agent;
}

View File

@@ -0,0 +1,22 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AgentPagingList } from './agentPagingList';
export interface AgentPaging {
list?: AgentPagingList;
}

View File

@@ -0,0 +1,24 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Pagination } from './pagination';
import { AgentEntry } from './agentEntry';
export interface AgentPagingList {
entries?: AgentEntry[];
pagination?: Pagination;
}

View File

@@ -0,0 +1,24 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AiAnswerReference } from './aiAnswerReference';
export interface AiAnswer {
answer: string;
questionId: string;
references: AiAnswerReference[];
}

View File

@@ -0,0 +1,22 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AiAnswer } from './aiAnswer';
export interface AiAnswerEntry {
entry: AiAnswer;
}

View File

@@ -0,0 +1,22 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AiAnswerPagingList } from './aiAnswerPagingList';
export interface AiAnswerPaging {
list?: AiAnswerPagingList;
}

View File

@@ -0,0 +1,24 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Pagination } from './pagination';
import { AiAnswerEntry } from './aiAnswerEntry';
export interface AiAnswerPagingList {
entries?: AiAnswerEntry[];
pagination?: Pagination;
}

View File

@@ -0,0 +1,21 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface AiAnswerReference {
referenceId: string;
referenceText: string;
}

View File

@@ -27,6 +27,15 @@ export * from './activity';
export * from './activityEntry';
export * from './activityPaging';
export * from './activityPagingList';
export * from './agent';
export * from './agentEntry';
export * from './agentPaging';
export * from './agentPagingList';
export * from './aiAnswer';
export * from './aiAnswerEntry';
export * from './aiAnswerPaging';
export * from './aiAnswerPagingList';
export * from './aiAnswerReference';
export * from './association';
export * from './associationBody';
export * from './associationEntry';
@@ -133,6 +142,8 @@ export * from './preferencePagingList';
export * from './probeEntry';
export * from './probeEntryEntry';
export * from './property';
export * from './questionModel';
export * from './questionRequest';
export * from './rating';
export * from './ratingAggregate';
export * from './ratingBody';

View File

@@ -0,0 +1,22 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface QuestionModel {
question: string;
questionId: string;
restrictionQuery: string;
}

View File

@@ -0,0 +1,21 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface QuestionRequest {
question: string;
nodeIds: string[];
}