Skip to content

Commit f03c683

Browse files
committed
Fix tsc errors in vertex tests
1 parent 98bbf53 commit f03c683

File tree

1 file changed

+44
-10
lines changed

1 file changed

+44
-10
lines changed

packages/vertexai/src/models/generative-model.test.ts

+44-10
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,21 @@ describe('GenerativeModel', () => {
6262
it('passes params through to generateContent', async () => {
6363
const genModel = new GenerativeModel(fakeVertexAI, {
6464
model: 'my-model',
65-
tools: [{ functionDeclarations: [{ name: 'myfunc' }] }],
65+
tools: [
66+
{
67+
functionDeclarations: [
68+
{
69+
name: 'myfunc',
70+
description: 'mydesc'
71+
}
72+
]
73+
}
74+
],
6675
toolConfig: { functionCallingConfig: { mode: FunctionCallingMode.NONE } },
6776
systemInstruction: { role: 'system', parts: [{ text: 'be friendly' }] }
6877
});
6978
expect(genModel.tools?.length).to.equal(1);
70-
expect(genModel.toolConfig?.functionCallingConfig.mode).to.equal(
79+
expect(genModel.toolConfig?.functionCallingConfig?.mode).to.equal(
7180
FunctionCallingMode.NONE
7281
);
7382
expect(genModel.systemInstruction?.parts[0].text).to.equal('be friendly');
@@ -122,12 +131,21 @@ describe('GenerativeModel', () => {
122131
it('generateContent overrides model values', async () => {
123132
const genModel = new GenerativeModel(fakeVertexAI, {
124133
model: 'my-model',
125-
tools: [{ functionDeclarations: [{ name: 'myfunc' }] }],
134+
tools: [
135+
{
136+
functionDeclarations: [
137+
{
138+
name: 'myfunc',
139+
description: 'mydesc'
140+
}
141+
]
142+
}
143+
],
126144
toolConfig: { functionCallingConfig: { mode: FunctionCallingMode.NONE } },
127145
systemInstruction: { role: 'system', parts: [{ text: 'be friendly' }] }
128146
});
129147
expect(genModel.tools?.length).to.equal(1);
130-
expect(genModel.toolConfig?.functionCallingConfig.mode).to.equal(
148+
expect(genModel.toolConfig?.functionCallingConfig?.mode).to.equal(
131149
FunctionCallingMode.NONE
132150
);
133151
expect(genModel.systemInstruction?.parts[0].text).to.equal('be friendly');
@@ -139,7 +157,13 @@ describe('GenerativeModel', () => {
139157
);
140158
await genModel.generateContent({
141159
contents: [{ role: 'user', parts: [{ text: 'hello' }] }],
142-
tools: [{ functionDeclarations: [{ name: 'otherfunc' }] }],
160+
tools: [
161+
{
162+
functionDeclarations: [
163+
{ name: 'otherfunc', description: 'otherdesc' }
164+
]
165+
}
166+
],
143167
toolConfig: { functionCallingConfig: { mode: FunctionCallingMode.AUTO } },
144168
systemInstruction: { role: 'system', parts: [{ text: 'be formal' }] }
145169
});
@@ -162,12 +186,14 @@ describe('GenerativeModel', () => {
162186
it('passes params through to chat.sendMessage', async () => {
163187
const genModel = new GenerativeModel(fakeVertexAI, {
164188
model: 'my-model',
165-
tools: [{ functionDeclarations: [{ name: 'myfunc' }] }],
189+
tools: [
190+
{ functionDeclarations: [{ name: 'myfunc', description: 'mydesc' }] }
191+
],
166192
toolConfig: { functionCallingConfig: { mode: FunctionCallingMode.NONE } },
167193
systemInstruction: { role: 'system', parts: [{ text: 'be friendly' }] }
168194
});
169195
expect(genModel.tools?.length).to.equal(1);
170-
expect(genModel.toolConfig?.functionCallingConfig.mode).to.equal(
196+
expect(genModel.toolConfig?.functionCallingConfig?.mode).to.equal(
171197
FunctionCallingMode.NONE
172198
);
173199
expect(genModel.systemInstruction?.parts[0].text).to.equal('be friendly');
@@ -222,12 +248,14 @@ describe('GenerativeModel', () => {
222248
it('startChat overrides model values', async () => {
223249
const genModel = new GenerativeModel(fakeVertexAI, {
224250
model: 'my-model',
225-
tools: [{ functionDeclarations: [{ name: 'myfunc' }] }],
251+
tools: [
252+
{ functionDeclarations: [{ name: 'myfunc', description: 'mydesc' }] }
253+
],
226254
toolConfig: { functionCallingConfig: { mode: FunctionCallingMode.NONE } },
227255
systemInstruction: { role: 'system', parts: [{ text: 'be friendly' }] }
228256
});
229257
expect(genModel.tools?.length).to.equal(1);
230-
expect(genModel.toolConfig?.functionCallingConfig.mode).to.equal(
258+
expect(genModel.toolConfig?.functionCallingConfig?.mode).to.equal(
231259
FunctionCallingMode.NONE
232260
);
233261
expect(genModel.systemInstruction?.parts[0].text).to.equal('be friendly');
@@ -239,7 +267,13 @@ describe('GenerativeModel', () => {
239267
);
240268
await genModel
241269
.startChat({
242-
tools: [{ functionDeclarations: [{ name: 'otherfunc' }] }],
270+
tools: [
271+
{
272+
functionDeclarations: [
273+
{ name: 'otherfunc', description: 'otherdesc' }
274+
]
275+
}
276+
],
243277
toolConfig: {
244278
functionCallingConfig: { mode: FunctionCallingMode.AUTO }
245279
},

0 commit comments

Comments
 (0)