feat: add export to .md button

This commit is contained in:
Yifei Zhang
2023-03-15 17:24:03 +00:00
parent 64e331a3e3
commit bab470d000
11 changed files with 181 additions and 18 deletions

View File

@@ -1,6 +1,8 @@
import type { ChatRequest, ChatReponse } from "./api/chat/typing";
import { Message } from "./store";
const TIME_OUT_MS = 30000
const makeRequestParam = (
messages: Message[],
options?: {
@@ -52,7 +54,7 @@ export async function requestChatStream(
});
const controller = new AbortController();
const reqTimeoutId = setTimeout(() => controller.abort(), 10000);
const reqTimeoutId = setTimeout(() => controller.abort(), TIME_OUT_MS);
try {
const res = await fetch("/api/chat-stream", {
@@ -78,7 +80,7 @@ export async function requestChatStream(
while (true) {
// handle time out, will stop if no response in 10 secs
const resTimeoutId = setTimeout(() => finish(), 10000);
const resTimeoutId = setTimeout(() => finish(), TIME_OUT_MS);
const content = await reader?.read();
clearTimeout(resTimeoutId);
const text = decoder.decode(content?.value);