Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TypeScript Compiler Errors in Vertex Tests #8562

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 44 additions & 10 deletions packages/vertexai/src/models/generative-model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,21 @@ describe('GenerativeModel', () => {
it('passes params through to generateContent', async () => {
const genModel = new GenerativeModel(fakeVertexAI, {
model: 'my-model',
tools: [{ functionDeclarations: [{ name: 'myfunc' }] }],
tools: [
{
functionDeclarations: [
{
name: 'myfunc',
description: 'mydesc'
}
]
}
],
toolConfig: { functionCallingConfig: { mode: FunctionCallingMode.NONE } },
systemInstruction: { role: 'system', parts: [{ text: 'be friendly' }] }
});
expect(genModel.tools?.length).to.equal(1);
expect(genModel.toolConfig?.functionCallingConfig.mode).to.equal(
expect(genModel.toolConfig?.functionCallingConfig?.mode).to.equal(
FunctionCallingMode.NONE
);
expect(genModel.systemInstruction?.parts[0].text).to.equal('be friendly');
Expand Down Expand Up @@ -122,12 +131,21 @@ describe('GenerativeModel', () => {
it('generateContent overrides model values', async () => {
const genModel = new GenerativeModel(fakeVertexAI, {
model: 'my-model',
tools: [{ functionDeclarations: [{ name: 'myfunc' }] }],
tools: [
{
functionDeclarations: [
{
name: 'myfunc',
description: 'mydesc'
}
]
}
],
toolConfig: { functionCallingConfig: { mode: FunctionCallingMode.NONE } },
systemInstruction: { role: 'system', parts: [{ text: 'be friendly' }] }
});
expect(genModel.tools?.length).to.equal(1);
expect(genModel.toolConfig?.functionCallingConfig.mode).to.equal(
expect(genModel.toolConfig?.functionCallingConfig?.mode).to.equal(
FunctionCallingMode.NONE
);
expect(genModel.systemInstruction?.parts[0].text).to.equal('be friendly');
Expand All @@ -139,7 +157,13 @@ describe('GenerativeModel', () => {
);
await genModel.generateContent({
contents: [{ role: 'user', parts: [{ text: 'hello' }] }],
tools: [{ functionDeclarations: [{ name: 'otherfunc' }] }],
tools: [
{
functionDeclarations: [
{ name: 'otherfunc', description: 'otherdesc' }
]
}
],
toolConfig: { functionCallingConfig: { mode: FunctionCallingMode.AUTO } },
systemInstruction: { role: 'system', parts: [{ text: 'be formal' }] }
});
Expand All @@ -162,12 +186,14 @@ describe('GenerativeModel', () => {
it('passes params through to chat.sendMessage', async () => {
const genModel = new GenerativeModel(fakeVertexAI, {
model: 'my-model',
tools: [{ functionDeclarations: [{ name: 'myfunc' }] }],
tools: [
{ functionDeclarations: [{ name: 'myfunc', description: 'mydesc' }] }
],
toolConfig: { functionCallingConfig: { mode: FunctionCallingMode.NONE } },
systemInstruction: { role: 'system', parts: [{ text: 'be friendly' }] }
});
expect(genModel.tools?.length).to.equal(1);
expect(genModel.toolConfig?.functionCallingConfig.mode).to.equal(
expect(genModel.toolConfig?.functionCallingConfig?.mode).to.equal(
FunctionCallingMode.NONE
);
expect(genModel.systemInstruction?.parts[0].text).to.equal('be friendly');
Expand Down Expand Up @@ -222,12 +248,14 @@ describe('GenerativeModel', () => {
it('startChat overrides model values', async () => {
const genModel = new GenerativeModel(fakeVertexAI, {
model: 'my-model',
tools: [{ functionDeclarations: [{ name: 'myfunc' }] }],
tools: [
{ functionDeclarations: [{ name: 'myfunc', description: 'mydesc' }] }
],
toolConfig: { functionCallingConfig: { mode: FunctionCallingMode.NONE } },
systemInstruction: { role: 'system', parts: [{ text: 'be friendly' }] }
});
expect(genModel.tools?.length).to.equal(1);
expect(genModel.toolConfig?.functionCallingConfig.mode).to.equal(
expect(genModel.toolConfig?.functionCallingConfig?.mode).to.equal(
FunctionCallingMode.NONE
);
expect(genModel.systemInstruction?.parts[0].text).to.equal('be friendly');
Expand All @@ -239,7 +267,13 @@ describe('GenerativeModel', () => {
);
await genModel
.startChat({
tools: [{ functionDeclarations: [{ name: 'otherfunc' }] }],
tools: [
{
functionDeclarations: [
{ name: 'otherfunc', description: 'otherdesc' }
]
}
],
toolConfig: {
functionCallingConfig: { mode: FunctionCallingMode.AUTO }
},
Expand Down
Loading