diff --git a/apps/remix-ide/src/app/plugins/copilot/suggestion-service/copilot-suggestion.ts b/apps/remix-ide/src/app/plugins/copilot/suggestion-service/copilot-suggestion.ts index 1d1c3caa49..2c326e7115 100644 --- a/apps/remix-ide/src/app/plugins/copilot/suggestion-service/copilot-suggestion.ts +++ b/apps/remix-ide/src/app/plugins/copilot/suggestion-service/copilot-suggestion.ts @@ -6,7 +6,7 @@ const profile = { name: 'copilot-suggestion', displayName: 'copilot-suggestion', description: 'copilot-suggestion', - methods: ['suggest'] + methods: ['suggest', 'init', 'uninstall'] } export class CopilotSuggestion extends Plugin { @@ -26,11 +26,16 @@ export class CopilotSuggestion extends Plugin { } async suggest(content: string) { + if (!await this.call('settings', 'get', 'settings/copilot/suggest/activate')) return { output: [{ generated_text: ''}]} + + const max_new_tokens = await this.call('settings', 'get', 'settings/copilot/suggest/max_new_tokens') + const temperature = await this.call('settings', 'get', 'settings/copilot/suggest/temperature') + console.log('suggest', max_new_tokens, temperature) const options: SuggestOptions = { do_sample: false, top_k: 0, - temperature: await this.call('settings', 'get', 'settings/copilot/suggest/temperature'), - max_new_tokens: await this.call('settings', 'get', 'settings/copilot/suggest/max_new_tokens') + temperature, + max_new_tokens } return this.service.suggest(content, options) } @@ -40,5 +45,5 @@ export class CopilotSuggestion extends Plugin { } async uninstall() { - } + } } \ No newline at end of file diff --git a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx index 844cc2643f..83c6feacdb 100644 --- a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx +++ b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx @@ -135,11 +135,11 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => { } const onchangeCopilotMaxNewToken = (event) => { - copilotMaxNewToken(props.config, event.target.value, dispatch) + copilotMaxNewToken(props.config, parseInt(event.target.value), dispatch) } const onchangeCopilotTemperature = (event) => { - copilotTemperature(props.config, event.target.value, dispatch) + copilotTemperature(props.config, parseInt(event.target.value) / 100, dispatch) } const onchangePersonal = (event) => { @@ -399,12 +399,13 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => { const isCopilotActivated = props.config.get('settings/copilot/suggest/activate') || false const copilotMaxnewToken = props.config.get('settings/copilot/suggest/max_new_tokens') || 5 - const copilotTemperatureValue = props.config.get('settings/copilot/suggest/temperature') || 0.5 + const copilotTemperatureValue = (props.config.get('settings/copilot/suggest/temperature') || 0.5) * 100 + if (isCopilotActivated) props.plugin.call('copilot-suggestion', 'init') const copilotSettings = () => (