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

@@ -45,10 +45,12 @@ class MemoirImagePromptingTest(unittest.TestCase):
liblib_template_uuid="tpl-uuid",
)
llm = Mock()
llm.invoke.return_value.content = (
bound_llm = Mock()
bound_llm.invoke.return_value.content = (
'{"prompt":"A grandmother in a quiet courtyard, summer cicadas, soft watercolor",'
'"style":"watercolor","size":"1024x1024"}'
)
llm.bind.return_value = bound_llm
service = MemoirImagePromptService(llm=llm, settings=settings)
result = service.build_prompt(
@@ -74,13 +76,15 @@ class MemoirImagePromptingTest(unittest.TestCase):
liblib_template_uuid="tpl-uuid",
)
llm = Mock()
llm.invoke.return_value.content = """```json
bound_llm = Mock()
bound_llm.invoke.return_value.content = """```json
{
"prompt": "A middle-aged teacher stands on the empty stage, realistic, cinematic lighting",
"style": "realistic",
"size": "1280x720"
}
```"""
llm.bind.return_value = bound_llm
service = MemoirImagePromptService(llm=llm, settings=settings)
result = service.build_prompt(
@@ -112,7 +116,9 @@ class MemoirImagePromptingTest(unittest.TestCase):
liblib_template_uuid="tpl-uuid",
)
llm = Mock()
llm.invoke.return_value.content = "not-json"
bound_llm = Mock()
bound_llm.invoke.return_value.content = "not-json"
llm.bind.return_value = bound_llm
service = MemoirImagePromptService(llm=llm, settings=settings)
result = service.build_prompt(