38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
from typing import Any
|
|
|
|
PROMPT_VERSION = "heaven-deterministic-v1"
|
|
|
|
|
|
def messages(mode: str, result: dict[str, Any]) -> list[dict[str, str]]:
|
|
instructions = {
|
|
"trend": "解释既有本卦、动爻、之卦、六爻量化依据和势值,不得另起卦或修改行情。",
|
|
"fortune": (
|
|
"解释既有五运六气三层气机、复合断语、个人派生影响、"
|
|
"生克断语与制衡动作,不得修改干支历法。"
|
|
),
|
|
"heart": "解释既有本卦、动爻、之卦和卦辞,帮助用户观察第一念,不得另起卦或作确定性预测。",
|
|
}
|
|
safe = _safe_result(mode, result)
|
|
return [
|
|
{
|
|
"role": "system",
|
|
"content": (
|
|
"你是传统文化观察的文字整理助手。"
|
|
+ instructions[mode]
|
|
+ "明确说明内容仅供传统文化与娱乐化观察,不构成预测或投资建议。"
|
|
),
|
|
},
|
|
{"role": "user", "content": json.dumps(safe, ensure_ascii=False, separators=(",", ":"))},
|
|
]
|
|
|
|
|
|
def _safe_result(mode: str, result: dict[str, Any]) -> dict[str, Any]:
|
|
if mode != "fortune":
|
|
return result
|
|
return {key: value for key, value in result.items() if key != "personal"} | {
|
|
"personal_synthesis": (result.get("personal") or {}).get("tone")
|
|
}
|