Skip to content
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

feat: update Outputs component to use languageModel capabilities and … #31

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions app/components/outputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import { cn } from '../utils';
import { Alert, AlertDescription, AlertTitle } from './ui/alert';
import { AlertCircle } from 'lucide-react';
import Link from 'next/link';
import { ChromeAIAssistantCapabilities } from '@/src/global';

export interface OutputsProps extends React.HTMLAttributes<HTMLDivElement> {}
export interface OutputsProps extends React.HTMLAttributes<HTMLDivElement> { }

export const Outputs = React.forwardRef<
HTMLDivElement,
Expand All @@ -24,9 +25,10 @@ export const Outputs = React.forwardRef<
const version = getChromeVersion();
// setIsBrowserSupport(version >= 127);

setIsEnabledFlags(!!globalThis.ai?.assistant);
setIsEnabledFlags(!!globalThis.ai?.languageModel);

globalThis.ai?.languageModel.capabilities().then((cap: ChromeAIAssistantCapabilities) => {

globalThis.ai?.assistant.capabilities().then((cap) => {
setIsEnabledFlags(cap.available === 'readily');
});
}, []);
Expand Down
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.16",
"ai": "^4.0.5",
"autoprefixer": "^10.4.20",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
Expand Down
2 changes: 2 additions & 0 deletions src/enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ export enum ChromeAICapabilityAvailability {
*/
READILY = 'readily',
}


12 changes: 12 additions & 0 deletions src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@
import { ChromeAICapabilityAvailability } from './enum';

export interface ChromeAIAssistantCapabilities {
/**
* the availability of the capability
*/
available: ChromeAICapabilityAvailability;
/**
* the default temperature for the capability
*/
defaultTemperature: number;
/**
* the default top k for the capability
*/
defaultTopK: number;
/**
* the maximum top k for the capability
*/
maxTopK: number;
}

Expand Down