ai vyper code

pull/5270/head
yann300 1 month ago committed by Aniket
parent 4d330e0975
commit 68cf65a72a
  1. 3
      apps/remix-ide/src/app/tabs/locales/en/vyper.json
  2. 1
      apps/vyper/src/app/app.tsx
  3. 5
      libs/remix-ui/renderer/src/lib/renderer.tsx
  4. 5
      libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx

@ -0,0 +1,3 @@
{
"vyper.openaigptMessage": "vyper code: {content}\n error message: {messageText}\n explain why the error occurred and how to fix it."
}

@ -184,6 +184,7 @@ const App = () => {
return <Renderer key={index}
message={extractRelativePath(error.message, contract)}
plugin={remixClient}
context='vyper'
opt={{
useSpan: false,
type: 'error',

@ -9,6 +9,7 @@ interface RendererProps {
message: any
opt?: RendererOptions
plugin: any
context?: string
}
type RendererOptions = {
@ -20,7 +21,7 @@ type RendererOptions = {
errFile?: string
}
export const Renderer = ({ message, opt, plugin }: RendererProps) => {
export const Renderer = ({ message, opt, plugin, context }: RendererProps) => {
const intl = useIntl()
const [messageText, setMessageText] = useState(null)
const [editorOptions, setEditorOptions] = useState<RendererOptions>({
@ -88,7 +89,7 @@ export const Renderer = ({ message, opt, plugin }: RendererProps) => {
const askGtp = async () => {
try {
const content = await plugin.call('fileManager', 'readFile', editorOptions.errFile)
const message = intl.formatMessage({ id: 'solidity.openaigptMessage' }, { content, messageText })
const message = intl.formatMessage({ id: `${context || 'solidity' }.openaigptMessage` }, { content, messageText })
await plugin.call('remixAI', 'error_explaining', message)
_paq.push(['trackEvent', 'ai', 'remixAI', 'error_explaining_SolidityError'])
} catch (err) {

@ -299,6 +299,7 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => {
<Renderer
message={compileErrors[currentFile].error.formattedMessage || compileErrors[currentFile].error}
plugin={api}
context='solidity'
opt={{
type: compileErrors[currentFile].error.severity || 'error',
errorType: compileErrors[currentFile].error.type
@ -313,10 +314,10 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => {
compileErrors[currentFile].errors.map((err, index) => {
if (hideWarnings) {
if (err.severity !== 'warning') {
return <Renderer key={index} message={err.formattedMessage} plugin={api} opt={{ type: err.severity, errorType: err.type }} />
return <Renderer context='solidity' key={index} message={err.formattedMessage} plugin={api} opt={{ type: err.severity, errorType: err.type }} />
}
} else {
return <Renderer key={index} message={err.formattedMessage} plugin={api} opt={{ type: err.severity, errorType: err.type }} />
return <Renderer context='solidity' key={index} message={err.formattedMessage} plugin={api} opt={{ type: err.severity, errorType: err.type }} />
}
})}
</>

Loading…
Cancel
Save