moved logs to solcoderAI.tsx

pull/4809/head
Stéphane Tetsing 6 months ago committed by Aniket
parent a0713d6d8d
commit bd67db5e1f
  1. 6
      apps/circuit-compiler/src/app/components/container.tsx
  2. 13
      apps/remix-ide/src/app/plugins/solcoderAI.tsx
  3. 3
      apps/vyper/src/app/utils/remix-client.tsx
  4. 3
      libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts

@ -11,7 +11,6 @@ import { WitnessToggler } from './witnessToggler'
import { WitnessSection } from './witness' import { WitnessSection } from './witness'
import { CompilerFeedback } from './feedback' import { CompilerFeedback } from './feedback'
import { CompilerReport, PrimeValue } from '../types' import { CompilerReport, PrimeValue } from '../types'
const _paq = (window._paq = window._paq || [])
export function Container () { export function Container () {
const circuitApp = useContext(CircuitAppContext) const circuitApp = useContext(CircuitAppContext)
@ -54,7 +53,7 @@ export function Container () {
const handleCircuitAutoCompile = (value: boolean) => { const handleCircuitAutoCompile = (value: boolean) => {
circuitApp.dispatch({ type: 'SET_AUTO_COMPILE', payload: value }) circuitApp.dispatch({ type: 'SET_AUTO_COMPILE', payload: value })
} }
const handleCircuitHideWarnings = (value: boolean) => { const handleCircuitHideWarnings = (value: boolean) => {
circuitApp.dispatch({ type: 'SET_HIDE_WARNINGS', payload: value }) circuitApp.dispatch({ type: 'SET_HIDE_WARNINGS', payload: value })
} }
@ -75,7 +74,6 @@ export function Container () {
` `
// @ts-ignore // @ts-ignore
await circuitApp.plugin.call('solcoder', 'error_explaining', message) await circuitApp.plugin.call('solcoder', 'error_explaining', message)
_paq.push(['trackEvent', 'ai', 'solcoder', 'error_explaining_circom'])
} else { } else {
const message = ` const message = `
error message: ${error} error message: ${error}
@ -84,7 +82,6 @@ export function Container () {
` `
// @ts-ignore // @ts-ignore
await circuitApp.plugin.call('solcoder', 'error_explaining', message) await circuitApp.plugin.call('solcoder', 'error_explaining', message)
_paq.push(['trackEvent', 'ai', 'solcoder', 'error_explaining_circom'])
} }
} else { } else {
const error = report.message const error = report.message
@ -95,7 +92,6 @@ export function Container () {
` `
// @ts-ignore // @ts-ignore
await circuitApp.plugin.call('solcoder', 'error_explaining', message) await circuitApp.plugin.call('solcoder', 'error_explaining', message)
_paq.push(['trackEvent', 'ai', 'solcoder', 'error_explaining_circom'])
} }
} }

@ -50,6 +50,8 @@ export class SolCoder extends Plugin {
async code_generation(prompt): Promise<any> { async code_generation(prompt): Promise<any> {
this.emit("aiInfering") this.emit("aiInfering")
this.call('layout', 'maximizeTerminal') this.call('layout', 'maximizeTerminal')
_paq.push(['trackEvent', 'ai', 'solcoder', 'code_generation'])
let result let result
try { try {
result = await( result = await(
@ -78,6 +80,9 @@ export class SolCoder extends Plugin {
async solidity_answer(prompt): Promise<any> { async solidity_answer(prompt): Promise<any> {
this.emit("aiInfering") this.emit("aiInfering")
this.call('layout', 'maximizeTerminal') this.call('layout', 'maximizeTerminal')
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: `\n\nWaiting for SOL-GPT answer...` })
_paq.push(['trackEvent', 'ai', 'solcoder', 'answering'])
let result let result
try { try {
const main_prompt = this._build_solgpt_promt(prompt) const main_prompt = this._build_solgpt_promt(prompt)
@ -112,6 +117,9 @@ export class SolCoder extends Plugin {
async code_explaining(prompt, context:string=""): Promise<any> { async code_explaining(prompt, context:string=""): Promise<any> {
this.emit("aiInfering") this.emit("aiInfering")
this.call('layout', 'maximizeTerminal') this.call('layout', 'maximizeTerminal')
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: `\n\nWaiting for SOL-GPT answer...` })
_paq.push(['trackEvent', 'ai', 'solcoder', 'explaining'])
let result let result
try { try {
result = await( result = await(
@ -138,6 +146,8 @@ export class SolCoder extends Plugin {
async code_completion(prompt, options:SuggestOptions=null): Promise<any> { async code_completion(prompt, options:SuggestOptions=null): Promise<any> {
this.emit("aiInfering") this.emit("aiInfering")
_paq.push(['trackEvent', 'ai', 'solcoder', 'code_completion'])
let result let result
try { try {
result = await( result = await(
@ -184,6 +194,8 @@ export class SolCoder extends Plugin {
async code_insertion(msg_pfx, msg_sfx): Promise<any> { async code_insertion(msg_pfx, msg_sfx): Promise<any> {
this.emit("aiInfering") this.emit("aiInfering")
_paq.push(['trackEvent', 'ai', 'solcoder', 'code_insertion'])
let result let result
try { try {
result = await( result = await(
@ -222,6 +234,7 @@ export class SolCoder extends Plugin {
this.emit("aiInfering") this.emit("aiInfering")
this.call('layout', 'maximizeTerminal') this.call('layout', 'maximizeTerminal')
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: `\n\nWaiting for SOL-GPT answer...` }) this.call('terminal', 'log', { type: 'aitypewriterwarning', value: `\n\nWaiting for SOL-GPT answer...` })
_paq.push(['trackEvent', 'ai', 'solcoder', 'explaining'])
let result let result
try { try {

@ -5,8 +5,6 @@ import {PluginClient} from '@remixproject/plugin'
import {Contract, compileContract} from './compiler' import {Contract, compileContract} from './compiler'
import {ExampleContract} from '../components/VyperResult' import {ExampleContract} from '../components/VyperResult'
import EventEmitter from 'events' import EventEmitter from 'events'
const _paq = (window._paq = window._paq || [])
export type VyperComplierAddress = 'https://vyper2.remixproject.org/' | 'http://localhost:8000/' export type VyperComplierAddress = 'https://vyper2.remixproject.org/' | 'http://localhost:8000/'
export class RemixClient extends PluginClient { export class RemixClient extends PluginClient {
@ -73,7 +71,6 @@ export class RemixClient extends PluginClient {
can you explain why this error occurred and how to fix it? can you explain why this error occurred and how to fix it?
` `
await this.client.call('solcoder' as any, 'error_explaining', message) await this.client.call('solcoder' as any, 'error_explaining', message)
_paq.push(['trackEvent', 'ai', 'solcoder', 'error_explaining'])
} catch (err) { } catch (err) {
console.error('unable to askGpt') console.error('unable to askGpt')
console.error(err) console.error(err)

@ -66,7 +66,6 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
this.props.plugin.call('terminal', 'log', { type: 'aitypewriterwarning', value: 'Solcoder - generating code for following comment: ' + ask.replace('///', '') }) this.props.plugin.call('terminal', 'log', { type: 'aitypewriterwarning', value: 'Solcoder - generating code for following comment: ' + ask.replace('///', '') })
const data = await this.props.plugin.call('solcoder', 'code_generation', word) const data = await this.props.plugin.call('solcoder', 'code_generation', word)
_paq.push(['trackEvent', 'ai', 'solcoder', 'code_generation'])
const parsedData = data[0].trimStart() //JSON.parse(data).trimStart() const parsedData = data[0].trimStart() //JSON.parse(data).trimStart()
const item: monacoTypes.languages.InlineCompletion = { const item: monacoTypes.languages.InlineCompletion = {
@ -105,7 +104,6 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
// Code insertion // Code insertion
try { try {
const output = await this.props.plugin.call('solcoder', 'code_insertion', word, word_after) const output = await this.props.plugin.call('solcoder', 'code_insertion', word, word_after)
_paq.push(['trackEvent', 'ai', 'solcoder', 'code_insertion'])
const generatedText = output[0] // no need to clean it. should already be const generatedText = output[0] // no need to clean it. should already be
const item: monacoTypes.languages.InlineCompletion = { const item: monacoTypes.languages.InlineCompletion = {
@ -130,7 +128,6 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
try { try {
// Code completion // Code completion
const output = await this.props.plugin.call('solcoder', 'code_completion', word) const output = await this.props.plugin.call('solcoder', 'code_completion', word)
_paq.push(['trackEvent', 'ai', 'solcoder', 'code_completion'])
const generatedText = output[0] const generatedText = output[0]
let clean = generatedText let clean = generatedText

Loading…
Cancel
Save