feat: add conversation request-response
This commit is contained in:
18
frontend/src/utils/streaming-fetch.ts
Normal file
18
frontend/src/utils/streaming-fetch.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
async function* streamingFetch(fetchcall: () => Promise<Response>) {
|
||||
const response = await fetchcall();
|
||||
// Attach Reader
|
||||
if (!response || !response.body) {
|
||||
throw new Error("Empty response");
|
||||
}
|
||||
const reader = response.body.getReader();
|
||||
while (true) {
|
||||
// wait for next encoded chunk
|
||||
const { done, value } = await reader.read();
|
||||
// check if stream is done
|
||||
if (done) break;
|
||||
// Decodes data chunk and yields it
|
||||
yield new TextDecoder().decode(value);
|
||||
}
|
||||
}
|
||||
|
||||
export { streamingFetch };
|
||||
19
frontend/src/utils/tailwind.ts
Normal file
19
frontend/src/utils/tailwind.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
/* A nice to have VScode autocompletion feature
|
||||
|
||||
Make sure you have the Tailwind CSS IntelliSense extension installed in VSCode
|
||||
https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss
|
||||
|
||||
Open the settings (json) file via CMD + SHIFT + P (macOS) or CTRL + SHIFT + P (Windows)
|
||||
Add the below entry to the json file
|
||||
{
|
||||
...
|
||||
"tailwindCSS.experimental.classRegex": ["tw`([^`]*)"],
|
||||
}
|
||||
|
||||
Allows you to have tailwind auto complete while typing outside of the className attribute
|
||||
By using the prefix tw`YOUR_CLASS_NAME_HERE`
|
||||
|
||||
Without the extension and settings adjustment, it'll still be interpreted as a string literal (backward compatible)
|
||||
*/
|
||||
export const tw = (strings: TemplateStringsArray, ...substitution: unknown[]) =>
|
||||
String.raw({ raw: strings }, ...substitution);
|
||||
Reference in New Issue
Block a user