Skip to content

Commit 5c0e70f

Browse files
committed
Fail availability check if request contains non-user roles
1 parent dd0c4b1 commit 5c0e70f

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

packages/vertexai/src/methods/chrome-adapter.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe('ChromeAdapter', () => {
8282
})
8383
).to.be.false;
8484
});
85-
it('returns false if request content has function role', async () => {
85+
it('returns false if request content has non-user role', async () => {
8686
const adapter = new ChromeAdapter(
8787
{
8888
availability: async () => Availability.available
@@ -93,7 +93,7 @@ describe('ChromeAdapter', () => {
9393
await adapter.isAvailable({
9494
contents: [
9595
{
96-
role: 'function',
96+
role: 'model',
9797
parts: []
9898
}
9999
]

packages/vertexai/src/methods/chrome-adapter.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,10 @@ export class ChromeAdapter {
144144
return false;
145145
}
146146

147-
// Applies the same checks as above, but for each content item.
148147
for (const content of request.contents) {
149-
if (content.role === 'function') {
148+
// Returns false if the request contains multiple roles, eg a chat history.
149+
// TODO: remove this guard once LanguageModelMessage is supported.
150+
if (content.role !== 'user') {
150151
return false;
151152
}
152153
}

0 commit comments

Comments
 (0)