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

View File

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