mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-8201] Knowledge Retrieval - getting AI response for one or more selected files (#10229)
* [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 * ACS-8201 Small correction after rebasing with Angular 15 * [ACS-8398] Unit tests for agents and search ai (#9974) * ACS-8398 Unit tests for search ai api and agents api * ACS-8398 Unit tests for getAnswer function from SearchAiApi, corrections for unit tests for SearchAiApi and AgentsApi * ACS-8398 Unit tests for SearchAiService and AgentService * [ACS-8210] Agent basic details popup (#9956) * [ACS-8573] Allow user to ask question without file selection * [ACS-8312] Display warning about losing response (#10059) * [ACS-8312] Display warning about losing response * [ACS-8312] Display warning about losing response - fixes * [ACS-8432] Sending all file types to HX instead of only the text file types (#10087) * ACS-8201 Fixed issues after rebase * [ACS-8588] Navigation is triggered twice when leaving Knowledge Retrieval page (#10132) * [ACS-8588] Navigation is triggered twice when leaving Knowledge Retrieval page * [ACS-8588] Navigation is triggered twice when leaving Knowledge Retrieval page - review fixes * [ACS-8588] Navigation is triggered twice when leaving Knowledge Retrieval page - review fixes 2 * [ACS-8399] Integrate all changes with backend (#10163) * Answers endpoint fix (#10176) * [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 * ACS-8201 Fixed issues after rebase * [ACS-8695] Getting Agent avatar (#10189) * [ACS-8695] Getting Agent avatar * [ACS-8695] Getting Agent avatar - on image load error * [ACS-8695] Getting Agent avatar - removed getAgentAvatar call (#10209) * [ACS-8201] Review fixes --------- Co-authored-by: AleksanderSklorz <115619721+AleksanderSklorz@users.noreply.github.com> Co-authored-by: Aleksander Sklorz <Aleksander.Sklorz@hyland.com>
This commit is contained in:
36
lib/js-api/src/api/content-rest-api/api/agents.api.ts
Normal file
36
lib/js-api/src/api/content-rest-api/api/agents.api.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
/*!
|
||||
* @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.
|
||||
* In order to use this api, you need to have the HX Insights Connector (additional ACS module) installed.
|
||||
*/
|
||||
export class AgentsApi extends BaseApi {
|
||||
/**
|
||||
* Gets all agents.
|
||||
*
|
||||
* @returns AgentPaging object containing the agents.
|
||||
*/
|
||||
getAgents(): Promise<AgentPaging> {
|
||||
return this.get({
|
||||
path: '/agents'
|
||||
});
|
||||
}
|
||||
}
|
@@ -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';
|
||||
|
64
lib/js-api/src/api/content-rest-api/api/search-ai.api.ts
Normal file
64
lib/js-api/src/api/content-rest-api/api/search-ai.api.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
/*!
|
||||
* @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, QuestionRequest, AiAnswerEntry, KnowledgeRetrievalConfigEntry } from '../model';
|
||||
import { BaseApi } from '../../hxi-connector-api/api/base.api';
|
||||
|
||||
/**
|
||||
* Search AI API.
|
||||
*/
|
||||
export class SearchAiApi extends BaseApi {
|
||||
/**
|
||||
* Ask a question to the AI.
|
||||
*
|
||||
* @param questions QuestionRequest array containing questions to ask.
|
||||
* @returns QuestionModel object containing information about questions.
|
||||
*/
|
||||
ask(questions: QuestionRequest[]): Promise<QuestionModel> {
|
||||
const agentId = questions[0].agentId;
|
||||
return this.post({
|
||||
path: `agents/${agentId}/questions`,
|
||||
bodyParam: questions.map((questionRequest) => ({
|
||||
question: questionRequest.question,
|
||||
restrictionQuery: { nodesIds: questionRequest.nodeIds }
|
||||
}))
|
||||
}).then((response) => response.entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an answer to specific question.
|
||||
*
|
||||
* @param questionId The ID of the question to get an answer for.
|
||||
* @returns AiAnswerEntry object containing the answer.
|
||||
*/
|
||||
getAnswer(questionId: string): Promise<AiAnswerEntry> {
|
||||
return this.get({
|
||||
path: `questions/${questionId}/answers/-default-`
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the knowledge retrieval configuration.
|
||||
*
|
||||
* @returns KnowledgeRetrievalConfigEntry object containing the configuration.
|
||||
*/
|
||||
getConfig(): Promise<KnowledgeRetrievalConfigEntry> {
|
||||
return this.get({
|
||||
path: '/config/-default-'
|
||||
});
|
||||
}
|
||||
}
|
87
lib/js-api/src/api/content-rest-api/docs/AgentsApi.md
Normal file
87
lib/js-api/src/api/content-rest-api/docs/AgentsApi.md
Normal file
@@ -0,0 +1,87 @@
|
||||
# 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",
|
||||
"description": "Some description",
|
||||
"avatarUrl": "Some avatar url"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**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 | Description |
|
||||
|-----------------|-----------|-------------------------------|
|
||||
| **id** | string | Agent id |
|
||||
| **name** | string | Agent name |
|
||||
| **description** | string | Agent description |
|
||||
| **avatarUrl** | string | (optional) Agent avatar image |
|
199
lib/js-api/src/api/content-rest-api/docs/SearchAiApi.md
Normal file
199
lib/js-api/src/api/content-rest-api/docs/SearchAiApi.md
Normal file
@@ -0,0 +1,199 @@
|
||||
# SearchAiApi
|
||||
|
||||
| Method | HTTP request | Description |
|
||||
|-------------------------|----------------------------|--------------------------------------------|
|
||||
| [ask](#ask) | **GET** /questions | Ask a question to the AI. |
|
||||
| [getAnswer](#getAnswer) | **GET** /answers/-default- | Get an answer to specific question. |
|
||||
| [getConfig](#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:
|
||||
|
||||
```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',
|
||||
agentId: 'Some agent id'
|
||||
}]).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**: [AiAnswerEntry](#AiAnswerEntry)
|
||||
|
||||
## getConfig
|
||||
|
||||
Get the knowledge retrieval configuration. For example:
|
||||
|
||||
```json
|
||||
{
|
||||
"entry": {
|
||||
"knowledgeRetrievalUrl": "https://some-url"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Example**
|
||||
|
||||
```javascript
|
||||
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](#KnowledgeRetrievalConfigEntry)
|
||||
|
||||
# Models
|
||||
|
||||
## 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** | RestrictionQuery |
|
||||
|
||||
## RestrictionQuery
|
||||
|
||||
**Properties**
|
||||
|
||||
| Name | Type |
|
||||
|--------------|----------|
|
||||
| **nodesIds** | string[] |
|
||||
|
||||
## QuestionRequest
|
||||
|
||||
**Properties**
|
||||
|
||||
| Name | Type |
|
||||
|--------------|----------|
|
||||
| **question** | string |
|
||||
| **nodeIds** | string[] |
|
||||
| **agentId** | string |
|
||||
|
||||
## KnowledgeRetrievalConfigEntry
|
||||
|
||||
**Properties**
|
||||
|
||||
| Name | Type |
|
||||
|-------|-------------------------------------------------------|
|
||||
| entry | [KnowledgeRetrievalConfig](#KnowledgeRetrievalConfig) |
|
||||
|
||||
## KnowledgeRetrievalConfig
|
||||
|
||||
**Properties**
|
||||
|
||||
| Name | Type |
|
||||
|-----------------------|--------|
|
||||
| knowledgeRetrievalUrl | string |
|
23
lib/js-api/src/api/content-rest-api/model/agent.ts
Normal file
23
lib/js-api/src/api/content-rest-api/model/agent.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/*!
|
||||
* @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;
|
||||
description: string;
|
||||
avatarUrl?: string;
|
||||
}
|
22
lib/js-api/src/api/content-rest-api/model/agentEntry.ts
Normal file
22
lib/js-api/src/api/content-rest-api/model/agentEntry.ts
Normal 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;
|
||||
}
|
22
lib/js-api/src/api/content-rest-api/model/agentPaging.ts
Normal file
22
lib/js-api/src/api/content-rest-api/model/agentPaging.ts
Normal 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;
|
||||
}
|
24
lib/js-api/src/api/content-rest-api/model/agentPagingList.ts
Normal file
24
lib/js-api/src/api/content-rest-api/model/agentPagingList.ts
Normal 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;
|
||||
}
|
24
lib/js-api/src/api/content-rest-api/model/aiAnswer.ts
Normal file
24
lib/js-api/src/api/content-rest-api/model/aiAnswer.ts
Normal 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[];
|
||||
}
|
22
lib/js-api/src/api/content-rest-api/model/aiAnswerEntry.ts
Normal file
22
lib/js-api/src/api/content-rest-api/model/aiAnswerEntry.ts
Normal 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;
|
||||
}
|
@@ -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;
|
||||
}
|
@@ -27,6 +27,13 @@ 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 './aiAnswerReference';
|
||||
export * from './association';
|
||||
export * from './associationBody';
|
||||
export * from './associationEntry';
|
||||
@@ -91,6 +98,8 @@ export * from './groupMemberPagingList';
|
||||
export * from './groupMembershipBodyCreate';
|
||||
export * from './groupPaging';
|
||||
export * from './groupPagingList';
|
||||
export * from './knowledgeRetrievalConfig';
|
||||
export * from './knowledgeRetrievalConfigEntry';
|
||||
export * from './modelError';
|
||||
export * from './networkQuota';
|
||||
export * from './node';
|
||||
@@ -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';
|
||||
|
@@ -0,0 +1,20 @@
|
||||
/*!
|
||||
* @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 KnowledgeRetrievalConfig {
|
||||
knowledgeRetrievalUrl: string;
|
||||
}
|
@@ -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 { KnowledgeRetrievalConfig } from './knowledgeRetrievalConfig';
|
||||
|
||||
export interface KnowledgeRetrievalConfigEntry {
|
||||
entry: KnowledgeRetrievalConfig;
|
||||
}
|
24
lib/js-api/src/api/content-rest-api/model/questionModel.ts
Normal file
24
lib/js-api/src/api/content-rest-api/model/questionModel.ts
Normal 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 { RestrictionQuery } from './restrictionQuery';
|
||||
|
||||
export interface QuestionModel {
|
||||
questionId: string;
|
||||
question: string;
|
||||
restrictionQuery: RestrictionQuery;
|
||||
}
|
22
lib/js-api/src/api/content-rest-api/model/questionRequest.ts
Normal file
22
lib/js-api/src/api/content-rest-api/model/questionRequest.ts
Normal 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 QuestionRequest {
|
||||
question: string;
|
||||
nodeIds: string[];
|
||||
agentId: string;
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
/*!
|
||||
* @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 RestrictionQuery {
|
||||
nodesIds: string[];
|
||||
}
|
71
lib/js-api/test/content-services/agentsApi.spec.ts
Normal file
71
lib/js-api/test/content-services/agentsApi.spec.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
/*!
|
||||
* @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 { AgentMock, EcmAuthMock } from '../mockObjects';
|
||||
import { AgentsApi, AlfrescoApi } from '../../src';
|
||||
import assert from 'assert';
|
||||
|
||||
describe('AgentsApi', () => {
|
||||
let agentMock: AgentMock;
|
||||
let agentsApi: AgentsApi;
|
||||
|
||||
beforeEach((done) => {
|
||||
const hostEcm = 'https://127.0.0.1:8080';
|
||||
const authResponseMock = new EcmAuthMock(hostEcm);
|
||||
agentMock = new AgentMock(hostEcm);
|
||||
authResponseMock.get201Response();
|
||||
const alfrescoJsApi = new AlfrescoApi({
|
||||
hostEcm
|
||||
});
|
||||
alfrescoJsApi.login('admin', 'admin').then(() => done());
|
||||
agentsApi = new AgentsApi(alfrescoJsApi);
|
||||
});
|
||||
|
||||
describe('getAgents', () => {
|
||||
it('should load list of agents', (done) => {
|
||||
agentMock.mockGetAgents200Response();
|
||||
|
||||
agentsApi.getAgents().then((paging) => {
|
||||
assert.deepStrictEqual(paging, {
|
||||
list: {
|
||||
pagination: {
|
||||
count: 2,
|
||||
hasMoreItems: false,
|
||||
skipCount: 0,
|
||||
maxItems: 100
|
||||
},
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
id: 'some id 1',
|
||||
name: 'some name 1'
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
id: 'some id 2',
|
||||
name: 'some name 2'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
99
lib/js-api/test/content-services/searchAiApi.spec.ts
Normal file
99
lib/js-api/test/content-services/searchAiApi.spec.ts
Normal file
@@ -0,0 +1,99 @@
|
||||
/*!
|
||||
* @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 { AlfrescoApi, SearchAiApi } from '../../src';
|
||||
import { EcmAuthMock, SearchAiMock } from '../mockObjects';
|
||||
import assert from 'assert';
|
||||
|
||||
describe('SearchAiApi', () => {
|
||||
let searchAiApi: SearchAiApi;
|
||||
let searchAiMock: SearchAiMock;
|
||||
|
||||
beforeEach((done) => {
|
||||
const hostEcm = 'https://127.0.0.1:8080';
|
||||
const authResponseMock = new EcmAuthMock(hostEcm);
|
||||
searchAiMock = new SearchAiMock(hostEcm);
|
||||
authResponseMock.get201Response();
|
||||
const alfrescoJsApi = new AlfrescoApi({
|
||||
hostEcm
|
||||
});
|
||||
alfrescoJsApi.login('admin', 'admin').then(() => done());
|
||||
searchAiApi = new SearchAiApi(alfrescoJsApi);
|
||||
});
|
||||
|
||||
describe('ask', () => {
|
||||
it('should load question information', (done) => {
|
||||
searchAiMock.mockGetAsk200Response();
|
||||
|
||||
searchAiApi
|
||||
.ask([
|
||||
{
|
||||
question: 'some question 1',
|
||||
nodeIds: ['some node id 1'],
|
||||
agentId: 'id1'
|
||||
}
|
||||
])
|
||||
.then((questions) => {
|
||||
assert.deepStrictEqual(questions, {
|
||||
questionId: 'some id 1',
|
||||
question: 'some question 1',
|
||||
restrictionQuery: {
|
||||
nodesIds: ['some node id 1']
|
||||
}
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('getAnswer', () => {
|
||||
it('should load question answer', (done) => {
|
||||
searchAiMock.mockGetAnswer200Response();
|
||||
|
||||
searchAiApi.getAnswer('id1').then((answer) => {
|
||||
assert.deepStrictEqual(answer, {
|
||||
entry: {
|
||||
answer: 'Some answer 1',
|
||||
questionId: 'some id 1',
|
||||
references: [
|
||||
{
|
||||
referenceId: 'some reference id 1',
|
||||
referenceText: 'some reference text 1'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('getConfig', () => {
|
||||
it('should load knowledge retrieval configuration', (done) => {
|
||||
searchAiMock.mockGetConfig200Response();
|
||||
|
||||
searchAiApi.getConfig().then((config) => {
|
||||
assert.deepStrictEqual(config, {
|
||||
entry: {
|
||||
knowledgeRetrievalUrl: 'https://some-url'
|
||||
}
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
50
lib/js-api/test/mockObjects/content-services/agent.mock.ts
Normal file
50
lib/js-api/test/mockObjects/content-services/agent.mock.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
/*!
|
||||
* @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 { BaseMock } from '../base.mock';
|
||||
import nock from 'nock';
|
||||
|
||||
export class AgentMock extends BaseMock {
|
||||
mockGetAgents200Response(): void {
|
||||
nock(this.host, { encodedQueryParams: true })
|
||||
.get('/alfresco/api/-default-/private/hxi/versions/1/agents')
|
||||
.reply(200, {
|
||||
list: {
|
||||
pagination: {
|
||||
count: 2,
|
||||
hasMoreItems: false,
|
||||
skipCount: 0,
|
||||
maxItems: 100
|
||||
},
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
id: 'some id 1',
|
||||
name: 'some name 1'
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
id: 'some id 2',
|
||||
name: 'some name 2'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
/*!
|
||||
* @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 { BaseMock } from '../base.mock';
|
||||
import nock from 'nock';
|
||||
|
||||
export class SearchAiMock extends BaseMock {
|
||||
mockGetAsk200Response(): void {
|
||||
nock(this.host, { encodedQueryParams: true })
|
||||
.post('/alfresco/api/-default-/private/hxi/versions/1/agents/id1/questions', [
|
||||
{
|
||||
question: 'some question 1',
|
||||
restrictionQuery: {
|
||||
nodesIds: ['some node id 1']
|
||||
}
|
||||
}
|
||||
])
|
||||
.reply(200, {
|
||||
entry: {
|
||||
question: 'some question 1',
|
||||
questionId: 'some id 1',
|
||||
restrictionQuery: {
|
||||
nodesIds: ['some node id 1']
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mockGetAnswer200Response(): void {
|
||||
nock(this.host, { encodedQueryParams: true })
|
||||
.get('/alfresco/api/-default-/private/hxi/versions/1/questions/id1/answers/-default-')
|
||||
.reply(200, {
|
||||
entry: {
|
||||
answer: 'Some answer 1',
|
||||
questionId: 'some id 1',
|
||||
references: [
|
||||
{
|
||||
referenceId: 'some reference id 1',
|
||||
referenceText: 'some reference text 1'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mockGetConfig200Response(): void {
|
||||
nock(this.host, { encodedQueryParams: true })
|
||||
.get('/alfresco/api/-default-/private/hxi/versions/1/config/-default-')
|
||||
.reply(200, {
|
||||
entry: {
|
||||
knowledgeRetrievalUrl: 'https://some-url'
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -15,6 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export * from './content-services/agent.mock';
|
||||
export * from './content-services/categories.mock';
|
||||
export * from './content-services/comment.mock';
|
||||
export * from './content-services/ecm-auth.mock';
|
||||
@@ -26,6 +27,7 @@ export * from './content-services/groups.mock';
|
||||
export * from './content-services/find-nodes.mock';
|
||||
export * from './content-services/rendition.mock';
|
||||
export * from './content-services/search.mock';
|
||||
export * from './content-services/search-ai.mock';
|
||||
export * from './content-services/tag.mock';
|
||||
export * from './content-services/upload.mock';
|
||||
export * from './content-services/version.mock';
|
||||
|
Reference in New Issue
Block a user