pull/4956/head
Stéphane Tetsing 5 months ago
parent 4b8c4ffe77
commit da7bee6bee
  1. 71
      apps/remixdesktop/src/plugins/remixAIDektop.ts
  2. 734
      apps/remixdesktop/yarn.lock
  3. 4
      libs/remix-ai-core/src/index.ts
  4. 3
      libs/remix-ai-core/src/types/constants.ts
  5. 9
      libs/remix-ai-core/src/types/models.ts
  6. 7
      libs/remix-ai-core/src/types/types.ts
  7. 5
      libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts
  8. 23
      libs/remix-ui/remix-ai/src/lib/components/Default.tsx
  9. 3
      package.json
  10. 54
      yarn.lock

@ -5,7 +5,7 @@ import { app } from 'electron';
import axios from "axios";
import fs from 'fs';
import path from 'path';
import {LlamaModel, LlamaContext, LlamaChatSession, LlamaModelOptions} from "node-llama-cpp";
//import {LlamaModel, LlamaContext, LlamaChatSession, LlamaModelOptions} from "node-llama-cpp";
// import { isE2E } from "../main";
@ -39,7 +39,7 @@ const clientProfile: Profile = {
description: 'RemixAI provides AI services to Remix IDE Desktop.',
kind: '',
documentation: 'https://remix-ide.readthedocs.io/en/latest/remixai.html',
methods: ['downloadModel']
methods: ['downloadModel', 'getInferenceModel']
}
class RemixAIDesktopPluginClient extends ElectronBasePluginClient {
@ -66,8 +66,6 @@ class RemixAIDesktopPluginClient extends ElectronBasePluginClient {
console.log('Remix AI desktop plugin enabled')
this.emit('enabled')
}
async downloadModel(model): Promise<void> {
console.log('Downloading the model model', model)
@ -124,41 +122,46 @@ class RemixAIDesktopPluginClient extends ElectronBasePluginClient {
writer.on('finish', resolve);
writer.on('error', reject);
});
}
async loadLocalModel(): Promise<LlamaChatSession> {
if (!this.SelectedModelPath) {
console.log('No model selected yet');
return;
}
console.log('Loading model at ', this.SelectedModelPath);
const model = new LlamaModel(this.SelectedModelPath);
// async _loadLocalModel(): Promise<LlamaChatSession> {
// if (!this.SelectedModelPath) {
// console.log('No model selected yet');
// return;
// }
// console.log('Loading model at ', this.SelectedModelPath);
// const model = new LlamaModel(this._getModelOptions());
const context = new LlamaContext({model});
const session = new LlamaChatSession({context});
// const context = new LlamaContext({model});
// const session = new LlamaChatSession({context});
return session;
}
// return session;
// }
_getModelOptions(): LlamaModelOptions {
const options: LlamaModelOptions = {
modelPath: this.SelectedModelPath,
contextSize: 1024,
batchSize: 1,
gpuLayers: 0,
threads: 1,
temperature: 0.9,
topK: 0,
topP: 1,
logitsAll: false,
vocabOnly: false,
useMmap: false,
useMlock: false,
embedding: false,
};
return options;
}
// _getModelOptions(): LlamaModelOptions {
// const options: LlamaModelOptions = {
// modelPath: this.SelectedModelPath? this.SelectedModelPath: null,
// contextSize: 1024,
// batchSize: 1,
// gpuLayers: this.selectedModel.modelReqs.GPURequired? -1: 0,
// threads: 1,
// temperature: 0.9,
// topK: 0,
// topP: 1,
// logitsAll: false,
// vocabOnly: false,
// useMmap: false,
// useMlock: false,
// embedding: false,
// };
// return options;
// }
// async getInferenceModel(): Promise<LlamaChatSession> {
// return this._loadLocalModel();
// }
}

File diff suppressed because it is too large Load Diff

@ -3,6 +3,6 @@
import { IModel, IModelResponse, IModelRequest, InferenceModel} from './types/types'
import { ModelType } from './types/constants'
import { DefaultModels } from './types/models'
import { InlineCompletionServiceTransformer } from './completions/completionTransformer'
export { IModel, IModelResponse, IModelRequest, InferenceModel, ModelType, DefaultModels}
export { IModel, IModelResponse, IModelRequest, InferenceModel, ModelType, DefaultModels, InlineCompletionServiceTransformer}

@ -3,4 +3,7 @@
export enum ModelType {
CODE_COMPLETION = 'code_completion',
GENERAL = 'general',
CODE_COMPLETION_INSERTION = 'code_completion_insertion',
}
export const COMPLETION_SYSTEM_PROMPT = "You are a Solidity AI Assistant that complete user code with provided context. You provide accurate solution and always answer as helpfully as possible, while being safe. You only provide code using this context:\n"

@ -20,8 +20,15 @@ const DefaultModels = (): IModel[] => {
modelType: ModelType.GENERAL,
modelReqs: { backend: 'llamacpp', minSysMemory: 8, GPURequired: true, MinGPUVRAM: 8}
};
const model3: IModel = {
name: 'DeepSeekTransformer',
modelName: 'Xenova/deepseek-coder-1.3b-base',
downloadUrl: 'Xenova/deepseek-coder-1.3b-base',
modelType: ModelType.CODE_COMPLETION_INSERTION,
modelReqs: { backend: 'transformer', minSysMemory: 2, GPURequired: false, MinGPUVRAM: 2}
};
return [model1, model2];
return [model1, model2, model3];
}
const getModel = async (name: string): Promise<IModel | undefined> => {

@ -13,7 +13,7 @@ export interface IModelRequirements{
export interface IModel {
name: string;
downloadUrl: string;
modelName?: string;
modelName: string;
modelType: ModelType;
modelReqs: IModelRequirements;
}
@ -35,3 +35,8 @@ export interface InferenceModel {
location: string;
isRemote: boolean;
}
export interface ICompletions{
code_completion(context): Promise<any>;
code_insertion(msg_pfx, msg_sfx): Promise<any>;
}

@ -6,10 +6,6 @@ import axios, {AxiosResponse} from 'axios'
import { slice } from 'lodash';
const _paq = (window._paq = window._paq || [])
const controller = new AbortController();
const { signal } = controller;
const result: string = ''
export class RemixInLineCompletionProvider implements monacoTypes.languages.InlineCompletionsProvider {
props: EditorUIProps
monaco: any
@ -127,7 +123,6 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
}
}
let result
try {
// Code completion
const output = await this.props.plugin.call('solcoder', 'code_completion', word)

@ -1,6 +1,7 @@
import React, { useContext, useEffect, useState } from 'react'
import '../remix-ai.css'
import { DefaultModels } from '@remix/remix-ai-core';
import { InlineCompletionServiceTransformer} from '@remix/remix-ai-core';
export const Default = (props) => {
const [searchText, setSearchText] = useState('');
@ -39,6 +40,7 @@ export const Default = (props) => {
> Download Model </button>
</div>
<div className="remix_ai_plugin_find_container_internal">
<textarea
className="remix_ai_plugin_search_result_textbox"
@ -48,6 +50,27 @@ export const Default = (props) => {
value={resultText}
readOnly
/>
<button className="remix_ai_plugin_download_button text-ai pl-2 pr-0 py-0 d-flex"
onClick={async () => {
if (props.plugin.isOnDesktop ) {
const completer = new InlineCompletionServiceTransformer();
if (!completer.ready) {
await completer.init();
}
const code = completer.code_completion("pragma solidity ^0.8.0;\n")
console.log("Got code completion ",code);
// const inferenceModel = await props.plugin.call(pluginName, 'getInferenceModel');
// console.log("Got inference model ",inferenceModel);
// const result = await inferenceModel.prompt("What is the meaning of life?");
// console.log("Got result ",result);
}
}}
> Test inference </button>
</div>
<div className="remix_ai_plugin_find-part">
<a href="#" className="remix_ai_plugin_search_result_item_title">/fix the problems in my code</a>

@ -116,7 +116,7 @@
"@ricarso/react-image-magnifiers": "^1.9.0",
"@types/nightwatch": "^2.3.1",
"@web3modal/ethers5": "^4.0.1",
"@xenova/transformers": "^2.7.0",
"@xenova/transformers": "^2.17.2",
"ansi-gray": "^0.1.1",
"assert": "^2.1.0",
"async": "^2.6.2",
@ -163,6 +163,7 @@
"merge": "^2.1.1",
"npm-install-version": "^6.0.2",
"octokit": "^3.1.2",
"onnxruntime-web": "^1.18.0",
"openai": "^3.3.0",
"path-browserify": "^1.0.1",
"prettier": "^2.8.4",

@ -2935,6 +2935,11 @@
semiver "^1.1.0"
ws "^8.13.0"
"@huggingface/jinja@^0.2.2":
version "0.2.2"
resolved "https://registry.yarnpkg.com/@huggingface/jinja/-/jinja-0.2.2.tgz#faeb205a9d6995089bef52655ddd8245d3190627"
integrity sha512-/KPde26khDUIPkTGU82jdtTW9UAuvUTumCAbFs/7giR0SxsvZC4hru51PBvpijH6BVkHcROcvZM/lpy5h1jRRA==
"@humanwhocodes/config-array@^0.11.10":
version "0.11.10"
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.10.tgz#5a3ffe32cc9306365fb3fd572596cd602d5e12d2"
@ -7419,11 +7424,12 @@
resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-1.7.0.tgz#e1993689ac42d2b16e9194376cfb6753f6254db1"
integrity sha512-oxnCNGj88fL+xzV+dacXs44HcDwf1ovs3AuEzvP7mqXw7fQntqIhQ1BRmynh4qEKQSSSRSWVyXRjmTbZIX9V2Q==
"@xenova/transformers@^2.7.0":
version "2.7.0"
resolved "https://registry.yarnpkg.com/@xenova/transformers/-/transformers-2.7.0.tgz#0aabc8700d32ed8e28f6aa61abf8653f62fb1678"
integrity sha512-py5RqZt9lL/FFUT5X6St+TOSBoVaEmDETI98lK9ApEOvlWeX4bTS2nMQDFe3nFMpv24+wllhmPw2Www/f/ubJA==
"@xenova/transformers@^2.17.2":
version "2.17.2"
resolved "https://registry.yarnpkg.com/@xenova/transformers/-/transformers-2.17.2.tgz#7448d73b90f67bced66f39fe2dd656adc891fde5"
integrity sha512-lZmHqzrVIkSvZdKZEx7IYY51TK0WDrC8eR0c5IMnBsO8di8are1zzw8BlLhyO2TklZKLN5UffNGs1IJwT6oOqQ==
dependencies:
"@huggingface/jinja" "^0.2.2"
onnxruntime-web "1.14.0"
sharp "^0.32.0"
optionalDependencies:
@ -19565,6 +19571,11 @@ long@^4.0.0:
resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28"
integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==
long@^5.0.0, long@^5.2.3:
version "5.2.3"
resolved "https://registry.yarnpkg.com/long/-/long-5.2.3.tgz#a3ba97f3877cf1d778eccbcb048525ebb77499e1"
integrity sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==
longest-streak@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/longest-streak/-/longest-streak-3.1.0.tgz#62fa67cd958742a1574af9f39866364102d90cd4"
@ -22429,6 +22440,11 @@ onnx-proto@^4.0.4:
dependencies:
protobufjs "^6.8.8"
onnxruntime-common@1.18.0:
version "1.18.0"
resolved "https://registry.yarnpkg.com/onnxruntime-common/-/onnxruntime-common-1.18.0.tgz#b904dc6ff134e7f21a3eab702fac17538f59e116"
integrity sha512-lufrSzX6QdKrktAELG5x5VkBpapbCeS3dQwrXbN0eD9rHvU0yAWl7Ztju9FvgAKWvwd/teEKJNj3OwM6eTZh3Q==
onnxruntime-common@~1.14.0:
version "1.14.0"
resolved "https://registry.yarnpkg.com/onnxruntime-common/-/onnxruntime-common-1.14.0.tgz#2bb5dac5261269779aa5fb6536ca379657de8bf6"
@ -22453,6 +22469,18 @@ onnxruntime-web@1.14.0:
onnxruntime-common "~1.14.0"
platform "^1.3.6"
onnxruntime-web@^1.18.0:
version "1.18.0"
resolved "https://registry.yarnpkg.com/onnxruntime-web/-/onnxruntime-web-1.18.0.tgz#cd46268d9472f89697da0a3282f13129f0acbfa0"
integrity sha512-o1UKj4ABIj1gmG7ae0RKJ3/GT+3yoF0RRpfDfeoe0huzRW4FDRLfbkDETmdFAvnJEXuYDE0YT+hhkia0352StQ==
dependencies:
flatbuffers "^1.12.0"
guid-typescript "^1.0.9"
long "^5.2.3"
onnxruntime-common "1.18.0"
platform "^1.3.6"
protobufjs "^7.2.4"
open@^8.0.9, open@^8.4.0:
version "8.4.0"
resolved "https://registry.yarnpkg.com/open/-/open-8.4.0.tgz#345321ae18f8138f82565a910fdc6b39e8c244f8"
@ -23971,6 +23999,24 @@ protobufjs@^6.8.8:
"@types/node" ">=13.7.0"
long "^4.0.0"
protobufjs@^7.2.4:
version "7.3.2"
resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-7.3.2.tgz#60f3b7624968868f6f739430cfbc8c9370e26df4"
integrity sha512-RXyHaACeqXeqAKGLDl68rQKbmObRsTIn4TYVUUug1KfS47YWCo5MacGITEryugIgZqORCvJWEk4l449POg5Txg==
dependencies:
"@protobufjs/aspromise" "^1.1.2"
"@protobufjs/base64" "^1.1.2"
"@protobufjs/codegen" "^2.0.4"
"@protobufjs/eventemitter" "^1.1.0"
"@protobufjs/fetch" "^1.1.0"
"@protobufjs/float" "^1.0.2"
"@protobufjs/inquire" "^1.1.0"
"@protobufjs/path" "^1.1.2"
"@protobufjs/pool" "^1.1.0"
"@protobufjs/utf8" "^1.1.0"
"@types/node" ">=13.7.0"
long "^5.0.0"
protocol-buffers-schema@^3.3.1:
version "3.6.0"
resolved "https://registry.yarnpkg.com/protocol-buffers-schema/-/protocol-buffers-schema-3.6.0.tgz#77bc75a48b2ff142c1ad5b5b90c94cd0fa2efd03"

Loading…
Cancel
Save