From f47deea9bb3c20421147464c610c3556cc8eb9fe Mon Sep 17 00:00:00 2001 From: STetsing <41009393+STetsing@users.noreply.github.com> Date: Mon, 16 Dec 2024 12:53:41 +0100 Subject: [PATCH] new modal with remix AI --- .../src/app/plugins/remixAIPlugin.tsx | 4 +-- .../src/inferencers/remote/remoteInference.ts | 2 +- .../editor/src/lib/remix-ui-editor.tsx | 31 +++++++++---------- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx b/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx index e373c69991d..1c5618145fd 100644 --- a/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx +++ b/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx @@ -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' @@ -37,7 +37,7 @@ export class RemixAIPlugin extends ViewPlugin { isInferencing: boolean = false chatRequestBuffer: chatRequestBufferT = null codeExpAgent: CodeExplainAgent - securityAgent: SecurityAgent + securityAgent: SecurityAgent useRemoteInferencer:boolean = false dispatch: any diff --git a/libs/remix-ai-core/src/inferencers/remote/remoteInference.ts b/libs/remix-ai-core/src/inferencers/remote/remoteInference.ts index c6ad3816184..4975f985f91 100644 --- a/libs/remix-ai-core/src/inferencers/remote/remoteInference.ts +++ b/libs/remix-ai-core/src/inferencers/remote/remoteInference.ts @@ -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) { diff --git a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx index 743dfd0996b..b80eeff8d85 100644 --- a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx +++ b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx @@ -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' @@ -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: (
{' '} @@ -701,24 +710,12 @@ export const EditorUI = (props: EditorUIProps) => { }} />
-
- -
- ), + ) } - 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)