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',
'contentImport',
'gistHandler',
'compilerloader'
'compilerloader',
'remixAI'
])
await this.appManager.activatePlugin(['settings'])

@ -10,18 +10,17 @@ const desktop_profile = {
description: 'RemixAI provides AI services to Remix IDE Desktop.',
documentation: 'https://remix-ide.readthedocs.io/en/latest/remixai.html',
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 {
constructor() {
console.log('remixAIDesktopPlugin loaded')
super(desktop_profile)
}
onActivation(): void {
this.on('remixAI', 'enabled', () => {console.log('someone enable the remixAI desktop plugin')} )
console.log('remixAIDesktopPlugin ---------------------- activated')
this.on('remixAI', 'enabled', () => {} )
console.log('remixAIDesktopPlugin activated')
}
}

@ -4,7 +4,6 @@ import { Plugin } from '@remixproject/engine';
import { RemixAITab } from '@remix-ui/remix-ai'
import React from 'react';
import { ICompletions, IModel, RemoteInferencer, IRemoteModel } from '@remix/remix-ai-core';
import { resourceUsage } from 'process';
const profile = {
name: 'remixAI',
@ -17,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 ViewPlugin {
export class RemixAIPlugin extends Plugin {
isOnDesktop:boolean = false
aiIsActivated:boolean = false
readonly remixDesktopPluginName = 'remixAID'
@ -31,7 +30,6 @@ export class RemixAIPlugin extends ViewPlugin {
isInferencing: boolean = false
constructor(inDesktop:boolean) {
console.log('remixAIPlugin loaded')
super(profile)
this.isOnDesktop = inDesktop
@ -41,16 +39,20 @@ export class RemixAIPlugin extends ViewPlugin {
onActivation(): void {
if (this.isOnDesktop) {
console.log('Activating RemixAIPlugin on desktop')
this.on(this.remixDesktopPluginName, 'activated', () => {
this.call("remixAI", 'initialize', null, null, null, false);
})
} else {
console.log('Activating RemixAIPlugin on browser')
this.initialize()
}
}
async initialize(model1?:IModel, model2?:IModel, remoteModel?:IRemoteModel){
async initialize(model1?:IModel, model2?:IModel, remoteModel?:IRemoteModel, useRemote?:boolean){
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) {
this.on(this.remixDesktopPluginName, 'onStreamResult', (value) => {
this.call('terminal', 'log', { type: 'log', value: value })
@ -67,7 +69,6 @@ export class RemixAIPlugin extends ViewPlugin {
} else {
// on browser
console.log('Initializing RemixAIPlugin on browser')
this.remoteInferencer = new RemoteInferencer(remoteModel?.apiUrl, remoteModel?.completionUrl)
this.remoteInferencer.event.on('onInference', () => {
this.isInferencing = true
@ -168,9 +169,9 @@ export class RemixAIPlugin extends ViewPlugin {
}
}
render() {
return (
<RemixAITab plugin={this}></RemixAITab>
)
}
// render() {
// return (
// <RemixAITab plugin={this}></RemixAITab>
// )
// }
}

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

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

Loading…
Cancel
Save