try getting some content

pull/4175/head
yann300 1 year ago
parent 144b5440c8
commit 607aa25f21
  1. 22
      apps/remix-ide/src/app/plugins/copilot/suggestion-service/copilot-suggestion.ts

@ -11,9 +11,11 @@ const profile = {
export class CopilotSuggestion extends Plugin { export class CopilotSuggestion extends Plugin {
service: SuggestionService service: SuggestionService
context: string
constructor() { constructor() {
super(profile) super(profile)
this.service = new SuggestionService() this.service = new SuggestionService()
this.context = ''
this.service.events.on('progress', (data) => { this.service.events.on('progress', (data) => {
this.call('terminal', 'log', {type: 'info', value: `loading Solidity copilot: ${(data.loaded / data.total) * 100}% done.` }) this.call('terminal', 'log', {type: 'info', value: `loading Solidity copilot: ${(data.loaded / data.total) * 100}% done.` })
}) })
@ -22,7 +24,7 @@ export class CopilotSuggestion extends Plugin {
}) })
this.service.events.on('ready', (data) => { this.service.events.on('ready', (data) => {
this.call('terminal', 'log', { type: 'info', value: `Solidity copilot ready to use.`}) this.call('terminal', 'log', { type: 'info', value: `Solidity copilot ready to use.`})
}) })
} }
async suggest(content: string) { async suggest(content: string) {
@ -37,13 +39,25 @@ export class CopilotSuggestion extends Plugin {
temperature, temperature,
max_new_tokens max_new_tokens
} }
return this.service.suggest(content, options) return this.service.suggest(this.context ? this.context + '\n\n' + content : content, options)
}
async loadModeContent() {
let importsContent = ''
const imports = await this.call('codeParser', 'getImports')
for (const imp of imports.modules) {
try {
importsContent += '\n\n' + (await this.call('contentImport', 'resolve', imp)).content
} catch (e) {
console.log(e)
}
}
return importsContent
} }
async init() { async init() {
return this.service.init() return this.service.init()
} }
async uninstall() { async uninstall() {}
}
} }
Loading…
Cancel
Save