From edfb3bda09d9006a92e3a77804d397c736281289 Mon Sep 17 00:00:00 2001 From: STetsing <41009393+STetsing@users.noreply.github.com> Date: Fri, 27 Sep 2024 15:42:52 +0200 Subject: [PATCH 01/40] initial chat --- .../src/app/plugins/remixAIPlugin.tsx | 14 +- apps/remix-ide/src/remixAppManager.js | 1 - .../src/inferencers/remote/remoteInference.ts | 2 +- .../remix-ai/src/lib/components/Default.tsx | 182 +++++++++++------- package.json | 3 + yarn.lock | 17 ++ 6 files changed, 138 insertions(+), 81 deletions(-) diff --git a/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx b/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx index 0fd0917d08..52f236f159 100644 --- a/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx +++ b/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx @@ -16,13 +16,13 @@ const profile = { icon: 'assets/img/remix-logo-blue.png', description: 'RemixAI provides AI services to Remix IDE.', kind: '', - // location: 'sidePanel', + location: 'sidePanel', documentation: 'https://remix-ide.readthedocs.io/en/latest/remixai.html', version: packageJson.version, maintainedBy: 'Remix' } -export class RemixAIPlugin extends Plugin { +export class RemixAIPlugin extends ViewPlugin { isOnDesktop:boolean = false aiIsActivated:boolean = false readonly remixDesktopPluginName = 'remixAID' @@ -169,9 +169,9 @@ export class RemixAIPlugin extends Plugin { } } - // render() { - // return ( - // - // ) - // } + render() { + return ( + + ) + } } diff --git a/apps/remix-ide/src/remixAppManager.js b/apps/remix-ide/src/remixAppManager.js index 9dab012bd5..1f080ad7ff 100644 --- a/apps/remix-ide/src/remixAppManager.js +++ b/apps/remix-ide/src/remixAppManager.js @@ -77,7 +77,6 @@ let requiredModules = [ // services + layout views + system views 'doc-gen', 'remix-templates', 'remixAID', - 'remixAI', 'solhint', 'dgit', 'pinnedPanel', diff --git a/libs/remix-ai-core/src/inferencers/remote/remoteInference.ts b/libs/remix-ai-core/src/inferencers/remote/remoteInference.ts index 638b35422b..0c37cf751a 100644 --- a/libs/remix-ai-core/src/inferencers/remote/remoteInference.ts +++ b/libs/remix-ai-core/src/inferencers/remote/remoteInference.ts @@ -10,7 +10,7 @@ export class RemoteInferencer implements ICompletions { api_url: string completion_url: string max_history = 7 - model_op = RemoteBackendOPModel.DEEPSEEK // default model operation change this to llama if necessary + model_op = RemoteBackendOPModel.CODELLAMA // default model operation change this to llama if necessary event: EventEmitter constructor(apiUrl?:string, completionUrl?:string) { diff --git a/libs/remix-ui/remix-ai/src/lib/components/Default.tsx b/libs/remix-ui/remix-ai/src/lib/components/Default.tsx index 59239309ed..b5e9291fb1 100644 --- a/libs/remix-ui/remix-ai/src/lib/components/Default.tsx +++ b/libs/remix-ui/remix-ai/src/lib/components/Default.tsx @@ -1,84 +1,122 @@ import React, { useContext, useEffect, useState } from 'react' import '../remix-ai.css' -import { DefaultModels } from '@remix/remix-ai-core'; +import { DefaultModels, GenerationParams } from '@remix/remix-ai-core'; +import { StreamSend, StreamingAdapterObserver } from '@nlux/react'; +import axios from 'axios'; +import { AiChat, useAsStreamAdapter } from '@nlux/react'; +import '@nlux/themes/nova.css'; + +import { user, assistantAvatar } from './personas'; +const demoProxyServerUrl = 'https://solcoder.remixproject.org'; export const Default = (props) => { - const [searchText, setSearchText] = useState(''); - const [resultText, setResultText] = useState(''); - const pluginName = 'remixAI' - const appendText = (newText) => { - setResultText(resultText => resultText + newText); - } - useEffect(() => { - const handleResultReady = async (e) => { - appendText(e); - }; - if (props.plugin.isOnDesktop ) { - props.plugin.on(props.plugin.remixDesktopPluginName, 'onStreamResult', (value) => { - handleResultReady(value); - }) - } - }, []) + const send: StreamSend = async ( + prompt: string, + observer: StreamingAdapterObserver, + ) => { + console.log(prompt); + const response = await props.plugin.call('remixAI', 'solidity_answer', prompt); + observer.next(response); + observer.complete(); +}; + const adapter = useAsStreamAdapter(send, []); return ( -
-
- console.log('searchText not implememted')} - > - + + ); +}; - +// useEffect(() => { +// const handleResultReady = async (e) => { +// appendText(e); +// }; +// if (props.plugin.isOnDesktop ) { +// props.plugin.on(props.plugin.remixDesktopPluginName, 'onStreamResult', (value) => { +// handleResultReady(value); +// }) +// } +// }, []) -
+// return ( +//
+//
+// console.log('searchText not implememted')} +// > +// -
-