1 import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
2 import { Util } from '../../../../shared/utils/utils';
3 import {NzMessageService} from "ng-zorro-antd";
4 import { HttpClient,HttpHeaders } from '@angular/common/http';
7 selector: 'app-input-application-management',
8 templateUrl: './input-application-management.component.html',
9 styleUrls: ['./input-application-management.component.less']
11 export class InputApplicationManagementComponent implements OnInit {
12 title = 'Add Application';
15 private message: NzMessageService,
16 private http: HttpClient
19 @Input() showModel: boolean;
20 @Output() modalOpreation = new EventEmitter();
22 maasUrl = '/api/usecaseui-llm-adaptation/v1/operator/maas/getAll';
23 knowBaseUrl = "/api/usecaseui-llm-adaptation/v1/knowledgeBase/queryByMaaSId/";
24 createApplicationUrl = "/api/usecaseui-llm-adaptation/v1/application/create";
27 applicationDescription = "";
28 applicationType = "Knowledge Assistant";
29 operators: any[] = [];
30 selectedOperator: any = null;
31 filteredPlatforms: any[] = [];
32 selectedPlatform: any = null;
33 filteredModels: any[] = [];
34 selectedModel: any = null;
35 knowledgeBases: any[] =[];
36 selectKnowledgeBase: any = null;
37 modelDefaultValue = "";
43 this.fetchOperators();
46 fetchOperators(): void {
47 this.http.get<any>(this.maasUrl).subscribe(
49 this.operators = response.result_body;
52 this.message.error('Failed to fetch operators');
57 handleOperatorChange(value: any): void {
59 this.filteredPlatforms = value.maaSPlatformList;
61 this.filteredPlatforms = [];
63 this.selectedPlatform = null;
64 this.selectedModel = null;
65 this.selectKnowledgeBase = null;
68 handleMaasChange(value: any): void {
70 this.filteredModels = value.modelList;
71 console.log(this.filteredModels);
72 this.fetchKnowledgeBase(value);
74 this.filteredModels = [];
76 this.selectedModel = null;
77 this.selectKnowledgeBase = null;
80 fetchKnowledgeBase(value): void {
81 this.http.get<any>(this.knowBaseUrl+value.maaSPlatformId).subscribe(
83 this.knowledgeBases = response.result_body;
86 this.message.error('Failed to fetch knowledge base');
91 handleCancel(): void {
92 this.showModel = false;
93 this.modalOpreation.emit({ "cancel": true });
96 this.createApplication();
100 const requestBody = {
101 applicationName: this.applicationName,
102 applicationDescription: this.applicationDescription,
103 applicationType: this.applicationType,
104 operatorName: this.selectedOperator.operatorName,
105 operatorId: this.selectedOperator.operatorId,
106 maaSPlatformId: this.selectedPlatform.maaSPlatformId,
107 maaSPlatformName: this.selectedPlatform.maaSPlatformName,
108 knowledgeBaseId: this.selectKnowledgeBase.knowledgeBaseId,
109 knowledgeBaseName: this.selectKnowledgeBase.knowledgeBaseName,
110 largeModelId: this.selectedModel.modelId,
111 largeModelName: this.selectedModel.modelName,
113 temperature: this.temperature,
115 openingRemarks: this.openingRemarks
117 console.log(requestBody);
118 this.http.post<any>(this.createApplicationUrl, requestBody).subscribe(
120 this.showModel = false;
121 this.modalOpreation.emit({ "cancel": false });
122 const resultHeader = {};
123 if(response.result_header.result_code===200){
124 this.message.success('Created successfully');
126 this.message.error(response.result_header.result_message);
130 this.showModel = false;
131 this.message.error('Created failed');