diff --git a/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts b/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts index 71c91e3d80..7cdd9f3f21 100644 --- a/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts +++ b/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts @@ -1,4 +1,5 @@ import { EditorUIProps, monacoTypes } from '@remix-ui/editor'; +import axios from 'axios'; const controller = new AbortController(); const { signal } = controller; const result: string = '' @@ -21,35 +22,25 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli }); // abort if there is a signal - + if (token.isCancellationRequested) { + console.log('aborted') + return { items: [] }; + } - const url = 'http://localhost:9090/infer' + const url = 'http://localhost:8000/infer' const data = {'prefix': 'contract test', 'max_token': 20} - const response = await fetch(url, { - method: "POST", - mode: "no-cors", - cache: "no-cache", - headers: { - "Content-Type": "application/json", - }, - signal, - redirect: "follow", - referrerPolicy: "no-referrer", - body: JSON.stringify(data), - }); - - + const response = await axios.post(url, data, {signal}) - console.log(response.body) + console.log(response.data.data) console.log('word', word) const item: monacoTypes.languages.InlineCompletion = { insertText: { - snippet: 'hello world\nhuman readable', + snippet: response.data.data, } }; diff --git a/mock-serve-data.json b/mock-serve-data.json new file mode 100644 index 0000000000..a734e6acf7 --- /dev/null +++ b/mock-serve-data.json @@ -0,0 +1,7 @@ +{ + "/infer": { + "post": { + "data": "testing data" + } + } +} \ No newline at end of file