-
Notifications
You must be signed in to change notification settings - Fork 929
VinF Hybrid Inference: throw if only_on_device and model is unavailable #8965
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,19 +61,8 @@ describe('ChromeAdapter', () => { | |
}) | ||
).to.be.false; | ||
}); | ||
it('returns false if AI API is undefined', async () => { | ||
const adapter = new ChromeAdapter(undefined, 'prefer_on_device'); | ||
expect( | ||
await adapter.isAvailable({ | ||
contents: [] | ||
}) | ||
).to.be.false; | ||
}); | ||
it('returns false if LanguageModel API is undefined', async () => { | ||
const adapter = new ChromeAdapter( | ||
{} as LanguageModel, | ||
'prefer_on_device' | ||
); | ||
const adapter = new ChromeAdapter(undefined, 'prefer_on_device'); | ||
expect( | ||
await adapter.isAvailable({ | ||
contents: [] | ||
|
@@ -82,7 +71,9 @@ describe('ChromeAdapter', () => { | |
}); | ||
it('returns false if request contents empty', async () => { | ||
const adapter = new ChromeAdapter( | ||
{} as LanguageModel, | ||
{ | ||
availability: async () => Availability.available | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We now check availability first, so this was added in a couple places |
||
} as LanguageModel, | ||
'prefer_on_device' | ||
); | ||
expect( | ||
|
@@ -93,7 +84,9 @@ describe('ChromeAdapter', () => { | |
}); | ||
it('returns false if request content has function role', async () => { | ||
const adapter = new ChromeAdapter( | ||
{} as LanguageModel, | ||
{ | ||
availability: async () => Availability.available | ||
} as LanguageModel, | ||
'prefer_on_device' | ||
); | ||
expect( | ||
|
@@ -107,51 +100,6 @@ describe('ChromeAdapter', () => { | |
}) | ||
).to.be.false; | ||
}); | ||
it('returns false if request system instruction has function role', async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We used to copy the systemInstruction out of the request, but removed that in favor of onDeviceParams.systemInstruction, which isn't currently validated. Added backlog item to revisit this. |
||
const adapter = new ChromeAdapter( | ||
{} as LanguageModel, | ||
'prefer_on_device' | ||
); | ||
expect( | ||
await adapter.isAvailable({ | ||
contents: [], | ||
systemInstruction: { | ||
role: 'function', | ||
parts: [] | ||
} | ||
}) | ||
).to.be.false; | ||
}); | ||
it('returns false if request system instruction has multiple parts', async () => { | ||
const adapter = new ChromeAdapter( | ||
{} as LanguageModel, | ||
'prefer_on_device' | ||
); | ||
expect( | ||
await adapter.isAvailable({ | ||
contents: [], | ||
systemInstruction: { | ||
role: 'function', | ||
parts: [{ text: 'a' }, { text: 'b' }] | ||
} | ||
}) | ||
).to.be.false; | ||
}); | ||
it('returns false if request system instruction has non-text part', async () => { | ||
const adapter = new ChromeAdapter( | ||
{} as LanguageModel, | ||
'prefer_on_device' | ||
); | ||
expect( | ||
await adapter.isAvailable({ | ||
contents: [], | ||
systemInstruction: { | ||
role: 'function', | ||
parts: [{ inlineData: { mimeType: 'a', data: 'b' } }] | ||
} | ||
}) | ||
).to.be.false; | ||
}); | ||
it('returns true if model is readily available', async () => { | ||
const languageModelProvider = { | ||
availability: () => Promise.resolve(Availability.available) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was stale, since we no longer have an
ai
namespace