|
|
@ -19,7 +19,7 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
// get text before the position of the completion
|
|
|
|
// get text before the position of the completion
|
|
|
|
let word = model.getValueInRange({ |
|
|
|
const word = model.getValueInRange({ |
|
|
|
startLineNumber: 1, |
|
|
|
startLineNumber: 1, |
|
|
|
startColumn: 1, |
|
|
|
startColumn: 1, |
|
|
|
endLineNumber: position.lineNumber, |
|
|
|
endLineNumber: position.lineNumber, |
|
|
@ -38,21 +38,25 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
word = word.split('\n') |
|
|
|
try { |
|
|
|
if (!word.length) return |
|
|
|
const split = word.split('\n') |
|
|
|
const ask = word[word.length - 2].trimStart() |
|
|
|
if (!split.length) return |
|
|
|
if (word[word.length - 1] === '' && ask.startsWith('///')) { |
|
|
|
const ask = split[split.length - 2].trimStart() |
|
|
|
// use the code generation model
|
|
|
|
if (split[split.length - 1].trim() === '' && ask.startsWith('///')) { |
|
|
|
const {data} = await axios.post('https://gpt-chat.remixproject.org/infer', {comment: ask.replace('///', ''}) |
|
|
|
// use the code generation model
|
|
|
|
const parsedData = JSON.parse(data).trimStart() |
|
|
|
const {data} = await axios.post('https://gpt-chat.remixproject.org/infer', {comment: ask.replace('///', '')}) |
|
|
|
console.log('parsedData', parsedData) |
|
|
|
const parsedData = JSON.parse(data).trimStart() |
|
|
|
const item: monacoTypes.languages.InlineCompletion = { |
|
|
|
console.log('parsedData', parsedData) |
|
|
|
insertText: parsedData |
|
|
|
const item: monacoTypes.languages.InlineCompletion = { |
|
|
|
}; |
|
|
|
insertText: parsedData |
|
|
|
return { |
|
|
|
}; |
|
|
|
items: [item], |
|
|
|
return { |
|
|
|
enableForwardStability: true |
|
|
|
items: [item], |
|
|
|
|
|
|
|
enableForwardStability: true |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
console.error(e) |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// abort if there is a signal
|
|
|
|
// abort if there is a signal
|
|
|
|