-
Notifications
You must be signed in to change notification settings - Fork 892
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
159 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 18 additions & 33 deletions
51
apps/remix-ide/src/app/plugins/electron/remixAIDesktopPlugin.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,41 @@ | ||
import { ElectronPlugin } from '@remixproject/engine-electron' | ||
import { IModel, ModelType, DefaultModels } from '@remix/remix-ai-core'; | ||
import axios from 'axios'; | ||
import fs from 'fs'; | ||
import { Model } from '@remix/remix-ai-core'; | ||
|
||
const desktop_profile = { | ||
name: 'remixAID', | ||
displayName: 'RemixAI Desktop', | ||
maintainedBy: 'Remix', | ||
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'], | ||
} | ||
|
||
export class remixAIDesktopPlugin extends ElectronPlugin { | ||
selectedModel: IModel | null = DefaultModels()[0] | ||
constructor() { | ||
console.log('remixAIDesktopPlugin') | ||
console.log('remixAIDesktopPlugin loaded') | ||
super(desktop_profile) | ||
|
||
this | ||
|
||
} | ||
|
||
onActivation(): void { | ||
this.on('remixAI', 'enabled', () => {console.log('someone enable the remixAI desktop plugin')} ) | ||
console.log('remixAIDesktopPlugin ---------------------- activated') | ||
console.log('remixAIDesktopPlugin Model: ', this.selectedModel) | ||
} | ||
|
||
async downloadModel(model: Model, outputLocationPath: string): Promise<void> { | ||
console.log(`Downloading model ${model.name}`) | ||
|
||
// Make a HEAD request to get the file size | ||
const { headers } = await axios.head(model.download_url); | ||
const totalSize = parseInt(headers['content-length'], 10); | ||
|
||
// Create a write stream to save the file | ||
const writer = fs.createWriteStream(outputLocationPath); | ||
|
||
// Start the file download | ||
const response = await axios({ | ||
method: 'get', | ||
url: model.download_url, | ||
responseType: 'stream' | ||
}); | ||
|
||
let downloadedSize = 0; | ||
|
||
response.data.on('data', (chunk: Buffer) => { | ||
downloadedSize += chunk.length; | ||
const progress = (downloadedSize / totalSize) * 100; | ||
this.emit('download_progress', progress); | ||
}); | ||
|
||
response.data.pipe(writer); | ||
|
||
} | ||
|
||
return new Promise((resolve, reject) => { | ||
writer.on('finish', resolve); | ||
writer.on('error', reject); | ||
}); | ||
} | ||
} | ||
// class RemixAIPlugin extends ElectronPlugin { | ||
// constructor() { | ||
// super(dek) | ||
// this.methods = ['downloadModel'] | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
'use strict' | ||
|
||
import { Model, ModelResponse, ModelRequest, InferenceModel} from './types/types' | ||
import { IModel, IModelResponse, IModelRequest, InferenceModel} from './types/types' | ||
import { ModelType } from './types/constants' | ||
import { DefaultModels } from './types/models' | ||
|
||
|
||
export { Model, ModelResponse, ModelRequest, InferenceModel } | ||
export { IModel, IModelResponse, IModelRequest, InferenceModel, ModelType, DefaultModels} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,3 @@ export enum ModelType { | |
CODE_COMPLETION = 'code_completion', | ||
GENERAL = 'general', | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.