using remote remixAI for destop

pull/5100/head
STetsing 2 months ago
parent 66513f9212
commit fad1c7acc7
  1. 3
      apps/remix-ide/src/app.js
  2. 7
      apps/remix-ide/src/app/plugins/electron/remixAIDesktopPlugin.tsx
  3. 27
      apps/remix-ide/src/app/plugins/remixAIPlugin.tsx
  4. 1
      apps/remix-ide/src/remixAppManager.js
  5. 10
      apps/remixdesktop/src/plugins/remixAIDektop.ts

@ -539,7 +539,8 @@ class AppComponent {
'fetchAndCompile', 'fetchAndCompile',
'contentImport', 'contentImport',
'gistHandler', 'gistHandler',
'compilerloader' 'compilerloader',
'remixAI'
]) ])
await this.appManager.activatePlugin(['settings']) await this.appManager.activatePlugin(['settings'])

@ -10,18 +10,17 @@ const desktop_profile = {
description: 'RemixAI provides AI services to Remix IDE Desktop.', description: 'RemixAI provides AI services to Remix IDE Desktop.',
documentation: 'https://remix-ide.readthedocs.io/en/latest/remixai.html', documentation: 'https://remix-ide.readthedocs.io/en/latest/remixai.html',
icon: 'assets/img/remix-logo-blue.png', icon: 'assets/img/remix-logo-blue.png',
methods: ['downloadModel', 'loadTransformerModel', 'code_completion'], methods: ['initializeModelBackend', 'code_completion', 'code_insertion', 'code_generation', 'code_explaining', 'error_explaining', 'solidity_answer'],
} }
export class remixAIDesktopPlugin extends ElectronPlugin { export class remixAIDesktopPlugin extends ElectronPlugin {
constructor() { constructor() {
console.log('remixAIDesktopPlugin loaded')
super(desktop_profile) super(desktop_profile)
} }
onActivation(): void { onActivation(): void {
this.on('remixAI', 'enabled', () => {console.log('someone enable the remixAI desktop plugin')} ) this.on('remixAI', 'enabled', () => {} )
console.log('remixAIDesktopPlugin ---------------------- activated') console.log('remixAIDesktopPlugin activated')
} }
} }

@ -4,7 +4,6 @@ import { Plugin } from '@remixproject/engine';
import { RemixAITab } from '@remix-ui/remix-ai' import { RemixAITab } from '@remix-ui/remix-ai'
import React from 'react'; import React from 'react';
import { ICompletions, IModel, RemoteInferencer, IRemoteModel } from '@remix/remix-ai-core'; import { ICompletions, IModel, RemoteInferencer, IRemoteModel } from '@remix/remix-ai-core';
import { resourceUsage } from 'process';
const profile = { const profile = {
name: 'remixAI', name: 'remixAI',
@ -17,13 +16,13 @@ const profile = {
icon: 'assets/img/remix-logo-blue.png', icon: 'assets/img/remix-logo-blue.png',
description: 'RemixAI provides AI services to Remix IDE.', description: 'RemixAI provides AI services to Remix IDE.',
kind: '', kind: '',
location: 'sidePanel', // location: 'sidePanel',
documentation: 'https://remix-ide.readthedocs.io/en/latest/remixai.html', documentation: 'https://remix-ide.readthedocs.io/en/latest/remixai.html',
version: packageJson.version, version: packageJson.version,
maintainedBy: 'Remix' maintainedBy: 'Remix'
} }
export class RemixAIPlugin extends ViewPlugin { export class RemixAIPlugin extends Plugin {
isOnDesktop:boolean = false isOnDesktop:boolean = false
aiIsActivated:boolean = false aiIsActivated:boolean = false
readonly remixDesktopPluginName = 'remixAID' readonly remixDesktopPluginName = 'remixAID'
@ -31,7 +30,6 @@ export class RemixAIPlugin extends ViewPlugin {
isInferencing: boolean = false isInferencing: boolean = false
constructor(inDesktop:boolean) { constructor(inDesktop:boolean) {
console.log('remixAIPlugin loaded')
super(profile) super(profile)
this.isOnDesktop = inDesktop this.isOnDesktop = inDesktop
@ -41,16 +39,20 @@ export class RemixAIPlugin extends ViewPlugin {
onActivation(): void { onActivation(): void {
if (this.isOnDesktop) { if (this.isOnDesktop) {
console.log('Activating RemixAIPlugin on desktop') console.log('Activating RemixAIPlugin on desktop')
this.on(this.remixDesktopPluginName, 'activated', () => {
this.call("remixAI", 'initialize', null, null, null, false);
})
} else { } else {
console.log('Activating RemixAIPlugin on browser') console.log('Activating RemixAIPlugin on browser')
this.initialize() this.initialize()
} }
} }
async initialize(model1?:IModel, model2?:IModel, remoteModel?:IRemoteModel){ async initialize(model1?:IModel, model2?:IModel, remoteModel?:IRemoteModel, useRemote?:boolean){
if (this.isOnDesktop) { if (this.isOnDesktop) {
const res = await this.call(this.remixDesktopPluginName, 'initializeModelBackend', false, model1, model2) // on desktop use remote inferencer -> false
console.log('initialize on desktop')
const res = await this.call(this.remixDesktopPluginName, 'initializeModelBackend', useRemote, model1, model2)
if (res) { if (res) {
this.on(this.remixDesktopPluginName, 'onStreamResult', (value) => { this.on(this.remixDesktopPluginName, 'onStreamResult', (value) => {
this.call('terminal', 'log', { type: 'log', value: value }) this.call('terminal', 'log', { type: 'log', value: value })
@ -67,7 +69,6 @@ export class RemixAIPlugin extends ViewPlugin {
} else { } else {
// on browser // on browser
console.log('Initializing RemixAIPlugin on browser')
this.remoteInferencer = new RemoteInferencer(remoteModel?.apiUrl, remoteModel?.completionUrl) this.remoteInferencer = new RemoteInferencer(remoteModel?.apiUrl, remoteModel?.completionUrl)
this.remoteInferencer.event.on('onInference', () => { this.remoteInferencer.event.on('onInference', () => {
this.isInferencing = true this.isInferencing = true
@ -168,9 +169,9 @@ export class RemixAIPlugin extends ViewPlugin {
} }
} }
render() { // render() {
return ( // return (
<RemixAITab plugin={this}></RemixAITab> // <RemixAITab plugin={this}></RemixAITab>
) // )
} // }
} }

@ -77,6 +77,7 @@ let requiredModules = [ // services + layout views + system views
'doc-gen', 'doc-gen',
'remix-templates', 'remix-templates',
'remixAID', 'remixAID',
'remixAI',
'solhint', 'solhint',
'dgit', 'dgit',
'pinnedPanel', 'pinnedPanel',

@ -21,7 +21,6 @@ const profile = {
export class RemixAIDesktopPlugin extends ElectronBasePlugin { export class RemixAIDesktopPlugin extends ElectronBasePlugin {
clients: RemixAIDesktopPluginClient[] = [] clients: RemixAIDesktopPluginClient[] = []
constructor() { constructor() {
console.log("loading the remix plugin main plugin ")
super(profile, clientProfile, RemixAIDesktopPluginClient) super(profile, clientProfile, RemixAIDesktopPluginClient)
this.methods = [...super.methods] this.methods = [...super.methods]
@ -54,8 +53,7 @@ class RemixAIDesktopPluginClient extends ElectronBasePluginClient {
async onActivation(): Promise<void> { async onActivation(): Promise<void> {
console.log("Activation", "loaded the remix plugin client application side") console.log("Activation", "loaded the remix plugin client application side")
this.onload(() => { this.onload(() => {
this.emit('loaded') this.emit('activated')
console.log("loaded the remix plugin client application side")
}) })
} }
@ -65,12 +63,12 @@ class RemixAIDesktopPluginClient extends ElectronBasePluginClient {
} }
async initializeModelBackend(local, generalModel?, completionModel?){ async initializeModelBackend(local, generalModel?, completionModel?){
if (local){ if (!local){
console.log('Initializing Inference model locally') console.log('RemixAI remote enpoints')
this.desktopInferencer = new RemoteInferencer() this.desktopInferencer = new RemoteInferencer()
} else if (generalModel || completionModel){ } else if (generalModel || completionModel){
if (!this.desktopInferencer){ if (!this.desktopInferencer){
console.log('Initializing Inference model') console.log('RemixAI local enpoints')
this.desktopInferencer = InferenceManager.getInstance(this.modelCacheDir) this.desktopInferencer = InferenceManager.getInstance(this.modelCacheDir)
if (this.desktopInferencer instanceof InferenceManager && generalModel) await this.desktopInferencer.init(generalModel) if (this.desktopInferencer instanceof InferenceManager && generalModel) await this.desktopInferencer.init(generalModel)
if (this.desktopInferencer instanceof InferenceManager && completionModel) await this.desktopInferencer.init(completionModel) if (this.desktopInferencer instanceof InferenceManager && completionModel) await this.desktopInferencer.init(completionModel)

Loading…
Cancel
Save