이미지 크롤링 로직 변경 및 자막 이미지 매칭 보완
This commit is contained in:
1 parent
4d8462651a
commit
b8be2a355a
16 files changed
+212
-74
No files matched your search
@@ -97,11 +97,13 @@ def _extract_region_from_address(road_address: str | None, jibun_address: str |
|
||||
|
||||
|
||||
class _IndustryOutput(BaseModel):
|
||||
industry: Literal["stay", "restaurant", "cafe", "salon", "clinic", "fitness", "academy", "attraction"]
|
||||
industry: Literal[
|
||||
"stay", "restaurant", "cafe", "salon", "clinic", "fitness", "academy", "attraction", "general"
|
||||
]
|
||||
|
||||
|
||||
async def _resolve_industry(category: str, customer_name: str = "") -> str:
|
||||
"""업체를 통합 프롬프트의 8개 industry enum 중 하나로 AI 분류.
|
||||
"""업체를 통합 프롬프트의 9개 industry enum 중 하나로 AI 분류.
|
||||
|
||||
분류 근거는 카테고리를 우선 사용하고, 카테고리가 없으면 업체명으로 분류한다.
|
||||
근거가 둘 다 없으면 빈 문자열 반환. API 장애 시 예외 전파(하위 분석도 동일 API 의존).
|
||||
@@ -115,10 +117,12 @@ async def _resolve_industry(category: str, customer_name: str = "") -> str:
|
||||
chatgpt = ChatgptService()
|
||||
prompt = (
|
||||
f"{basis_label}: '{basis_value}'\n"
|
||||
"위 정보를 바탕으로 이 업체를 다음 8개 업종 중 가장 적합한 하나로 분류하세요: "
|
||||
"위 정보를 바탕으로 이 업체를 다음 업종 중 가장 적합한 하나로 분류하세요: "
|
||||
"stay(숙박/펜션/호텔), restaurant(음식점), cafe(카페/디저트), "
|
||||
"salon(미용실/네일/뷰티), clinic(병원/의원/치과), fitness(헬스/필라테스/요가), "
|
||||
"academy(학원/교습소), attraction(관광/체험/액티비티)."
|
||||
"academy(학원/교습소), attraction(관광/체험/액티비티). "
|
||||
"위 8개 중 어느 것에도 명확히 해당하지 않는 경우에만 general(기타/범용 업종)로 분류하세요. "
|
||||
"유사한 업종이 있으면 general 대신 그 업종을 우선 선택하세요."
|
||||
)
|
||||
result = await chatgpt._call_pydantic_output_chat_completion(
|
||||
prompt=prompt,
|
||||
@@ -312,7 +316,7 @@ async def _crawling_logic(
|
||||
[img["original"] for img in extra_photo_urls], industry
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"[crawling] Step 3 FAILED - 이미지 필터링 중 오류: {e}")
|
||||
# logger.error(f"[crawling] Step 3 FAILED - 이미지 필터링 중 오류: {e}")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_502_BAD_GATEWAY,
|
||||
detail="이미지 마케팅 적합성 필터링 중 오류가 발생했습니다.",
|
||||
@@ -337,11 +341,22 @@ async def _crawling_logic(
|
||||
try:
|
||||
# Step 4-1: ChatGPT 서비스 초기화 및 입력 데이터 구성
|
||||
chatgpt_service = ChatgptService()
|
||||
# 메뉴 전달은 잠정 보류 — 사이드 메뉴(볶음밥·냉면 등)가 분석에 과도한 영향을 주는
|
||||
# 문제로 프롬프트에서 {menu_info}를 제거함. 크롤링(scraper.menu_info)은 유지 중이므로
|
||||
# 주력/사이드 구분 방안이 정리되면 아래 주석을 되살려 재전달할 것.
|
||||
# menus = scraper.menu_info or []
|
||||
# menus = sorted(menus, key=lambda m: not m.get("recommend"))[:15]
|
||||
# menu_info = ", ".join(m["name"] for m in menus if m.get("name"))
|
||||
top_keywords = (scraper.voted_keyword_stats or [])[:5]
|
||||
input_marketing_data = {
|
||||
"customer_name": customer_name,
|
||||
"region": region,
|
||||
"detail_region_info": road_address or "",
|
||||
"industry": industry, # 통합 프롬프트 내부 분기용 업종 enum
|
||||
"category": category, # 네이버 지도 원본 카테고리 텍스트
|
||||
"facility_info": scraper.facility_info or "",
|
||||
"voted_keywords": ", ".join(kw["displayName"] for kw in top_keywords),
|
||||
# "menu_info": menu_info, # 실제 판매 품목 (셀링포인트 구체화용)
|
||||
}
|
||||
|
||||
# Step 4-2: GPT API 호출 → 구조화된 마케팅 분석 결과 반환
|
||||
@@ -456,6 +471,7 @@ async def manual_marketing(
|
||||
"region": region,
|
||||
"detail_region_info": request_body.address,
|
||||
"industry": industry, # 통합 프롬프트 내부 분기용 업종 enum
|
||||
"category": request_body.category, # 사용자 입력 원본 카테고리 텍스트 (세부 묘사 참고용)
|
||||
}
|
||||
marketing_analysis = await chatgpt_service.generate_structured_output(
|
||||
marketing_prompt, input_marketing_data
|
||||
@@ -658,7 +674,7 @@ async def upload_images_blob(
|
||||
),
|
||||
industry: str = Form(
|
||||
default="",
|
||||
description="업종 분류 (stay|restaurant|cafe|salon|clinic|fitness|academy|attraction). 크롤링 응답의 industry 값을 그대로 전달",
|
||||
description="업종 분류 (stay|restaurant|cafe|salon|clinic|fitness|academy|attraction|general). 크롤링 응답의 industry 값을 그대로 전달",
|
||||
),
|
||||
current_user: User = Depends(get_current_user),
|
||||
) -> ImageUploadResponse:
|
||||
|
||||
+1
-1
@@ -118,7 +118,7 @@ class Project(Base):
|
||||
String(50),
|
||||
nullable=False,
|
||||
default="",
|
||||
comment="업종 분류 (stay|restaurant|cafe|salon|clinic|fitness|academy|attraction)",
|
||||
comment="업종 분류 (stay|restaurant|cafe|salon|clinic|fitness|academy|attraction|general)",
|
||||
)
|
||||
|
||||
language: Mapped[str] = mapped_column(
|
||||
|
||||
@@ -78,7 +78,7 @@ class ProcessedInfo(BaseModel):
|
||||
customer_name: str = Field(..., description="고객명/가게명 (base_info.name)")
|
||||
region: str = Field(..., description="지역명 (roadAddress에서 추출한 시 이름)")
|
||||
detail_region_info: str = Field(..., description="상세 지역 정보 (roadAddress)")
|
||||
industry: str = Field(default="", description="업종 분류 (stay|restaurant|cafe|salon|clinic|fitness|academy|attraction)")
|
||||
industry: str = Field(default="", description="업종 분류 (stay|restaurant|cafe|salon|clinic|fitness|academy|attraction|general)")
|
||||
|
||||
|
||||
# class MarketingAnalysisDetail(BaseModel):
|
||||
@@ -249,7 +249,7 @@ class CrawlingResponse(BaseModel):
|
||||
None, description="마케팅 분석 결과 . 실패 시 null"
|
||||
)
|
||||
m_id : int = Field(..., description="마케팅 분석 결과 ID")
|
||||
industry: str = Field(default="", description="업종 분류 (stay|restaurant|cafe|salon|clinic|fitness|academy|attraction)")
|
||||
industry: str = Field(default="", description="업종 분류 (stay|restaurant|cafe|salon|clinic|fitness|academy|attraction|general)")
|
||||
|
||||
|
||||
class ManualMarketingRequest(BaseModel):
|
||||
|
||||
Reference in new issue
Block a user