Skip to content

Commit 02600d0

Browse files
committed
Cleanup
1 parent 5a78b76 commit 02600d0

File tree

4 files changed

+8
-18
lines changed

4 files changed

+8
-18
lines changed

packages/vertexai/src/googleAIMappers.test.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ describe('Google AI Mappers', () => {
9292
};
9393
const mappedRequest = mapGenerateContentRequest(request);
9494
expect(loggerWarnStub).to.have.been.calledOnceWith(
95-
'topK in GenerationConfig has been rounded to the nearest integer.'
95+
'topK in GenerationConfig has been rounded to the nearest integer to match the format for Google AI requests.'
9696
);
9797
expect(mappedRequest.generationConfig?.topK).to.equal(16);
9898
});
@@ -133,12 +133,8 @@ describe('Google AI Mappers', () => {
133133
const googleAIMockResponse: GoogleAIGenerateContentResponse = await (
134134
getMockResponse('googleAI', 'unary-success-citations.txt') as Response
135135
).json();
136-
console.log(JSON.stringify(googleAIMockResponse));
137136
const mappedResponse = mapGenerateContentResponse(googleAIMockResponse);
138137

139-
console.log(JSON.stringify(googleAIMockResponse));
140-
console.log(JSON.stringify(mappedResponse));
141-
142138
expect(mappedResponse.candidates).to.exist;
143139
expect(mappedResponse.candidates?.[0].content.parts[0].text).to.contain(
144140
'quantum mechanics'
@@ -242,16 +238,17 @@ describe('Google AI Mappers', () => {
242238

243239
it('should map a minimal Vertex AI CountTokensRequest', () => {
244240
const vertexRequest: CountTokensRequest = {
245-
contents: fakeContents
241+
contents: fakeContents,
242+
systemInstruction: { role: 'system', parts: [{ text: 'Be nice' }] },
243+
generationConfig: { temperature: 0.8 }
246244
};
247245

248246
const expectedGoogleAIRequest: GoogleAICountTokensRequest = {
249247
generateContentRequest: {
250248
model: fakeModel,
251249
contents: vertexRequest.contents,
252-
systemInstruction: undefined,
253-
tools: undefined,
254-
generationConfig: undefined
250+
systemInstruction: { role: 'system', parts: [{ text: 'Be nice' }] },
251+
generationConfig: { temperature: 0.8 }
255252
}
256253
};
257254

packages/vertexai/src/googleAIMappers.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export function mapGenerateContentRequest(
7676

7777
if (roundedTopK !== generateContentRequest.generationConfig.topK) {
7878
logger.warn(
79-
'topK in GenerationConfig has been rounded to the nearest integer.'
79+
'topK in GenerationConfig has been rounded to the nearest integer to match the format for Google AI requests.'
8080
);
8181
generateContentRequest.generationConfig.topK = roundedTopK;
8282
}
@@ -126,10 +126,7 @@ export function mapCountTokensRequest(
126126
const mappedCountTokensRequest: GoogleAICountTokensRequest = {
127127
generateContentRequest: {
128128
model,
129-
contents: countTokensRequest.contents,
130-
systemInstruction: countTokensRequest.systemInstruction,
131-
tools: countTokensRequest.tools,
132-
generationConfig: countTokensRequest.generationConfig
129+
...countTokensRequest
133130
}
134131
};
135132

packages/vertexai/src/helpers.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ describe('Identifier Encoding/Decoding', () => {
2929
backendType: BackendType.VERTEX_AI,
3030
location: 'us-central1'
3131
};
32-
console.log(identifier);
3332
const expected = `${AI_TYPE}/vertexai/us-central1`;
3433
expect(encodeInstanceIdentifier(identifier)).to.equal(expected);
3534
});

packages/vertexai/test-utils/mock-response.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ export function getMockResponse(
7272
filename: string
7373
): Partial<Response> {
7474
const mocksLookup = mockSetMaps[backendName];
75-
if (backendName === 'googleAI') {
76-
console.log(Object.keys(mocksLookup));
77-
}
7875
if (!(filename in mocksLookup)) {
7976
throw Error(`${backendName} mock response file '${filename}' not found.`);
8077
}

0 commit comments

Comments
 (0)