Skip to content

Commit 72ebaca

Browse files
google-genai-botcopybara-github
authored andcommitted
ADK changes
PiperOrigin-RevId: 820601151
1 parent 6991400 commit 72ebaca

File tree

4 files changed

+124
-0
lines changed

4 files changed

+124
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import {InjectionToken} from '@angular/core';
19+
20+
export const PENDING_EVENT_SERVICE = new InjectionToken<PendingEventService>(
21+
'PendingEventService',
22+
);
23+
24+
/**
25+
* Service to provide methods to handle pending events.
26+
*/
27+
export abstract class PendingEventService {
28+
abstract createFunctionResponse(
29+
id: string,
30+
name: string,
31+
response: {[key: string]: unknown},
32+
): any;
33+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import {TestBed} from '@angular/core/testing';
2+
3+
import {PendingEventServiceImpl} from './pending-event.service';
4+
5+
describe('PendingEventService', () => {
6+
let service: PendingEventServiceImpl;
7+
8+
beforeEach(() => {
9+
TestBed.configureTestingModule({
10+
providers: [PendingEventServiceImpl],
11+
});
12+
service = TestBed.inject(PendingEventServiceImpl);
13+
});
14+
15+
describe('createFunctionResponse', () => {
16+
it('should return a correctly formatted function response object', () => {
17+
const id = 'test-id-123';
18+
const name = 'testFunction';
19+
const response = {'result': 'success', 'data': 42};
20+
21+
const expected = {
22+
'function_response': {
23+
id,
24+
name,
25+
'response': {'response': response},
26+
},
27+
};
28+
29+
const result = service.createFunctionResponse(id, name, response);
30+
expect(result).toEqual(expected);
31+
});
32+
33+
it('should handle empty response objects', () => {
34+
const id = 'empty-id';
35+
const name = 'emptyFunction';
36+
const response = {};
37+
38+
const expected = {
39+
'function_response': {
40+
id,
41+
name,
42+
'response': {'response': {}},
43+
},
44+
};
45+
46+
const result = service.createFunctionResponse(id, name, response);
47+
expect(result).toEqual(expected);
48+
});
49+
});
50+
});
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import {Injectable} from '@angular/core';
19+
20+
import {PendingEventService} from './interfaces/pendingevent';
21+
22+
/**
23+
* Service to provide methods to handle pending events.
24+
*/
25+
@Injectable({
26+
providedIn: 'root',
27+
})
28+
export class PendingEventServiceImpl extends PendingEventService {
29+
createFunctionResponse(
30+
id: string,
31+
name: string,
32+
response: {[key: string]: unknown},
33+
): any {
34+
return {
35+
'function_response': {id, name, response: {'response': response}},
36+
};
37+
}
38+
}

src/main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ import {EVENT_SERVICE, EventService} from './app/core/services/event.service';
4040
import {FEATURE_FLAG_SERVICE, FeatureFlagService} from './app/core/services/feature-flag.service';
4141
import {GRAPH_SERVICE, GraphService} from './app/core/services/graph.service';
4242
import {LOCAL_FILE_SERVICE} from './app/core/services/interfaces/localfile';
43+
import {PENDING_EVENT_SERVICE} from './app/core/services/interfaces/pendingevent';
4344
import {SAFE_VALUES_SERVICE} from './app/core/services/interfaces/safevalues';
4445
import {STRING_TO_COLOR_SERVICE} from './app/core/services/interfaces/string-to-color';
4546
import {LocalFileServiceImpl} from './app/core/services/local-file.service';
47+
import {PendingEventServiceImpl} from './app/core/services/pending-event.service';
4648
import {SafeValuesServiceImpl} from './app/core/services/safevalues.service';
4749
import {SESSION_SERVICE, SessionService} from './app/core/services/session.service';
4850
import {STREAM_CHAT_SERVICE, StreamChatService} from './app/core/services/stream-chat.service';
@@ -86,6 +88,7 @@ fetch('./assets/config/runtime-config.json')
8688
},
8789
{provide: SAFE_VALUES_SERVICE, useClass: SafeValuesServiceImpl},
8890
{provide: LOCAL_FILE_SERVICE, useClass: LocalFileServiceImpl},
91+
{provide: PENDING_EVENT_SERVICE, useClass: PendingEventServiceImpl},
8992
{provide: MARKDOWN_COMPONENT, useValue: MarkdownComponent},
9093
...(config.logo ?
9194
[{provide: LOGO_COMPONENT, useValue: CustomLogoComponent}] :

0 commit comments

Comments
 (0)