mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-17 14:21:29 +00:00
[ACS-8399] Integrate all changes with backend (#10163)
This commit is contained in:
committed by
Aleksander Sklorz
parent
dcaa736a0c
commit
a21dc4d6a0
@@ -27,17 +27,18 @@ export class SearchAiApi extends BaseApi {
|
||||
/**
|
||||
* Ask a question to the AI.
|
||||
*
|
||||
* @param questions The questions to ask.
|
||||
* @param questions QuestionRequest array containing questions to ask.
|
||||
* @returns QuestionModel object containing information about questions.
|
||||
*/
|
||||
ask(questions: QuestionRequest[]): Promise<QuestionModel[]> {
|
||||
return this.get({
|
||||
path: '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: questionRequest.nodeIds.join(',')
|
||||
restrictionQuery: { nodesIds: questionRequest.nodeIds }
|
||||
}))
|
||||
});
|
||||
}).then((response) => response.entry);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,10 +49,7 @@ export class SearchAiApi extends BaseApi {
|
||||
*/
|
||||
getAnswer(questionId: string): Promise<AiAnswerPaging> {
|
||||
return this.get({
|
||||
path: 'answers',
|
||||
queryParams: {
|
||||
questionId
|
||||
}
|
||||
path: `questions/${questionId}/answers`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -30,7 +30,8 @@ const searchAiApi = new SearchAiApi(alfrescoApi);
|
||||
|
||||
searchAiApi.ask([{
|
||||
question: 'Some question',
|
||||
restrictionQuery: 'Some restriction query'
|
||||
restrictionQuery: 'Some restriction query',
|
||||
agentId: 'Some agent id'
|
||||
}]).then((questionInformation) => {
|
||||
console.log('API called successfully. Returned data: ' + questionInformation);
|
||||
});
|
||||
@@ -146,11 +147,19 @@ searchAiApi.getAnswer('some question id').then((answer) => {
|
||||
|
||||
**Properties**
|
||||
|
||||
| Name | Type |
|
||||
|----------------------|--------|
|
||||
| **question** | string |
|
||||
| **questionId** | string |
|
||||
| **restrictionQuery** | string |
|
||||
| Name | Type |
|
||||
|----------------------|------------------|
|
||||
| **question** | string |
|
||||
| **questionId** | string |
|
||||
| **restrictionQuery** | RestrictionQuery |
|
||||
|
||||
## RestrictionQuery
|
||||
|
||||
**Properties**
|
||||
|
||||
| Name | Type |
|
||||
|--------------|----------|
|
||||
| **nodesIds** | string[] |
|
||||
|
||||
## QuestionRequest
|
||||
|
||||
@@ -160,3 +169,4 @@ searchAiApi.getAnswer('some question id').then((answer) => {
|
||||
|--------------|----------|
|
||||
| **question** | string |
|
||||
| **nodeIds** | string[] |
|
||||
| **agentId** | string |
|
||||
|
@@ -15,8 +15,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { RestrictionQuery } from './restrictionQuery';
|
||||
|
||||
export interface QuestionModel {
|
||||
question: string;
|
||||
questionId: string;
|
||||
restrictionQuery: string;
|
||||
question: string;
|
||||
restrictionQuery: RestrictionQuery;
|
||||
}
|
||||
|
@@ -18,4 +18,5 @@
|
||||
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[];
|
||||
}
|
Reference in New Issue
Block a user