Skip to content

Commit

Permalink
new modal with remix AI
Browse files Browse the repository at this point in the history
  • Loading branch information
STetsing committed Dec 16, 2024
1 parent 7b72b7b commit f47deea
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
4 changes: 2 additions & 2 deletions apps/remix-ide/src/app/plugins/remixAIPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ViewPlugin } from '@remixproject/engine-web'
import { Plugin } from '@remixproject/engine';
import { RemixAITab, ChatApi } from '@remix-ui/remix-ai'
import React, { useCallback } from 'react';
import { ICompletions, IModel, RemoteInferencer, IRemoteModel, IParams, GenerationParams, CodeExplainAgent, SecurityAgent} from '@remix/remix-ai-core';
import { ICompletions, IModel, RemoteInferencer, IRemoteModel, IParams, GenerationParams, CodeExplainAgent, SecurityAgent } from '@remix/remix-ai-core';
import { CustomRemixApi } from '@remix-api'
import { PluginViewWrapper } from '@remix-ui/helper'

Expand Down Expand Up @@ -37,7 +37,7 @@ export class RemixAIPlugin extends ViewPlugin {
isInferencing: boolean = false
chatRequestBuffer: chatRequestBufferT<any> = null
codeExpAgent: CodeExplainAgent
securityAgent: SecurityAgent
securityAgent: SecurityAgent
useRemoteInferencer:boolean = false
dispatch: any

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class RemoteInferencer implements ICompletions {
max_history = 7
model_op = RemoteBackendOPModel.CODELLAMA // default model operation change this to llama if necessary
event: EventEmitter
test_env=false
test_env=true
test_url="http://solcodertest.org"

constructor(apiUrl?:string, completionUrl?:string) {
Expand Down
31 changes: 14 additions & 17 deletions libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState, useRef, useEffect, useReducer } from 'react' // eslint
import { FormattedMessage, useIntl } from 'react-intl'
import { isArray } from 'lodash'
import Editor, { DiffEditor, loader, Monaco } from '@monaco-editor/react'
import { AlertModal } from '@remix-ui/app'
import { AppModal } from '@remix-ui/app'
import { ConsoleLogs, QueryParams } from '@remix-project/remix-lib'
import { reducerActions, reducerListener, initialState } from './actions/editor'
import { solidityTokensProvider, solidityLanguageConfig } from './syntaxes/solidity'
Expand Down Expand Up @@ -670,9 +670,18 @@ export const EditorUI = (props: EditorUIProps) => {
const pastedCode = editor.getModel().getValueInRange(e.range)
const pastedCodePrompt = intl.formatMessage({ id: 'editor.PastedCodeSafety' }, { content:pastedCode })

const modalContent: AlertModal = {
const modalContent: AppModal = {
id: 'newCodePasted',
title: intl.formatMessage({ id: 'editor.title1' }),
title: "New code pasted",
okLabel: 'Ask RemixAI',
cancelLabel: 'Close',
cancelFn: () => {},
okFn: async () => {
await props.plugin.call('popupPanel', 'showPopupPanel', true)
setTimeout(async () => {
props.plugin.call('remixAI', 'chatPipe', 'vulnerability_check', pastedCodePrompt)
}, 500)
},
message: (
<div>
{' '}
Expand Down Expand Up @@ -701,24 +710,12 @@ export const EditorUI = (props: EditorUIProps) => {
}}
/>
</div>
<div className="mt-2">
<button className="btn btn-primary" onClick={async () => {
await props.plugin.call('popupPanel', 'showPopupPanel', true)
setTimeout(async () => {
props.plugin.call('remixAI', 'chatPipe', 'vulnerability_check', pastedCodePrompt)
}, 500)
return
}
}>
Ask RemixAI
</button>
</div>
</div>
</div>
),
)
}

props.plugin.call('notification', 'alert', modalContent)
props.plugin.call('notification', 'modal', modalContent)
// pasteCodeRef.current = true
_paq.push(['trackEvent', 'editor', 'onDidPaste', 'more_than_10_lines'])
// const result = await props.plugin.call('remixAI', 'vulnerability_check', pastedCodePrompt)
Expand Down

0 comments on commit f47deea

Please sign in to comment.