added remix lib

pull/4956/head
Stéphane Tetsing 5 months ago
parent 046aa197a5
commit 8ed1077cb2
  1. 39
      apps/remix-ide/src/app/plugins/electron/remixAIDesktopPlugin.tsx
  2. 12387
      apps/remixdesktop/package-lock.json
  3. 1
      apps/remixdesktop/package.json
  4. 3
      apps/remixdesktop/src/plugins/remixAIDektop.ts
  5. 2532
      apps/remixdesktop/yarn.lock
  6. 1
      libs/remix-ai-core/.eslintrc
  7. 7
      libs/remix-ai-core/README.md
  8. 68
      libs/remix-ai-core/package.json
  9. 31
      libs/remix-ai-core/project.json
  10. 0
      libs/remix-ai-core/src/helpers/dowload_model.ts
  11. 7
      libs/remix-ai-core/src/index.ts
  12. 7
      libs/remix-ai-core/src/types/constants.ts
  13. 20
      libs/remix-ai-core/src/types/models.ts
  14. 29
      libs/remix-ai-core/src/types/types.ts
  15. 13
      libs/remix-ai-core/tsconfig.json
  16. 13
      libs/remix-ai-core/tsconfig.lib.json
  17. 15
      libs/remix-ai-core/tsconfig.spec.json
  18. 79
      libs/remix-ui/remix-ai/src/lib/components/ModelSelection.tsx
  19. 4
      tsconfig.paths.json

@ -1,11 +1,14 @@
import { ElectronPlugin } from '@remixproject/engine-electron'
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.',
methods: [''],
methods: ['downloadModel'],
}
export class remixAIDesktopPlugin extends ElectronPlugin {
@ -17,5 +20,37 @@ export class remixAIDesktopPlugin extends ElectronPlugin {
onActivation(): void {
this.on('remixAI', 'enabled', () => {console.log('someone enable the remixAI desktop plugin')} )
}
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);
});
}
}

File diff suppressed because it is too large Load Diff

@ -65,6 +65,7 @@
"express": "^4.19.2",
"isomorphic-git": "^1.24.2",
"matomo-tracker": "^2.2.4",
"node-llama-cpp": "^2.8.11",
"node-pty": "^0.10.1",
"semver": "^7.5.4"
},

@ -28,7 +28,7 @@ export class RemixAIDesktopPlugin extends ElectronBasePlugin {
const clientProfile: Profile = {
name: 'remixAID',
displayName: 'RemixAI desktop',
methods: ['enable'],
methods: ['enable', 'downloadModel'],
description: 'RemixAI provides AI services to Remix IDE Desktop.',
maintainedBy: 'Remix',
}
@ -54,6 +54,7 @@ class RemixAIDesktopPluginClient extends ElectronBasePluginClient {
console.log('Remix AI desktop plugin enabled')
this.emit('enabled')
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1 @@
{ "extends": "../../.eslintrc", "rules": {}, "ignorePatterns": ["!**/*"] }

@ -0,0 +1,7 @@
# remix-ai-core
[![npm version](https://badge.fury.io/js/%40remix-project%2Fremixd.svg)](https://www.npmjs.com/package/@remix-project/remixd)
[![npm](https://img.shields.io/npm/dt/@remix-project/remixd.svg?label=Total%20Downloads&logo=npm)](https://www.npmjs.com/package/@remix-project/remixd)
[![npm](https://img.shields.io/npm/dw/@remix-project/remixd.svg?logo=npm)](https://www.npmjs.com/package/@remix-project/remixd)

@ -0,0 +1,68 @@
{
"name": "@remix-project/remixd",
"version": "0.6.31",
"description": "remix server: allow accessing file system from remix.ethereum.org and start a dev environment (see help section)",
"main": "index.js",
"types": "./index.d.ts",
"bin": {
"remixd": "./src/bin/remixd.js"
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ethereum/remix-project.git"
},
"keywords": [
"remix",
"ide",
"ethereum",
"solidity"
],
"author": "Remix Team",
"license": "MIT",
"bugs": {
"url": "https://github.com/ethereum/remix-project/issues"
},
"homepage": "https://github.com/ethereum/remix-project#readme",
"dependencies": {
"@remixproject/plugin": "0.3.33",
"@remixproject/plugin-api": "0.3.33",
"@remixproject/plugin-utils": "0.3.33",
"@remixproject/plugin-ws": "0.3.33",
"axios": "1.6.0",
"chokidar": "^2.1.8",
"commander": "^9.4.1",
"fs-extra": "^3.0.1",
"isbinaryfile": "^3.0.2",
"latest-version": "^5.1.0",
"semver": "^6.3.0",
"ws": "^7.3.0"
},
"python": {
"execPath": "python3",
"dependencies": {
"vyper": ">=0.1.0b3"
}
},
"devDependencies": {
"@types/axios": "^0.14.0",
"@types/fs-extra": "^9.0.1",
"@types/node": "^18.16.1",
"@types/ws": "^7.2.4",
"@typescript-eslint/eslint-plugin": "^3.2.0",
"@typescript-eslint/parser": "^3.2.0",
"eslint": "6.8.0",
"eslint-config-standard": "14.1.1",
"eslint-plugin-import": "2.20.2",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-standard": "4.0.1",
"nodemon": "^2.0.4",
"ts-node": "^8.10.1",
"typescript": "^3.9.3"
},
"typings": "index.d.ts",
"gitHead": "ba6b2b226349d035146bd6deb120fef3d499ed16"
}

@ -0,0 +1,31 @@
{
"name": "remix-ai-core",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/remix-ai-core/src",
"projectType": "library",
"implicitDependencies": [
],
"targets": {
"build": {
"executor": "@nrwl/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/remix-ai-core",
"main": "libs/remix-ai-core/src/index.ts",
"tsConfig": "libs/remix-ai-core/tsconfig.lib.json",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [
"libs/remix-ai-core/*.md"
]
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["libs/remix-ai-core/**/*.ts"]
}
}
},
"tags": []
}

@ -0,0 +1,7 @@
'use strict'
import { Model, ModelResponse, ModelRequest, InferenceModel} from './types/types'
import { ModelType } from './types/constants'
export { Model, ModelResponse, ModelRequest, InferenceModel }

@ -0,0 +1,7 @@
/// constants for modelselection
export enum ModelType {
CODE_COMPLETION = 'code_completion',
GENERAL = 'general',
}

@ -0,0 +1,20 @@
// create a list of supported models
// create a function getModels returning a list of all supported models
// create a function getModel returning a model by its name
import { Model } from './types';
const supportedModels: Model[] = [];
const getModels = async (): Promise<Model[]> => {
return supportedModels;
}
const getModel = async (name: string): Promise<Model | undefined> => {
return supportedModels.find(model => model.name === name);
}
const loadModel = async (modelname: string): Promise<void> => {
console.log(`Loading model ${modelname}`);
}

@ -0,0 +1,29 @@
// model implementation for the model selection component
import exp from 'constants';
import { ModelType } from './constants';
export interface Model {
name: string;
download_url: string;
type: ModelType;
url: string;
}
export interface ModelResponse {
output: string;
error: string;
success: boolean;
model: Model;
}
export interface ModelRequest {
input: string;
model: Model;
}
export interface InferenceModel {
model: Model;
location: string;
isRemote: boolean;
}

@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}

@ -0,0 +1,13 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"outDir": "../../dist/out-tsc",
"declaration": true,
"rootDir": "./src",
"types": ["node"]
},
"exclude": ["**/*.spec.ts"],
"include": ["bin", "src", "bin/origins.json"]
}

@ -0,0 +1,15 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["node"]
},
"include": [
"**/*.spec.ts",
"**/*.spec.tsx",
"**/*.spec.js",
"**/*.spec.jsx",
"**/*.d.ts"
]
}

@ -0,0 +1,79 @@
// UI interface for selecting a model from a list of models
// This component is used in the ModelSelectionModal component
// It is a dropdown list of models that the user can select from
// The user can also search for a specific model by typing in the search bar
// The user can also filter the models by type
// The user can select a model from the dropdown list
// the panel controlling the model selection can be hidden or shown
// Once selected, the model is either loaded from the local storage or downloaded
// the remix ai desktop plugin provided the interface for storing the model in the local storage after downloading
import React, { useState, useEffect } from 'react';
import { Select, Input, Button, Icon } from 'antd';
import { Model } from '@remix/remix-ai-core';
import { getModels } from '../services';
import { ModelType } from '@remix/remix-ai-core';
import { useTranslation } from 'react-i18next';
const { Option } = Select;
const { Search } = Input;
interface ModelSelectionProps {
onSelect: (model: Model) => void;
}
export const ModelSelection: React.FC<ModelSelectionProps> = ({ onSelect }) => {
const { t } = useTranslation();
const [models, setModels] = useState<Model[]>([]);
const [filteredModels, setFilteredModels] = useState<Model[]>([]);
const [search, setSearch] = useState<string>('');
const [type, setType] = useState<ModelType | 'all'>('all');
useEffect(() => {
getModels().then(setModels);
}, []);
useEffect(() => {
setFilteredModels(models.filter((model) => {
return model.name.toLowerCase().includes(search.toLowerCase()) &&
(type === 'all' || model.type === type);
}));
}, [models, search, type]);
return (
<div>
<Search
placeholder={t('search_models')}
onChange={(e) => setSearch(e.target.value)}
style={{ width: 200, marginBottom: 10 }}
/>
<Select
defaultValue="all"
style={{ width: 200, marginBottom: 10 }}
onChange={(value) => setType(value)}
>
<Option value="all">{t('all_models')}</Option>
<Option value={ModelType.IMAGE}>{t('image_models')}</Option>
<Option value={ModelType.TEXT}>{t('text_models')}</Option>
<Option value={ModelType.AUDIO}>{t('audio_models')}</Option>
</Select>
<Select
showSearch
style={{ width: 200 }}
placeholder={t('select_model')}
optionFilterProp="children"
onChange={(value) => onSelect(models.find((model) => model.name === value))}
filterOption={(input, option) =>
option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
>
{filteredModels.map((model) => (
<Option key={model.name} value={model.name}>
{model.name}
</Option>
))}
</Select>
</div>
);
};

@ -176,6 +176,10 @@
"libs/remix-ui/remix-ai/src/index.ts"
],
"@remix/remix-ai-core": [
"libs/remix-ai-core/src/index.ts"
],
}
}
}

Loading…
Cancel
Save