added plugin api types

pull/5100/head
STetsing 2 months ago
parent 3fb2da4bb9
commit efe26270b1
  1. 23
      apps/remix-ide/src/app/plugins/remixAIPlugin.tsx
  2. 23
      libs/remix-api/src/lib/plugins/remixAIDesktop-api.ts
  3. 21
      libs/remix-api/src/lib/plugins/remixai-api.ts
  4. 5
      libs/remix-api/src/lib/remix-api.ts

@ -4,6 +4,7 @@ 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 { CustomRemixApi } from '@remix-api'
const profile = {
name: 'remixAI',
@ -22,7 +23,7 @@ const profile = {
maintainedBy: 'Remix'
}
export class RemixAIPlugin extends Plugin {
export class RemixAIPlugin extends Plugin<any, CustomRemixApi> {
isOnDesktop:boolean = false
aiIsActivated:boolean = false
readonly remixDesktopPluginName = 'remixAID'
@ -84,7 +85,7 @@ export class RemixAIPlugin extends Plugin {
async code_generation(prompt: string): Promise<any> {
if (this.isInferencing) {
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: "RemixAI is already busy!" })
this.call('terminal', 'logHtml', "RemixAI is already busy!")
return
}
@ -105,11 +106,11 @@ export class RemixAIPlugin extends Plugin {
async solidity_answer(prompt: string): Promise<any> {
if (this.isInferencing) {
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: "RemixAI is already busy!" })
this.call('terminal', 'logHtml', "RemixAI is already busy!" )
return
}
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: `\n\nWaiting for RemixAI answer...` })
this.call('terminal', 'logHtml', '\n\nWaiting for RemixAI answer...')
let result
if (this.isOnDesktop) {
@ -117,18 +118,18 @@ export class RemixAIPlugin extends Plugin {
} else {
result = await this.remoteInferencer.solidity_answer(prompt)
}
if (result) this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result })
if (result) this.call('terminal', 'logHtml', result)
// this.call('terminal', 'log', { type: 'aitypewriterwarning', value: "RemixAI Done" })
return result
}
async code_explaining(prompt: string): Promise<any> {
if (this.isInferencing) {
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: "RemixAI is already busy!" })
this.call('terminal', 'logHtml',"RemixAI is already busy!")
return
}
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: `\n\nWaiting for RemixAI answer...` })
this.call('terminal', 'logHtml', '\n\nWaiting for RemixAI answer...')
let result
if (this.isOnDesktop) {
@ -137,18 +138,18 @@ export class RemixAIPlugin extends Plugin {
} else {
result = await this.remoteInferencer.code_explaining(prompt)
}
if (result) this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result })
if (result) this.call('terminal', 'logHtml', result )
// this.call('terminal', 'log', { type: 'aitypewriterwarning', value: "RemixAI Done" })
return result
}
async error_explaining(prompt: string): Promise<any> {
if (this.isInferencing) {
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: "RemixAI is already busy!" })
this.call('terminal', 'logHtml', "RemixAI is already busy!")
return
}
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: `\n\nWaiting for RemixAI answer...` })
this.call('terminal', 'logHtml', '\n\nWaiting for RemixAI answer...')
let result
if (this.isOnDesktop) {
@ -156,7 +157,7 @@ export class RemixAIPlugin extends Plugin {
} else {
result = await this.remoteInferencer.error_explaining(prompt)
}
if (result) this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result })
if (result) this.call('terminal', 'logHtml', result)
// this.call('terminal', 'log', { type: 'aitypewriterwarning', value: "RemixAI Done" })
return result
}

@ -0,0 +1,23 @@
import { IParams } from "@remix/remix-ai-core";
import { StatusEvents } from "@remixproject/plugin-utils";
export interface IRemixAID {
events: {
activated():void,
onInference():void,
onInferenceDone():void,
onStreamResult(streamText: string):void,
} & StatusEvents,
methods: {
code_completion(context: string): Promise<string>
code_insertion(msg_pfx: string, msg_sfx: string): Promise<string>,
code_generation(prompt: string): Promise<string | null>,
code_explaining(code: string, context?: string): Promise<string | null>,
error_explaining(prompt: string): Promise<string | null>,
solidity_answer(prompt: string): Promise<string | null>,
initializeModelBackend(local: boolean, generalModel?, completionModel?): Promise<boolean>,
chatPipe(pipeMessage: string): Promise<void>,
ProcessChatRequestBuffer(params:IParams): Promise<void>,
}
}

@ -0,0 +1,21 @@
import { IModel, IParams, IRemoteModel } from "@remix/remix-ai-core";
import { StatusEvents } from "@remixproject/plugin-utils";
export interface IRemixAI {
events: {
onStreamResult(streamText: string): Promise<void>,
activated(): Promise<void>,
} & StatusEvents,
methods: {
code_completion(context: string): Promise<string>
code_insertion(msg_pfx: string, msg_sfx: string): Promise<string>,
code_generation(prompt: string): Promise<string | null>,
code_explaining(code: string, context?: string): Promise<string | null>,
error_explaining(prompt: string): Promise<string | null>,
solidity_answer(prompt: string): Promise<string | null>,
initializeModelBackend(local: boolean, generalModel?, completionModel?): Promise<void>,
chatPipe(pipeMessage: string): Promise<void>,
ProcessChatRequestBuffer(params:IParams): Promise<void>,
initialize(model1?:IModel, model2?:IModel, remoteModel?:IRemoteModel, useRemote?:boolean): Promise<void>,
}
}

@ -14,6 +14,8 @@ import { IPinnedPanelApi } from "./plugins/pinned-panel-api"
import { ILayoutApi } from "./plugins/layout-api"
import { IMatomoApi } from "./plugins/matomo-api"
import { IRemixAI } from "./plugins/remixai-api"
import { IRemixAID } from "./plugins/remixAIDesktop-api"
export interface ICustomRemixApi extends IRemixApi {
dgitApi: IGitApi
@ -30,7 +32,8 @@ export interface ICustomRemixApi extends IRemixApi {
pinnedPanel: IPinnedPanelApi
layout: ILayoutApi
matomo: IMatomoApi
remixAI: IRemixAI
remixAI: IRemixAI,
remixAID: IRemixAID
}
export declare type CustomRemixApi = Readonly<ICustomRemixApi>
Loading…
Cancel
Save