update model input

pull/5370/head
yann300 12 months ago committed by GitHub
parent e15be7a032
commit cffcff6a95
  1. 13
      libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts

@ -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
const word = model.getValueInRange({ let word = model.getValueInRange({
startLineNumber: 1, startLineNumber: 1,
startColumn: 1, startColumn: 1,
endLineNumber: position.lineNumber, endLineNumber: position.lineNumber,
@ -38,13 +38,12 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
return; return;
} }
// eslint-disable-next-line no-useless-escape word = word.split('\n')
const regex = new RegExp('\/\/\/(.*)\n ', 'g') if (!word.length) return
const ask = word[word.length - 2].trimStart()
const generativeComment = [...word.matchAll(regex)] if (word[word.length - 1] === '' && ask.startsWith('///')) {
if (generativeComment && generativeComment.length) {
// use the code generation model // use the code generation model
const {data} = await axios.post('https://gpt-chat.remixproject.org/infer', {comment: generativeComment[generativeComment.length - 1][1]}) 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 = {

Loading…
Cancel
Save