feat: 引入deepseek结构化输出

This commit is contained in:
yangshilin
2026-03-19 11:27:43 +08:00
parent f3629efec3
commit 4c75c6f4f4
10 changed files with 74 additions and 26 deletions

View File

@@ -57,7 +57,11 @@ class MemoirImagePromptService:
if self.llm:
raw_response = None
try:
response = self.llm.invoke(
json_llm = self.llm.bind(
model_kwargs={"response_format": {"type": "json_object"}},
max_tokens=512,
)
response = json_llm.invoke(
"Return JSON only with keys prompt, style, size. "
"Convert the memoir scene into an image-generation prompt.\n"
+ json.dumps(llm_input, ensure_ascii=False)
@@ -113,7 +117,11 @@ class MemoirImagePromptService:
if self.llm:
try:
response = self.llm.invoke(
json_llm = self.llm.bind(
model_kwargs={"response_format": {"type": "json_object"}},
max_tokens=512,
)
response = json_llm.invoke(
"Return JSON only with keys prompt, style, size. "
"Create an image-generation prompt for a memoir chapter COVER. "
"Emphasize: hero composition, evocative scene, chapter cover aesthetic.\n"