use gpt from the terminal

pull/4275/head
yann300 1 year ago
parent d79cb93400
commit b8353be687
  1. 6
      apps/remix-ide/src/app/plugins/openaigpt.tsx
  2. 1
      apps/remix-ide/src/remixEngine.js
  3. 5
      libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx
  4. 2
      libs/remix-ui/terminal/src/lib/utils/wrapScript.ts

@ -38,11 +38,11 @@ export class OpenAIGpt extends Plugin {
} }
if (result && result.choices && result.choices.length) { if (result && result.choices && result.choices.length) {
this.call('terminal', 'log', { type: 'typewritersuccess', value: result.choices[0].message.content }) this.call('terminal', 'log', { type: 'typewriterwarning', value: result.choices[0].message.content })
} else if (result.error) { } else if (result.error) {
this.call('terminal', 'log', { type: 'typewritersuccess', value: result.error }) this.call('terminal', 'log', { type: 'typewriterwarning', value: result.error })
} else { } else {
this.call('terminal', 'log', { type: 'typewritersuccess', value: 'No response...' }) this.call('terminal', 'log', { type: 'typewriterwarning', value: 'No response...' })
} }
return result.data return result.data
} }

@ -22,6 +22,7 @@ export class RemixEngine extends Engine {
if (name === 'udapp') return { queueTimeout: 60000 * 4 } if (name === 'udapp') return { queueTimeout: 60000 * 4 }
if (name === 'circuit-compiler') return { queueTimeout: 60000 * 4 } if (name === 'circuit-compiler') return { queueTimeout: 60000 * 4 }
if (name === 'filePanel') return { queueTimeout: 60000 * 20 } if (name === 'filePanel') return { queueTimeout: 60000 * 20 }
if (name === 'openaigpt') return { queueTimeout: 60000 * 2 }
return { queueTimeout: 10000 } return { queueTimeout: 10000 }
} }

@ -28,6 +28,7 @@ import RenderKnownTransactions from './components/RenderKnownTransactions' // es
import parse from 'html-react-parser' import parse from 'html-react-parser'
import { EMPTY_BLOCK, KNOWN_TRANSACTION, RemixUiTerminalProps, UNKNOWN_TRANSACTION } from './types/terminalTypes' import { EMPTY_BLOCK, KNOWN_TRANSACTION, RemixUiTerminalProps, UNKNOWN_TRANSACTION } from './types/terminalTypes'
import { wrapScript } from './utils/wrapScript' import { wrapScript } from './utils/wrapScript'
const _paq = (window._paq = window._paq || [])
/* eslint-disable-next-line */ /* eslint-disable-next-line */
export interface ClipboardEvent<T = Element> extends SyntheticEvent<T, any> { export interface ClipboardEvent<T = Element> extends SyntheticEvent<T, any> {
@ -229,6 +230,10 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
try { try {
if (script.trim().startsWith('git')) { if (script.trim().startsWith('git')) {
// await this.call('git', 'execute', script) code might be used in the future // await this.call('git', 'execute', script) code might be used in the future
} else if (script.trim().startsWith('gpt')) {
call('terminal', 'log',{ type: 'warn', value: `> ${script}` })
await call('openaigpt', 'message', script)
_paq.push(['trackEvent', 'ai', 'openai', 'askFromTerminal'])
} else { } else {
await call('scriptRunner', 'execute', script) await call('scriptRunner', 'execute', script)
} }

@ -1,5 +1,5 @@
export const wrapScript = (script) => { export const wrapScript = (script) => {
const isKnownScript = ['remix.', 'console.', 'git'].some(prefix => script.trim().startsWith(prefix)) const isKnownScript = ['remix.', 'console.', 'git', 'gpt'].some(prefix => script.trim().startsWith(prefix))
if (isKnownScript) return script if (isKnownScript) return script
return ` return `
try { try {

Loading…
Cancel
Save