working base

pull/4801/head
Stéphane Tetsing 6 months ago
parent 92d059c839
commit dd35effcd2
  1. 7
      apps/remix-ide/src/app/plugins/solcoderAI.tsx
  2. 41
      libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts

@ -15,7 +15,7 @@ const profile = {
name: 'solcoder',
displayName: 'solcoder',
description: 'solcoder',
methods: ['code_generation', 'code_completion', "solidity_answer", "code_explaining", "code_insertion"],
methods: ['code_generation', 'code_completion', "solidity_answer", "code_explaining", "code_insertion", "contract_generation"],
events: [],
maintainedBy: 'Remix',
}
@ -219,12 +219,12 @@ export class SolCoder extends Plugin {
}
}
async contract_genertion(prompt): Promise<any> {
async contract_generation(prompt): Promise<any> {
this.emit("aiInfering")
let result
try {
result = await(
await fetch(this.completion_url, {
await fetch(this.api_url, {
method: 'POST',
headers: {
Accept: 'application/json',
@ -255,7 +255,6 @@ export class SolCoder extends Plugin {
}
}
_build_solgpt_promt(user_promt:string){
if (this.solgpt_chat_history.length === 0){
return user_promt

@ -46,6 +46,28 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
endColumn: getTextAtLine(model.getLineCount()).length + 1,
});
if (this.isSolidityComment(word) &&
word.includes("sol-gen") &&
this.isGeneratingContract===false &&
word.split('\n')[word.split('\n').length-1].trim()===""){
this.isGeneratingContract = true
console.log("new contract generation")
const output = await this.props.plugin.call('solcoder', 'contract_generation', word)
_paq.push(['trackEvent', 'ai', 'solcoder', 'contract_generation'])
const handleCompletionTimer = new CompletionTimer(5000, () => { this.isGeneratingContract = false });
handleCompletionTimer.start()
const item: monacoTypes.languages.InlineCompletion = {
insertText: output[0]
};
return {
items: [item],
enableForwardStability: true
}
}
if (!word.endsWith(' ') &&
!word.endsWith('.') &&
!word.endsWith('(')) {
@ -85,25 +107,6 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
return
}
console.log("is sol comment", this.isSolidityComment(word))
if (this.isSolidityComment(word) && word.includes("sol-gen") && this.isGeneratingContract===false){
this.isGeneratingContract = true
console.log("new contract generation")
const output = await this.props.plugin.call('solcoder', 'contract_generation', word)
_paq.push(['trackEvent', 'ai', 'solcoder', 'contract_generation'])
const handleCompletionTimer = new CompletionTimer(5000, () => { this.isGeneratingContract = false });
handleCompletionTimer.start()
const item: monacoTypes.languages.InlineCompletion = {
insertText: output[0]
};
return {
items: [item],
enableForwardStability: true
}
}
if (word.split('\n').at(-1).trimStart().startsWith('//') ||
word.split('\n').at(-1).trimStart().startsWith('/*') ||
word.split('\n').at(-1).trimStart().startsWith('*') ||

Loading…
Cancel
Save