|
|
|
@ -1,4 +1,5 @@ |
|
|
|
|
import { Plugin } from '@remixproject/engine' |
|
|
|
|
import {SuggestOptions} from './copilot/suggestion-service/suggestion-service' |
|
|
|
|
|
|
|
|
|
const _paq = (window._paq = window._paq || []) |
|
|
|
|
|
|
|
|
@ -6,7 +7,7 @@ const profile = { |
|
|
|
|
name: 'solcoder', |
|
|
|
|
displayName: 'solcoder', |
|
|
|
|
description: 'solcoder', |
|
|
|
|
methods: ['code_generation', 'code_completion'], |
|
|
|
|
methods: ['code_generation', 'code_completion', "solidity_answer"], |
|
|
|
|
events: [], |
|
|
|
|
maintainedBy: 'Remix', |
|
|
|
|
} |
|
|
|
@ -31,6 +32,28 @@ export class SolCoder extends Plugin { |
|
|
|
|
body: JSON.stringify({"data":[prompt,false,1000,0.2,0.8,50]}), |
|
|
|
|
}) |
|
|
|
|
).json() |
|
|
|
|
return result.data[0] |
|
|
|
|
} catch (e) { |
|
|
|
|
this.call('terminal', 'log', { type: 'typewritererror', value: `Unable to get a response ${e.message}` }) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async solidity_answer(prompt): Promise<any> { |
|
|
|
|
this.call('layout', 'maximizeTerminal') |
|
|
|
|
this.call('terminal', 'log', 'Waiting for Solcoder answer...') |
|
|
|
|
let result |
|
|
|
|
try { |
|
|
|
|
result = await( |
|
|
|
|
await fetch("https://hkfll35zthu6e2-7861.proxy.runpod.net/api/solidity_answer", { |
|
|
|
|
method: 'POST', |
|
|
|
|
headers: { |
|
|
|
|
Accept: 'application/json', |
|
|
|
|
'Content-Type': 'application/json', |
|
|
|
|
}, |
|
|
|
|
body: JSON.stringify({"data":[prompt,false,1000,0.9,0.8,50]}), |
|
|
|
|
}) |
|
|
|
|
).json() |
|
|
|
|
} catch (e) { |
|
|
|
|
this.call('terminal', 'log', { type: 'typewritererror', value: `Unable to get a response ${e.message}` }) |
|
|
|
|
return |
|
|
|
@ -44,7 +67,7 @@ export class SolCoder extends Plugin { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async code_completion(prompt): Promise<any> { |
|
|
|
|
async code_completion(prompt, options:SuggestOptions=null): Promise<any> { |
|
|
|
|
let result |
|
|
|
|
try { |
|
|
|
|
result = await( |
|
|
|
@ -54,19 +77,27 @@ export class SolCoder extends Plugin { |
|
|
|
|
Accept: 'application/json', |
|
|
|
|
'Content-Type': 'application/json', |
|
|
|
|
}, |
|
|
|
|
body: JSON.stringify({"data":[ |
|
|
|
|
body: JSON.stringify({"data": !options? [ |
|
|
|
|
prompt, // string in 'context_code' Textbox component
|
|
|
|
|
"", // string in 'comment' Textbox component
|
|
|
|
|
false, // boolean in 'stream_result' Checkbox component
|
|
|
|
|
200, // number (numeric value between 0 and 2000) in 'max_new_tokens' Slider component
|
|
|
|
|
0.4, // number (numeric value between 0.01 and 1) in 'temperature' Slider component
|
|
|
|
|
0.9, // number (numeric value between 0.01 and 1) in 'temperature' Slider component
|
|
|
|
|
0.90, // number (numeric value between 0 and 1) in 'top_p' Slider component
|
|
|
|
|
50, // number (numeric value between 1 and 200) in 'top_k' Slider component
|
|
|
|
|
]}), |
|
|
|
|
] : [ |
|
|
|
|
prompt, |
|
|
|
|
"", |
|
|
|
|
options.stream_result, |
|
|
|
|
options.max_new_tokens, |
|
|
|
|
options.temperature, |
|
|
|
|
options.top_p, |
|
|
|
|
options.top_k |
|
|
|
|
] |
|
|
|
|
}), |
|
|
|
|
}) |
|
|
|
|
).json() |
|
|
|
|
|
|
|
|
|
console.log('solcoder result', result.data) |
|
|
|
|
return result.data |
|
|
|
|
} catch (e) { |
|
|
|
|
this.call('terminal', 'log', { type: 'typewritererror', value: `Unable to get a response ${e.message}` }) |
|
|
|
|