blob: 5304e876f0ac7016843ca909da75a2a91e71d44d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
import { Component, OnInit } from '@angular/core';
import { NzMessageService } from 'ng-zorro-antd';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-robot',
templateUrl: './robot.component.html',
styleUrls: ['./robot.component.less']
})
export class RobotComponent implements OnInit {
question: string;
communicationMessage: string;
chatHistory: { question: string, answer: string }[] = [];
apiUrl = '/api/usecaseui-llm-adaptation/v1/getHelper';
constructor(
private http: HttpClient,
private message: NzMessageService
) { }
ngOnInit() {}
submitQuestion() {
this.http.post<any>(this.apiUrl,this.question,{ responseType: 'text' as 'json'}).subscribe((data) => {
if(data==''){
this.chatHistory.push({ question: this.question, answer: 'network error' });
}else{
this.chatHistory.push({ question: this.question, answer: data });
}
this.question = '';
}, error => {
this.message.error('error');
});
}
}
|