Files
zhimingge/app/actions/bazi.ts
T
dekun 0f3bc2c50a Fix AI stream by returning stream.value directly from Server Actions.
createStreamableValue must be created and returned in the action itself; wrapping in { data } or a helper return caused production RSC serialization errors.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-10 22:24:57 +08:00

35 lines
698 B
TypeScript

"use server";
import { createStreamableValue } from "ai/rsc";
import { pumpAIStream } from "@/lib/ai/stream";
import {
calculateBazi,
formatBaziForPrompt,
type BaziInput,
} from "@/lib/calc/bazi";
import { BAZI_SYSTEM_PROMPT } from "@/lib/prompts";
export async function getBaziAnswer(
input: BaziInput,
question: string,
birthPlaceName: string,
) {
const chart = calculateBazi(input);
const chartText = formatBaziForPrompt(chart);
const stream = createStreamableValue<string>();
pumpAIStream(
stream,
BAZI_SYSTEM_PROMPT,
`【出生时空】
出生地:${birthPlaceName}
【排盘信息】
${chartText}
【问事】
${question}`,
);
return stream.value;
}