diff --git a/docs/content-services/services/search-ai.service.md b/docs/content-services/services/search-ai.service.md index 524d6235e0..c3ee98037e 100644 --- a/docs/content-services/services/search-ai.service.md +++ b/docs/content-services/services/search-ai.service.md @@ -20,10 +20,10 @@ Manages search AI in Content Services. Ask a question to the AI. - _question:_ [`QuestionRequest`](../../../lib/js-api/src/api/content-rest-api/docs/SearchAiApi.md#questionrequest) - The question to ask. - **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`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`AiAnswerPaging`](../../../lib/js-api/src/api/content-rest-api/docs/SearchAiApi.md#aianswerpaging)`>`
+- **getAnswer**(questionId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`AiAnswerEntry`](../../../lib/js-api/src/api/content-rest-api/docs/SearchAiApi.md#aianswerentry)`>`
Get an answer to specific question. - _questionId:_ `string` - The ID of the question to get an answer for. - - **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. + - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`AiAnswerEntry`](../../../lib/js-api/src/api/content-rest-api/docs/SearchAiApi.md#aianswerentry)`>` - AiAnswerEntry object containing the answer. - **checkSearchAvailability**(selectedNodesState: `SelectionState`, maxSelectedNodes: `number`): `string`
Check if using of search is possible (if all conditions are met). - _selectedNodesState:_ `SelectionState` - information about selected nodes. diff --git a/lib/content-services/src/lib/search-ai/services/search-ai.service.spec.ts b/lib/content-services/src/lib/search-ai/services/search-ai.service.spec.ts index a45dddab53..cbbc92ecd0 100644 --- a/lib/content-services/src/lib/search-ai/services/search-ai.service.spec.ts +++ b/lib/content-services/src/lib/search-ai/services/search-ai.service.spec.ts @@ -16,7 +16,7 @@ */ import { TestBed } from '@angular/core/testing'; -import { AiAnswerPaging, Node, QuestionModel, QuestionRequest } from '@alfresco/js-api'; +import { AiAnswerEntry, Node, QuestionModel, QuestionRequest } from '@alfresco/js-api'; import { ContentTestingModule } from '../../testing/content.testing.module'; import { SearchAiService } from './search-ai.service'; import { SearchAiInputState } from '../models/search-ai-input-state'; @@ -57,38 +57,14 @@ describe('SearchAiService', () => { describe('getAnswer', () => { it('should load information about question', (done) => { const questionId = 'some id'; - const answer: AiAnswerPaging = { - list: { - pagination: { - count: 2, - hasMoreItems: false, - skipCount: 0, - maxItems: 100 - }, - entries: [ + const answer: AiAnswerEntry = { + entry: { + answer: 'Some answer 1', + questionId, + references: [ { - entry: { - answer: 'Some answer 1', - questionId, - references: [ - { - referenceId: 'some reference id 1', - referenceText: 'some reference text 1' - } - ] - } - }, - { - entry: { - answer: 'Some answer 2', - questionId, - references: [ - { - referenceId: 'some reference id 2', - referenceText: 'some reference text 2' - } - ] - } + referenceId: 'some reference id 1', + referenceText: 'some reference text 1' } ] } diff --git a/lib/content-services/src/lib/search-ai/services/search-ai.service.ts b/lib/content-services/src/lib/search-ai/services/search-ai.service.ts index e98878c1f0..2336d6d6d0 100644 --- a/lib/content-services/src/lib/search-ai/services/search-ai.service.ts +++ b/lib/content-services/src/lib/search-ai/services/search-ai.service.ts @@ -16,7 +16,7 @@ */ import { Injectable } from '@angular/core'; -import { AiAnswerPaging, QuestionModel, QuestionRequest, SearchAiApi } from '@alfresco/js-api'; +import { AiAnswerEntry, QuestionModel, QuestionRequest, SearchAiApi } from '@alfresco/js-api'; import { AlfrescoApiService } from '@alfresco/adf-core'; import { BehaviorSubject, from, Observable } from 'rxjs'; import { SelectionState } from '@alfresco/adf-extensions'; @@ -64,9 +64,9 @@ export class SearchAiService { * Get an answer to specific question. * * @param questionId The ID of the question to get an answer for. - * @returns AiAnswerPaging object containing the answer. + * @returns AiAnswerEntry object containing the answer. */ - getAnswer(questionId: string): Observable { + getAnswer(questionId: string): Observable { return from(this.searchAiApi.getAnswer(questionId)); } diff --git a/lib/js-api/src/api/content-rest-api/api/search-ai.api.ts b/lib/js-api/src/api/content-rest-api/api/search-ai.api.ts index 3a0d2529ae..5ec2edda40 100644 --- a/lib/js-api/src/api/content-rest-api/api/search-ai.api.ts +++ b/lib/js-api/src/api/content-rest-api/api/search-ai.api.ts @@ -18,7 +18,7 @@ import { QuestionModel } from '../model/questionModel'; import { BaseApi } from '../../hxi-connector-api/api/base.api'; import { QuestionRequest } from '../model/questionRequest'; -import { AiAnswerPaging } from '../model/aiAnswerPaging'; +import { AiAnswerEntry } from '../model'; /** * Search AI API. @@ -45,11 +45,11 @@ export class SearchAiApi extends BaseApi { * Get an answer to specific question. * * @param questionId The ID of the question to get an answer for. - * @returns AiAnswerPaging object containing the answer. + * @returns AiAnswerEntry object containing the answer. */ - getAnswer(questionId: string): Promise { + getAnswer(questionId: string): Promise { return this.get({ - path: `questions/${questionId}/answers` + path: `questions/${questionId}/answers/-default-` }); } } diff --git a/lib/js-api/src/api/content-rest-api/docs/SearchAiApi.md b/lib/js-api/src/api/content-rest-api/docs/SearchAiApi.md index 96e49ef423..07175ea6c0 100644 --- a/lib/js-api/src/api/content-rest-api/docs/SearchAiApi.md +++ b/lib/js-api/src/api/content-rest-api/docs/SearchAiApi.md @@ -1,9 +1,9 @@ # 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. | +| 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. | ## ask @@ -95,27 +95,10 @@ searchAiApi.getAnswer('some question id').then((answer) => { |----------------|--------|----------------------------------------------| | **questionId** | string | The ID of the question to get an answer for. | -**Return type**: [AiAnswerPaging](#AiAnswerPaging) +**Return type**: [AiAnswerEntry](#AiAnswerEntry) # Models -## AiAnswerPaging - -**Properties** - -| Name | Type | -|------|-------------------------------------------| -| list | [AiAnswerPagingList](#AiAnswerPagingList) | - -## AiAnswerPagingList - -**Properties** - -| Name | Type | -|----------------|-----------------------------------| -| **pagination** | [Pagination](Pagination.md) | -| **entries** | [AiAnswerEntry[]](#AiAnswerEntry) | - ## AiAnswerEntry **Properties** diff --git a/lib/js-api/src/api/content-rest-api/model/aiAnswerPaging.ts b/lib/js-api/src/api/content-rest-api/model/aiAnswerPaging.ts deleted file mode 100644 index 377297f0f5..0000000000 --- a/lib/js-api/src/api/content-rest-api/model/aiAnswerPaging.ts +++ /dev/null @@ -1,22 +0,0 @@ -/*! - * @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; -} diff --git a/lib/js-api/src/api/content-rest-api/model/aiAnswerPagingList.ts b/lib/js-api/src/api/content-rest-api/model/aiAnswerPagingList.ts deleted file mode 100644 index 47c74607b2..0000000000 --- a/lib/js-api/src/api/content-rest-api/model/aiAnswerPagingList.ts +++ /dev/null @@ -1,24 +0,0 @@ -/*! - * @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; -} diff --git a/lib/js-api/src/api/content-rest-api/model/index.ts b/lib/js-api/src/api/content-rest-api/model/index.ts index 756cf262bc..5ebb4ba8ee 100644 --- a/lib/js-api/src/api/content-rest-api/model/index.ts +++ b/lib/js-api/src/api/content-rest-api/model/index.ts @@ -34,8 +34,6 @@ 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'; diff --git a/lib/js-api/test/content-services/searchAiApi.spec.ts b/lib/js-api/test/content-services/searchAiApi.spec.ts index 8cc2e75978..7806662dba 100644 --- a/lib/js-api/test/content-services/searchAiApi.spec.ts +++ b/lib/js-api/test/content-services/searchAiApi.spec.ts @@ -43,11 +43,13 @@ describe('SearchAiApi', () => { .ask([ { question: 'some question 1', - nodeIds: ['some node id 1'] + nodeIds: ['some node id 1'], + agentId: 'some id 1' }, { question: 'some question 2', - nodeIds: ['some node id 2', 'some node id 3'] + nodeIds: ['some node id 2', 'some node id 3'], + agentId: 'some id 2' } ]) .then((questions) => { @@ -74,37 +76,13 @@ describe('SearchAiApi', () => { searchAiApi.getAnswer('id1').then((answer) => { assert.deepStrictEqual(answer, { - list: { - pagination: { - count: 2, - hasMoreItems: false, - skipCount: 0, - maxItems: 100 - }, - entries: [ + entry: { + answer: 'Some answer 1', + questionId: 'some id 1', + references: [ { - entry: { - answer: 'Some answer 1', - questionId: 'some id 1', - references: [ - { - referenceId: 'some reference id 1', - referenceText: 'some reference text 1' - } - ] - } - }, - { - entry: { - answer: 'Some answer 2', - questionId: 'some id 2', - references: [ - { - referenceId: 'some reference id 2', - referenceText: 'some reference text 2' - } - ] - } + referenceId: 'some reference id 1', + referenceText: 'some reference text 1' } ] } diff --git a/lib/js-api/test/mockObjects/content-services/search-ai.mock.ts b/lib/js-api/test/mockObjects/content-services/search-ai.mock.ts index 876b0d6139..4462248bc2 100644 --- a/lib/js-api/test/mockObjects/content-services/search-ai.mock.ts +++ b/lib/js-api/test/mockObjects/content-services/search-ai.mock.ts @@ -47,7 +47,7 @@ export class SearchAiMock extends BaseMock { mockGetAnswer200Response(): void { nock(this.host, { encodedQueryParams: true }) - .get('/alfresco/api/-default-/private/hxi/versions/1/answers?questionId=id1') + .get('/alfresco/api/-default-/private/hxi/versions/1/answers/-default-?questionId=id1') .reply(200, { list: { pagination: {