Skip to content
Merged
Show file tree
Hide file tree
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
Fail availability check if request contains non-user roles
  • Loading branch information
erikeldridge committed Apr 24, 2025
commit 5c0e70f66627b249852a0165664ec43b3fb8c35a
4 changes: 2 additions & 2 deletions packages/vertexai/src/methods/chrome-adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('ChromeAdapter', () => {
})
).to.be.false;
});
it('returns false if request content has function role', async () => {
it('returns false if request content has non-user role', async () => {
const adapter = new ChromeAdapter(
{
availability: async () => Availability.available
Expand All @@ -93,7 +93,7 @@ describe('ChromeAdapter', () => {
await adapter.isAvailable({
contents: [
{
role: 'function',
role: 'model',
parts: []
}
]
Expand Down
5 changes: 3 additions & 2 deletions packages/vertexai/src/methods/chrome-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ export class ChromeAdapter {
return false;
}

// Applies the same checks as above, but for each content item.
for (const content of request.contents) {
if (content.role === 'function') {
// Returns false if the request contains multiple roles, eg a chat history.
// TODO: remove this guard once LanguageModelMessage is supported.
if (content.role !== 'user') {
return false;
}
}
Expand Down
Loading