mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-17 14:21:29 +00:00
Answers endpoint fix (#10176)
This commit is contained in:
committed by
Aleksander Sklorz
parent
a21dc4d6a0
commit
13fc92e62c
@@ -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)`>`<br/>
|
||||
- **getAnswer**(questionId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`AiAnswerEntry`](../../../lib/js-api/src/api/content-rest-api/docs/SearchAiApi.md#aianswerentry)`>`<br/>
|
||||
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`<br/>
|
||||
Check if using of search is possible (if all conditions are met).
|
||||
- _selectedNodesState:_ `SelectionState` - information about selected nodes.
|
||||
|
@@ -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'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@@ -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<AiAnswerPaging> {
|
||||
getAnswer(questionId: string): Observable<AiAnswerEntry> {
|
||||
return from(this.searchAiApi.getAnswer(questionId));
|
||||
}
|
||||
|
||||
|
@@ -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<AiAnswerPaging> {
|
||||
getAnswer(questionId: string): Promise<AiAnswerEntry> {
|
||||
return this.get({
|
||||
path: `questions/${questionId}/answers`
|
||||
path: `questions/${questionId}/answers/-default-`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -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**
|
||||
|
@@ -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;
|
||||
}
|
@@ -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;
|
||||
}
|
@@ -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';
|
||||
|
@@ -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'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@@ -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: {
|
||||
|
Reference in New Issue
Block a user