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
@@ -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