|
|
@ -1,6 +1,7 @@ |
|
|
|
import {ViewPlugin} from '@remixproject/engine-web' |
|
|
|
import {ViewPlugin} from '@remixproject/engine-web' |
|
|
|
import React, {useState, useReducer, useEffect, useCallback} from 'react' // eslint-disable-line
|
|
|
|
import React, {useState, useRef, useReducer, useEffect, useCallback} from 'react' // eslint-disable-line
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import {AppModal, AlertModal, ModalTypes} from '@remix-ui/app' |
|
|
|
import {labels, textDark, textSecondary} from './constants' |
|
|
|
import {labels, textDark, textSecondary} from './constants' |
|
|
|
|
|
|
|
|
|
|
|
import './remix-ui-settings.css' |
|
|
|
import './remix-ui-settings.css' |
|
|
@ -52,6 +53,8 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => { |
|
|
|
const [ipfsProtocol, setipfsProtocol] = useState('') |
|
|
|
const [ipfsProtocol, setipfsProtocol] = useState('') |
|
|
|
const [ipfsProjectId, setipfsProjectId] = useState('') |
|
|
|
const [ipfsProjectId, setipfsProjectId] = useState('') |
|
|
|
const [ipfsProjectSecret, setipfsProjectSecret] = useState('') |
|
|
|
const [ipfsProjectSecret, setipfsProjectSecret] = useState('') |
|
|
|
|
|
|
|
const copilotDownload = useRef(null) |
|
|
|
|
|
|
|
|
|
|
|
const intl = useIntl() |
|
|
|
const intl = useIntl() |
|
|
|
const initValue = () => { |
|
|
|
const initValue = () => { |
|
|
|
const metadataConfig = props.config.get('settings/generate-contract-metadata') |
|
|
|
const metadataConfig = props.config.get('settings/generate-contract-metadata') |
|
|
@ -128,10 +131,43 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => { |
|
|
|
|
|
|
|
|
|
|
|
const onchangeCopilotActivate = (event) => { |
|
|
|
const onchangeCopilotActivate = (event) => { |
|
|
|
copilotActivate(props.config, event.target.checked, dispatch) |
|
|
|
copilotActivate(props.config, event.target.checked, dispatch) |
|
|
|
if (event.target.checked) props.plugin.call('copilot-suggestion', 'init') |
|
|
|
if (!event.target.checked) { |
|
|
|
else { |
|
|
|
copilotActivate(props.config, event.target.checked, dispatch) |
|
|
|
props.plugin.call('copilot-suggestion', 'uninstall') |
|
|
|
props.plugin.call('copilot-suggestion', 'uninstall') |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const message = <div>Please wait while the copilot is downloaded. <span ref={copilotDownload}>0</span>/100 .</div> |
|
|
|
|
|
|
|
copilotActivate(props.config, event.target.checked, dispatch) |
|
|
|
|
|
|
|
const modalActivate: AppModal = { |
|
|
|
|
|
|
|
id: 'loadcopilotActivate', |
|
|
|
|
|
|
|
title: 'Downloading Solidity copilot', |
|
|
|
|
|
|
|
modalType: ModalTypes.default, |
|
|
|
|
|
|
|
okLabel: 'Close', |
|
|
|
|
|
|
|
message, |
|
|
|
|
|
|
|
okFn: async() => { |
|
|
|
|
|
|
|
props.plugin.off('copilot-suggestion', 'loading') |
|
|
|
|
|
|
|
if (await props.plugin.call('copilot-suggestion', 'status')) { |
|
|
|
|
|
|
|
copilotActivate(props.config, true, dispatch)
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
props.plugin.call('copilot-suggestion', 'uninstall') |
|
|
|
|
|
|
|
copilotActivate(props.config, false, dispatch) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
hideFn: async () => { |
|
|
|
|
|
|
|
props.plugin.off('copilot-suggestion', 'loading') |
|
|
|
|
|
|
|
if (await props.plugin.call('copilot-suggestion', 'status')) { |
|
|
|
|
|
|
|
copilotActivate(props.config, true, dispatch)
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
props.plugin.call('copilot-suggestion', 'uninstall') |
|
|
|
|
|
|
|
copilotActivate(props.config, false, dispatch) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
props.plugin.call('notification', 'modal', modalActivate) |
|
|
|
|
|
|
|
props.plugin.on('copilot-suggestion', 'loading', (data) => { |
|
|
|
|
|
|
|
if (!copilotDownload.current) return |
|
|
|
|
|
|
|
copilotDownload.current.innerText = (data.loaded / data.total) * 100 |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const onchangeCopilotMaxNewToken = (event) => { |
|
|
|
const onchangeCopilotMaxNewToken = (event) => { |
|
|
@ -398,8 +434,11 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const isCopilotActivated = props.config.get('settings/copilot/suggest/activate') || false |
|
|
|
const isCopilotActivated = props.config.get('settings/copilot/suggest/activate') || false |
|
|
|
const copilotMaxnewToken = props.config.get('settings/copilot/suggest/max_new_tokens') || 5 |
|
|
|
const copilotMaxnewToken = props.config.get('settings/copilot/suggest/max_new_tokens') |
|
|
|
const copilotTemperatureValue = (props.config.get('settings/copilot/suggest/temperature') || 0.5) * 100 |
|
|
|
if (!copilotMaxnewToken) props.config.set('settings/copilot/suggest/max_new_tokens', 5) |
|
|
|
|
|
|
|
const copilotTemperatureValue = (props.config.get('settings/copilot/suggest/temperature')) * 100 |
|
|
|
|
|
|
|
if (!copilotTemperatureValue) props.config.set('settings/copilot/suggest/temperature', 0.5) |
|
|
|
|
|
|
|
|
|
|
|
if (isCopilotActivated) props.plugin.call('copilot-suggestion', 'init') |
|
|
|
if (isCopilotActivated) props.plugin.call('copilot-suggestion', 'init') |
|
|
|
const copilotSettings = () => ( |
|
|
|
const copilotSettings = () => ( |
|
|
|
<div className="border-top"> |
|
|
|
<div className="border-top"> |
|
|
|