File tree Expand file tree Collapse file tree 4 files changed +92
-2
lines changed
frontend/src/angular/src/app Expand file tree Collapse file tree 4 files changed +92
-2
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import { MatToolbarModule } from '@angular/material/toolbar';
1818import { MatInputModule } from '@angular/material/input' ;
1919import { MatFormFieldModule } from '@angular/material/form-field' ;
2020import { Router } from '@angular/router' ;
21+ import { McpServiceService } from '../service/mcp-service.service' ;
2122
2223@Component ( {
2324 selector : 'app-mcp-client' ,
@@ -36,14 +37,20 @@ export class McpClientComponent {
3637 protected query = '' ;
3738 protected response = '' ;
3839
39- constructor ( private readonly router : Router ) { }
40-
40+ constructor ( private readonly router : Router , private readonly mcpService : McpServiceService ) { }
41+
4142 protected showList ( ) : void {
4243 this . router . navigate ( [ '/doclist' ] ) ;
4344 }
4445
4546 protected submitForm ( ) : void {
4647 console . log ( this . query ) ;
48+ this . mcpService . sendRequest ( { question : this . query } ) . subscribe ( {
49+ next : ( response ) => {
50+ this . query = '' ;
51+ this . response = response . answer ;
52+ }
53+ } ) ;
4754 }
4855
4956 protected logout ( ) : void {
Original file line number Diff line number Diff line change 1+ /**
2+ * Copyright 2023 Sven Loesekann
3+ Licensed under the Apache License, Version 2.0 (the "License");
4+ you may not use this file except in compliance with the License.
5+ You may obtain a copy of the License at
6+ http://www.apache.org/licenses/LICENSE-2.0
7+ Unless required by applicable law or agreed to in writing, software
8+ distributed under the License is distributed on an "AS IS" BASIS,
9+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+ See the License for the specific language governing permissions and
11+ limitations under the License.
12+ */
13+ export interface McpRequest {
14+ question : string ;
15+ }
16+
17+ export interface ToolCall {
18+ id : string ;
19+ type : string ;
20+ name : string ;
21+ arguments : string [ ] ;
22+ }
23+
24+ export interface McpResponse {
25+ answer : string ;
26+ toolCalls : ToolCall [ ] ;
27+ }
Original file line number Diff line number Diff line change 1+ /**
2+ * Copyright 2023 Sven Loesekann
3+ Licensed under the Apache License, Version 2.0 (the "License");
4+ you may not use this file except in compliance with the License.
5+ You may obtain a copy of the License at
6+ http://www.apache.org/licenses/LICENSE-2.0
7+ Unless required by applicable law or agreed to in writing, software
8+ distributed under the License is distributed on an "AS IS" BASIS,
9+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+ See the License for the specific language governing permissions and
11+ limitations under the License.
12+ */
13+ import { TestBed } from '@angular/core/testing' ;
14+
15+ import { McpServiceService } from './mcp-service.service' ;
16+ /*
17+ describe('McpServiceService', () => {
18+ let service: McpServiceService;
19+
20+ beforeEach(() => {
21+ TestBed.configureTestingModule({});
22+ service = TestBed.inject(McpServiceService);
23+ });
24+
25+ it('should be created', () => {
26+ expect(service).toBeTruthy();
27+ });
28+ });
29+ */
Original file line number Diff line number Diff line change 1+ /**
2+ * Copyright 2023 Sven Loesekann
3+ Licensed under the Apache License, Version 2.0 (the "License");
4+ you may not use this file except in compliance with the License.
5+ You may obtain a copy of the License at
6+ http://www.apache.org/licenses/LICENSE-2.0
7+ Unless required by applicable law or agreed to in writing, software
8+ distributed under the License is distributed on an "AS IS" BASIS,
9+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+ See the License for the specific language governing permissions and
11+ limitations under the License.
12+ */
13+ import { HttpClient } from '@angular/common/http' ;
14+ import { Injectable } from '@angular/core' ;
15+ import { McpRequest , McpResponse } from '../model/mcp' ;
16+
17+ @Injectable ( {
18+ providedIn : 'root'
19+ } )
20+ export class McpServiceService {
21+
22+ constructor ( private httpClient : HttpClient ) { }
23+
24+ public sendRequest ( request : McpRequest ) {
25+ return this . httpClient . post < McpResponse > ( '/rest/mcpclient/question' , request ) ;
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments