-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from jeasonstudio/feat-stream-text-support-abo…
…rt-signal feat: stream text/object support abort signal
- Loading branch information
Showing
10 changed files
with
138 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"chrome-ai": patch | ||
--- | ||
|
||
feat: stream text/object support abort signal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { describe, it, expect } from 'vitest'; | ||
import { chromeai } from './chromeai'; | ||
|
||
describe('chromeai', () => { | ||
it('should correctly create instance', async () => { | ||
expect(chromeai().modelId).toBe('generic'); | ||
expect(chromeai('text').modelId).toBe('text'); | ||
expect(chromeai('embedding').modelId).toBe('embedding'); | ||
expect(chromeai.embedding().modelId).toBe('embedding'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { | ||
ChromeAIEmbeddingModel, | ||
ChromeAIEmbeddingModelSettings, | ||
} from './embedding-model'; | ||
import { | ||
ChromeAIChatLanguageModel, | ||
ChromeAIChatModelId, | ||
ChromeAIChatSettings, | ||
} from './language-model'; | ||
import createDebug from 'debug'; | ||
|
||
const debug = createDebug('chromeai'); | ||
|
||
/** | ||
* Create a new ChromeAI model/embedding instance. | ||
* @param modelId 'generic' | 'text' | 'embedding' | ||
* @param settings Options for the model | ||
*/ | ||
export function chromeai( | ||
modelId?: ChromeAIChatModelId, | ||
settings?: ChromeAIChatSettings | ||
): ChromeAIChatLanguageModel; | ||
export function chromeai( | ||
modelId?: 'embedding', | ||
settings?: ChromeAIEmbeddingModelSettings | ||
): ChromeAIEmbeddingModel; | ||
export function chromeai(modelId: string = 'generic', settings: any = {}) { | ||
debug('create instance', modelId, settings); | ||
if (modelId === 'embedding') { | ||
return new ChromeAIEmbeddingModel(settings); | ||
} | ||
return new ChromeAIChatLanguageModel( | ||
modelId as ChromeAIChatModelId, | ||
settings | ||
); | ||
} | ||
|
||
/** @deprecated use `chromeai('embedding'[, options])` */ | ||
chromeai.embedding = (settings: ChromeAIEmbeddingModelSettings = {}) => | ||
new ChromeAIEmbeddingModel(settings); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './language-model'; | ||
export * from './embedding-model'; | ||
export * from './chromeai'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters