사주 프롬프트 강화

This commit is contained in:
2026-03-11 07:46:21 +09:00
parent 95453212ec
commit de02d44762
4 changed files with 283 additions and 109 deletions

View File

@@ -50,7 +50,7 @@ const MODELS = ['gpt-4o', 'gpt-4o-mini'] as const;
export async function POST(request: Request) {
try {
const { saju, daeun, daeunList, gender } = await request.json();
const { saju, daeun, daeunList, gender, engineData } = await request.json();
// 종합 분석 수행
let analysis;
@@ -73,7 +73,7 @@ export async function POST(request: Request) {
apiKey: process.env.OPENAI_API_KEY,
});
const prompt = createSajuPrompt(saju, daeun, gender, analysis, daeunList || []);
const prompt = createSajuPrompt(saju, daeun, gender, analysis, daeunList || [], engineData);
// 모델 폴백: gpt-4o 실패 시 gpt-4o-mini로 재시도
let interpretation: string | null = null;

View File

@@ -20,6 +20,13 @@ interface SajuAISectionProps {
gender: string;
birthKey: BirthKey;
currentUrl: string;
// Python 엔진 데이터 (더 정밀한 절기 계산 결과)
engineData?: {
interactions?: any[];
shinsal?: any[];
gongmang?: any;
hiddenStems?: any[];
};
}
export default function SajuAISection({
@@ -31,6 +38,7 @@ export default function SajuAISection({
gender,
birthKey,
currentUrl,
engineData,
}: SajuAISectionProps) {
const [status, setStatus] = useState<'idle' | 'loading' | 'done' | 'error'>(
savedInterpretation ? 'done' : 'idle'
@@ -46,7 +54,13 @@ export default function SajuAISection({
fetch('/api/saju/analyze', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ saju: sajuData, daeun, daeunList, gender }),
body: JSON.stringify({
saju: sajuData,
daeun,
daeunList,
gender,
engineData, // Python 엔진 데이터 전달
}),
})
.then((r) => r.json())
.then((data) => {

View File

@@ -555,6 +555,12 @@ export default async function SajuResultPage({ searchParams }: PageProps) {
gender={gender}
birthKey={birthKey}
currentUrl={currentUrl}
engineData={engineResult ? {
interactions: engineResult.interactions,
shinsal: engineResult.shinsal,
gongmang: engineResult.gongmang,
hiddenStems: engineResult.hiddenStems,
} : undefined}
/>
);
})()}