-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,33 +24,7 @@ export type ChromeAIChatModelId = 'text'; | |
|
||
export interface ChromeAIChatSettings extends Record<string, unknown> { | ||
temperature?: number; | ||
/** | ||
* Optional. The maximum number of tokens to consider when sampling. | ||
* | ||
* Models use nucleus sampling or combined Top-k and nucleus sampling. | ||
* Top-k sampling considers the set of topK most probable tokens. | ||
* Models running with nucleus sampling don't allow topK setting. | ||
*/ | ||
topK?: number; | ||
|
||
/** | ||
* Optional. A list of unique safety settings for blocking unsafe content. | ||
* @note this is not working yet | ||
*/ | ||
safetySettings?: Array<{ | ||
category: | ||
| 'HARM_CATEGORY_HATE_SPEECH' | ||
| 'HARM_CATEGORY_DANGEROUS_CONTENT' | ||
| 'HARM_CATEGORY_HARASSMENT' | ||
| 'HARM_CATEGORY_SEXUALLY_EXPLICIT'; | ||
|
||
threshold: | ||
| 'HARM_BLOCK_THRESHOLD_UNSPECIFIED' | ||
| 'BLOCK_LOW_AND_ABOVE' | ||
| 'BLOCK_MEDIUM_AND_ABOVE' | ||
| 'BLOCK_ONLY_HIGH' | ||
| 'BLOCK_NONE'; | ||
}>; | ||
} | ||
|
||
function getStringContent( | ||
|
@@ -105,8 +79,13 @@ export class ChromeAIChatLanguageModel implements LanguageModelV1 { | |
throw new LoadSettingError({ message: 'Built-in model not ready' }); | ||
} | ||
|
||
const defaultOptions = await ai.defaultTextSessionOptions(); | ||
this.options = { ...defaultOptions, ...this.options, ...options }; | ||
const defaultOptions = await ai.textModelInfo(); | ||
Check failure on line 82 in src/language-model.ts GitHub Actions / build-and-test-coveragesrc/language-model.test.ts > language-model > should do generate text
Check failure on line 82 in src/language-model.ts GitHub Actions / build-and-test-coveragesrc/language-model.test.ts > language-model > should do stream text
Check failure on line 82 in src/language-model.ts GitHub Actions / build-and-test-coveragesrc/language-model.test.ts > language-model > should do generate object
Check failure on line 82 in src/language-model.ts GitHub Actions / build-and-test-coveragesrc/language-model.test.ts > language-model > should do generate text
Check failure on line 82 in src/language-model.ts GitHub Actions / build-and-test-coveragesrc/language-model.test.ts > language-model > should do stream text
Check failure on line 82 in src/language-model.ts GitHub Actions / build-and-test-coveragesrc/language-model.test.ts > language-model > should do generate object
|
||
this.options = { | ||
temperature: defaultOptions.defaultTemperature, | ||
topK: defaultOptions.defaultTopK, | ||
...this.options, | ||
...options, | ||
}; | ||
|
||
this.session = await ai.createTextSession(this.options); | ||
|
||
|