Skip to content

Commit b6966cd

Browse files
authored
update model input
1 parent 8779bcb commit b6966cd

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
1919
return;
2020
}
2121
// get text before the position of the completion
22-
const word = model.getValueInRange({
22+
let word = model.getValueInRange({
2323
startLineNumber: 1,
2424
startColumn: 1,
2525
endLineNumber: position.lineNumber,
@@ -38,13 +38,12 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
3838
return;
3939
}
4040

41-
// eslint-disable-next-line no-useless-escape
42-
const regex = new RegExp('\/\/\/(.*)\n ', 'g')
43-
44-
const generativeComment = [...word.matchAll(regex)]
45-
if (generativeComment && generativeComment.length) {
41+
word = word.split('\n')
42+
if (!word.length) return
43+
const ask = word[word.length - 2].trimStart()
44+
if (word[word.length - 1] === '' && ask.startsWith('///')) {
4645
// use the code generation model
47-
const {data} = await axios.post('https://gpt-chat.remixproject.org/infer', {comment: generativeComment[generativeComment.length - 1][1]})
46+
const {data} = await axios.post('https://gpt-chat.remixproject.org/infer', {comment: ask.replace('///', ''})
4847
const parsedData = JSON.parse(data).trimStart()
4948
console.log('parsedData', parsedData)
5049
const item: monacoTypes.languages.InlineCompletion = {
@@ -55,7 +54,7 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
5554
enableForwardStability: true
5655
}
5756
}
58-
57+
5958
// abort if there is a signal
6059
if (token.isCancellationRequested) {
6160
console.log('aborted')

0 commit comments

Comments
 (0)