Server IP : 209.38.156.173 / Your IP : 216.73.216.122 [ Web Server : Apache/2.4.52 (Ubuntu) System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.1.2-1ubuntu2.22 Disable Function : NONE Domains : 2 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /proc/1534260/cwd/plugins/jetpack/extensions/shared/components/ai-model-selector-control/ |
Upload File : |
/* * External dependencies */ import { AI_MODEL_GPT_3_5_Turbo_16K, AI_MODEL_GPT_4 } from '@automattic/jetpack-ai-client'; import { RadioControl, __experimentalToggleGroupControl as ToggleGroupControl, // eslint-disable-line wpcalypso/no-unsafe-wp-apis __experimentalToggleGroupControlOption as ToggleGroupControlOption, // eslint-disable-line wpcalypso/no-unsafe-wp-apis } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; /** * Types and constants */ type AiExcerptControlProps = { disabled: boolean; model: AiModelTypeProp; onModelChange?: ( model: AiModelTypeProp ) => void; }; import type { AiModelTypeProp } from '@automattic/jetpack-ai-client'; import './style.scss'; export default function AiModelSelectorControl( { model, onModelChange, disabled, }: AiExcerptControlProps ) { const help = model === AI_MODEL_GPT_4 ? __( 'The most capable model, great for tasks that require creativity and advanced reasoning', 'jetpack' ) : __( 'The fastest model, great for most everyday tasks.', 'jetpack' ); /* * Add a fallback for the ToggleGroupControlOption component, * since it is experimental and might not be available in all versions of Gutenberg. */ if ( ! ToggleGroupControlOption || ! ToggleGroupControl ) { return ( <RadioControl label={ __( 'Model', 'jetpack' ) } className="ai-model-selector-control__radio-control" selected={ model } options={ [ { label: __( 'GPT-3.5 Turbo', 'jetpack' ), value: AI_MODEL_GPT_3_5_Turbo_16K }, { label: __( 'GPT-4', 'jetpack' ), value: AI_MODEL_GPT_4 }, ] } onChange={ onModelChange } help={ help } disabled={ disabled } /> ); } return ( <ToggleGroupControl isBlock label={ __( 'Model', 'jetpack' ) } onChange={ onModelChange } value={ model } disabled={ disabled } help={ help } > <ToggleGroupControlOption label={ __( 'GTP-3.5 Turbo', 'jetpack' ) } value={ AI_MODEL_GPT_3_5_Turbo_16K } disabled={ disabled } /> <ToggleGroupControlOption label={ __( 'GPT-4', 'jetpack' ) } value={ AI_MODEL_GPT_4 } /> </ToggleGroupControl> ); }