Skip to content

Commit

Permalink
Merge pull request #25 from AmAzing129/main
Browse files Browse the repository at this point in the history
chore: infer the right type of chromeai() overload
  • Loading branch information
jeasonstudio authored Aug 26, 2024
2 parents 6048d84 + e0f7d4c commit d76fa72
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 59 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ import 'chrome-ai/polyfill';
require('chrome-ai/polyfill');
```

## Star History

[![Star History Chart](https://api.star-history.com/svg?repos=jeasonstudio/chrome-ai&type=Date)](https://star-history.com/#jeasonstudio/chrome-ai&Date)

## License

[MIT](LICENSE) License © 2024 [Jeason](https://github.com/jeasonstudio)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"@types/react": "^18",
"@types/react-dom": "^18",
"@vitest/coverage-v8": "^2.0.5",
"ai": "^3.3.3",
"ai": "^3.3.16",
"autoprefixer": "^10.4.20",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
Expand Down
102 changes: 48 additions & 54 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions src/chromeai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,19 @@ export function chromeai(
settings?: ChromeAIChatSettings
): ChromeAIChatLanguageModel;
export function chromeai(
modelId?: 'embedding',
modelId: 'embedding',
settings?: ChromeAIEmbeddingModelSettings
): ChromeAIEmbeddingModel;
export function chromeai(modelId: string = 'text', settings: any = {}) {
export function chromeai(modelId: unknown = 'text', settings: unknown = {}) {
debug('create instance', modelId, settings);
if (modelId === 'embedding') {
return new ChromeAIEmbeddingModel(settings);
return new ChromeAIEmbeddingModel(
settings as ChromeAIEmbeddingModelSettings
);
}
return new ChromeAIChatLanguageModel(
modelId as ChromeAIChatModelId,
settings
settings as ChromeAIChatSettings
);
}

Expand Down

0 comments on commit d76fa72

Please sign in to comment.