feat: change the default API base URL

This commit is contained in:
Li Xin 2025-04-22 11:03:53 +08:00
parent 5ee1632489
commit 6987ca67c3
2 changed files with 15 additions and 9 deletions

View File

@ -22,7 +22,7 @@ export function chatStream(
return chatStreamMock(userMessage, params, options); return chatStreamMock(userMessage, params, options);
} }
return fetchStream<ChatEvent>( return fetchStream<ChatEvent>(
(env.NEXT_PUBLIC_API_URL ?? "/api") + "/chat/stream", (env.NEXT_PUBLIC_API_URL ?? "http://localhost:8000/api") + "/chat/stream",
{ {
body: JSON.stringify({ body: JSON.stringify({
messages: [{ role: "user", content: userMessage }], messages: [{ role: "user", content: userMessage }],
@ -56,7 +56,7 @@ async function* chatStreamMock(
const res = await fetch(mockFile, { const res = await fetch(mockFile, {
signal: options.abortSignal, signal: options.abortSignal,
}); });
await sleep(800); await sleep(500);
const text = await res.text(); const text = await res.text();
const chunks = text.split("\n\n"); const chunks = text.split("\n\n");
for (const chunk of chunks) { for (const chunk of chunks) {
@ -66,7 +66,7 @@ async function* chatStreamMock(
if (event === "message_chunk") { if (event === "message_chunk") {
await sleep(100); await sleep(100);
} else if (event === "tool_call_result") { } else if (event === "tool_call_result") {
await sleep(4000); await sleep(2000);
} }
try { try {
yield { yield {

View File

@ -1,14 +1,20 @@
// Copyright (c) 2025 Bytedance Ltd. and/or its affiliates // Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
import { env } from "~/env";
export async function generatePodcast(content: string) { export async function generatePodcast(content: string) {
const response = await fetch("/api/podcast/generate", { const response = await fetch(
method: "post", (env.NEXT_PUBLIC_API_URL ?? "http://localhost:8000/api") +
headers: { "/podcast/generate",
"Content-Type": "application/json", {
method: "post",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ content }),
}, },
body: JSON.stringify({ content }), );
});
if (!response.ok) { if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`); throw new Error(`HTTP error! status: ${response.status}`);
} }