fix/various fixes

This commit is contained in:
Kevin
2026-03-20 15:15:35 +08:00
parent 7f57f96c25
commit 7317bf10cd
112 changed files with 3790 additions and 2242 deletions

View File

@@ -1,8 +1,10 @@
import json
from app.core.logging import get_logger
import re
from typing import Any, Optional
from app.core.langchain_llm import bind_json_object_mode
from app.core.logging import get_logger
from .json_payload import extract_json_payload
from .settings import MemoirImageSettings
@@ -59,10 +61,7 @@ class MemoirImagePromptService:
if self.llm:
raw_response = None
try:
json_llm = self.llm.bind(
model_kwargs={"response_format": {"type": "json_object"}},
max_tokens=512,
)
json_llm = bind_json_object_mode(self.llm, 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"
@@ -123,10 +122,7 @@ class MemoirImagePromptService:
if self.llm:
try:
json_llm = self.llm.bind(
model_kwargs={"response_format": {"type": "json_object"}},
max_tokens=512,
)
json_llm = bind_json_object_mode(self.llm, 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. "