Skip to content

Commit b898cd0

Browse files
committed
Test request-based availability checks
1 parent d4286d6 commit b898cd0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,25 @@ export class ChromeAdapter {
141141
}
142142
}
143143

144+
if (request.systemInstruction) {
145+
const systemContent = request.systemInstruction as Content;
146+
// Returns false if the role can't be represented on-device.
147+
if (systemContent.role && systemContent.role === 'function') {
148+
return false;
149+
}
150+
151+
// Returns false if the system prompt is multi-part.
152+
if (systemContent.parts && systemContent.parts.length > 1) {
153+
return false;
154+
}
155+
156+
// Returns false if the system prompt isn't text.
157+
const systemText = request.systemInstruction as TextPart;
158+
if (!systemText.text) {
159+
return false;
160+
}
161+
}
162+
144163
return true;
145164
}
146165

0 commit comments

Comments
 (0)