[feat] solution/backend: 수집 뒤 콘텐츠 채울 때 캐치프레이즈·순환 문구 생성 — 숙박만
가게별 첫 화면 문구를 만드는 곳이 없어 모든 숙박이 공통 문구 10개를 돌려 썼다. - COPY 잡에 catchphrase 단계(prepare→generate→save→catchphrase→faq_fill), 숙박이 아니면 건너뜀 - prompts/catchphrase.py·gemini_text.generate_catchphrases: 캐치프레이즈 1 + 일반 20·계절 3×4·월 12·날씨 2×4. 문구마다 길이·상호명·ground_check(근거 없는 시설·수치) 검사 - fact tagline·catchphrases(lodging 스키마, allow_llm). 순환 문구는 사장님이 줄 단위로 고치게 글로 저장 (catchphrase_text: `봄 | ` · `9월 | ` · `비 | ` 머리) - site_payload: narrative.tagline·catchphrases 로 넘기고 이용정보 표(facts)에서는 뺀다 - 빌더 생성 화면 단계 문구, DATA_MODEL·GENERATION_FLOW 테스트 6건 추가. 관련 20개 파일 386 passed · 실패 102건은 main 과 목록이 같다(기존 실패) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a0b14dfca1
commit
ef0c44c5f2
13 files changed
+377
-8
No files matched your search
@@ -21,7 +21,7 @@ from crud.fact_crud import FactCRUD
|
||||
from crud.faq_crud import FaqCRUD
|
||||
from crud.place_crud import PlaceCRUD
|
||||
from router.v1.fact.protocol import Req_UpsertFact
|
||||
from services import faq_fill, place_research
|
||||
from services import catchphrase_text, faq_fill, place_research
|
||||
from services.external import gemini_text
|
||||
from services.llm import provider
|
||||
from services.fact_service import FactService
|
||||
@@ -248,6 +248,47 @@ async def save_copy(inputs: CopyInputs, copy: gemini_text.GeneratedCopy | None)
|
||||
return stat
|
||||
|
||||
|
||||
async def generate_catchphrases(inputs: CopyInputs) -> gemini_text.GeneratedCatchphrases:
|
||||
active_provider = provider.active()
|
||||
model = (
|
||||
external_api_config.openai_text_model if active_provider.__name__.endswith("openai")
|
||||
else external_api_config.gemini_text_model
|
||||
)
|
||||
try:
|
||||
return await gemini_text.generate_catchphrases(
|
||||
inputs.place.name, inputs.grounded, records=inputs.records or None, model=model,
|
||||
)
|
||||
except gemini_text.GeminiNotConfigured as ex:
|
||||
raise CopyAborted(str(ex)) from ex
|
||||
|
||||
|
||||
async def save_catchphrases(inputs: CopyInputs, generated: gemini_text.GeneratedCatchphrases) -> dict:
|
||||
place_id = str(inputs.place.place_id)
|
||||
stat = {"tagline": False, "catchphrases": 0, "rejected": [list(r) for r in generated.rejected][:20]}
|
||||
actor = UserInfo(user_id=str(inputs.place.owner_user_id), id="generator", role=1)
|
||||
service = FactService(_fact_crud, _place_crud)
|
||||
values = (("tagline", generated.tagline), ("catchphrases", catchphrase_text.encode(generated.items)))
|
||||
for key, value in values:
|
||||
spec = inputs.schema.get(key)
|
||||
if not (value or "").strip() or not (spec and spec.allow_llm):
|
||||
continue
|
||||
res = await service.upsert_fact(
|
||||
actor, place_id,
|
||||
Req_UpsertFact(
|
||||
key=key, value=value.strip(),
|
||||
source_type=SourceType.LLM, source_url=f"llm:{generated.source or external_api_config.gemini_text_model}",
|
||||
),
|
||||
)
|
||||
if not res.result.success:
|
||||
stat["rejected"].append([key, res.result.desc])
|
||||
elif key == "tagline":
|
||||
stat["tagline"] = True
|
||||
else:
|
||||
stat["catchphrases"] = len(generated.items)
|
||||
LOG.i(f"[copy] place={place_id} 캐치프레이즈 {'O' if stat['tagline'] else 'X'} · 순환 {stat['catchphrases']}개")
|
||||
return stat
|
||||
|
||||
|
||||
async def fill_faqs(pid: uuid.UUID, catalog: FaqCatalog, known_fact_keys: set[str], phone: str | None) -> int:
|
||||
"""노출 중인 FAQ 가 목표 수에 모자란 만큼 문의 안내 문항을 넣는다."""
|
||||
l_err, rows = await DB_SESSION_MNG.execute_lambda(
|
||||
|
||||
Reference in new issue
Block a user