ai改写调用

This commit is contained in:
董宏凯 committed 2026-05-17 20:18:11 +08:00
1 parent a0a6227368
commit 05ff10df1b
4 files changed
+106 -15

No files matched your search

+3 -5
View File
@@ -1,7 +1,5 @@
import { apiFetch } from "@/core/api/fetch-client";
import { env } from "@/env";
const BASE = (env.NEXT_PUBLIC_BACKEND_BASE_URL as string | undefined) ?? "http://localhost:8001";
import { getBackendBaseURL } from "@/core/config";
export type RewriteAction = "polish" | "expand" | "shorten" | "tone";
export type RewriteTone =
@@ -12,7 +10,7 @@ export type RewriteTone =
| "expressive";
export interface RewriteRequest {
threadId: string;
threadId?: string | null;
selection: { from: number; to: number; text: string };
action: RewriteAction;
tone?: RewriteTone;
@@ -71,7 +69,7 @@ export async function* streamRewrite(
req: RewriteRequest,
signal?: AbortSignal,
): AsyncGenerator<RewriteStreamEvent> {
const res = await apiFetch(`${BASE}/api/writing/rewrite`, {
const res = await apiFetch(`${getBackendBaseURL()}/api/writing/rewrite`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(req),