|
|
@ -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,12 +38,13 @@ 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() |
|
|
|
|
|
|
|
if (split[split.length - 1].trim() === '' && ask.startsWith('///')) { |
|
|
|
// use the code generation model
|
|
|
|
// use the code generation model
|
|
|
|
const {data} = await axios.post('https://gpt-chat.remixproject.org/infer', {comment: ask.replace('///', ''}) |
|
|
|
const {data} = await axios.post('https://gpt-chat.remixproject.org/infer', {comment: ask.replace('///', '')}) |
|
|
|
const parsedData = JSON.parse(data).trimStart() |
|
|
|
const parsedData = JSON.parse(data).trimStart() |
|
|
|
console.log('parsedData', parsedData) |
|
|
|
console.log('parsedData', parsedData) |
|
|
|
const item: monacoTypes.languages.InlineCompletion = { |
|
|
|
const item: monacoTypes.languages.InlineCompletion = { |
|
|
@ -54,6 +55,9 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli |
|
|
|
enableForwardStability: true |
|
|
|
enableForwardStability: true |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
console.error(e) |
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// abort if there is a signal
|
|
|
|
// abort if there is a signal
|
|
|
|
if (token.isCancellationRequested) { |
|
|
|
if (token.isCancellationRequested) { |
|
|
|