add mock data

pull/4175/head
filip mertens 1 year ago committed by yann300
parent 81357381f1
commit a10a1f30ef
  1. 27
      libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts
  2. 7
      mock-serve-data.json

@ -1,4 +1,5 @@
import { EditorUIProps, monacoTypes } from '@remix-ui/editor'; import { EditorUIProps, monacoTypes } from '@remix-ui/editor';
import axios from 'axios';
const controller = new AbortController(); const controller = new AbortController();
const { signal } = controller; const { signal } = controller;
const result: string = '' const result: string = ''
@ -21,35 +22,25 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
}); });
// abort if there is a signal // 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 data = {'prefix': 'contract test', 'max_token': 20}
const response = await fetch(url, { const response = await axios.post(url, data, {signal})
method: "POST",
mode: "no-cors",
cache: "no-cache",
headers: {
"Content-Type": "application/json",
},
signal,
redirect: "follow",
referrerPolicy: "no-referrer",
body: JSON.stringify(data),
});
console.log(response.body) console.log(response.data.data)
console.log('word', word) console.log('word', word)
const item: monacoTypes.languages.InlineCompletion = { const item: monacoTypes.languages.InlineCompletion = {
insertText: { insertText: {
snippet: 'hello world\nhuman readable', snippet: response.data.data,
} }
}; };

@ -0,0 +1,7 @@
{
"/infer": {
"post": {
"data": "testing data"
}
}
}
Loading…
Cancel
Save