Skip to content

[HSC-398] v1.1.0#60

Merged
tkv00 merged 2 commits into
mainfrom
release/HSC-398
Mar 19, 2026
Merged

[HSC-398] v1.1.0#60
tkv00 merged 2 commits into
mainfrom
release/HSC-398

Conversation

@tkv00

@tkv00 tkv00 commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

📝작업 내용


👀변경 사항


🎫 Jira Ticket

  • Jira Ticket: HSC-398

#️⃣관련 이슈

@tkv00 tkv00 added 🏷️ release 릴리즈 준비/버전 태깅/릴리즈 노트/릴리즈 브랜치 작업 ☁️ area: INFRA 인프라/운영/배포 영역 release:minor 버전 minor bump: X.Y.0 🔥 priority: P0 즉시 처리 필요(서비스/데모 블로커) Infra Team deploy:intelligence-server labels Mar 19, 2026
@github-actions github-actions Bot added the ⚠️ priority: P1 빠른 처리 필요(주요 기능 영향) label Mar 19, 2026
@github-actions github-actions Bot changed the title v1.1.0 [HSC-398] v1.1.0 Mar 19, 2026
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 애플리케이션의 유연성과 추천 시스템의 견고성을 향상시키는 데 중점을 둡니다. 특정 외부 라이브러리(pgvector, aiokafka)가 설치되지 않은 환경에서도 서비스가 정상적으로 작동하도록 조건부 임포트 로직을 추가했습니다. 또한, 추천 후보 상품을 검색하는 과정에서 특정 상품 타입으로의 쏠림 현상을 완화하고 다양한 상품을 추천할 수 있도록 검색 전략을 개선했습니다.

Highlights

  • 조건부 의존성 임포트: pgvector.asyncpgaiokafka 모듈의 임포트에 try-except 블록을 추가하여, 해당 의존성이 없는 환경에서도 애플리케이션이 실행될 수 있도록 유연성을 높였습니다.
  • 추천 후보 풀 다양성 개선: product_type별로 벡터 검색을 수행하는 새로운 SQL 쿼리(SEARCH_SIMILAR_BY_TYPE_SQL)와 관련 상수가 도입되어, 추천 후보 풀의 편향을 완화하고 다양한 상품을 포함하도록 개선되었습니다.
  • 추천 로직 변경: 메인 추천 로직(_run_recommendation_with_context)과 폴백 추천 로직(_run_fallback_recommendation)이 수정되어, 먼저 타입별 검색으로 후보를 확보한 후 부족한 부분을 전체 검색으로 채우는 방식으로 변경되었습니다.
  • Kafka 발행 안전성 강화: Kafka 메시지 발행 전에 AIOKafkaProducer 객체의 존재 여부를 확인하는 로직이 추가되어, Kafka 의존성이 없는 환경에서도 안전하게 발행을 스킵하도록 했습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

이번 PR에서는 pgvectoraiokafka를 선택적 의존성으로 변경하여 유연성을 높이고, 추천 로직에서 상품 다양성을 확보하기 위한 타입별 후보 검색을 추가하셨네요. 특히 폴백 추천 로직에도 동일한 다양성 확보 로직을 적용하여 일관성을 유지한 점이 좋습니다. 다만, 이 과정에서 _run_recommendation_with_context_run_fallback_recommendation 함수에 중복되는 코드가 발생했습니다. 코드 유지보수성을 높이기 위해 이 중복 코드를 별도 함수로 추출하는 것을 제안합니다. 자세한 내용은 개별 코멘트를 참고해주세요.

Comment on lines +684 to +735
# 2-1) 타입별 검색으로 후보 풀 분산(최소 1개/타입 유도)
seen: set[int] = set()
product_ids: list[int] = []
for ptype in MAIN_PRODUCT_TYPES:
r = await session.execute(
SEARCH_SIMILAR_BY_TYPE_SQL,
{
"query_vec": query_vec,
"exclude_ids": exclude_ids,
"k": RETRIEVAL_CANDIDATES_K,
"ptype": ptype,
"k": RETRIEVAL_PER_TYPE_K,
},
)
rows = result.fetchall()
product_ids = [r[0] for r in rows]
for row in r.fetchall():
pid = row[0]
if pid in seen:
continue
product_ids.append(pid)
seen.add(pid)

# 2-2) 부족분은 기존 전체 검색(가중치 boost 포함 가능)으로 보충
if len(product_ids) < RETRIEVAL_CANDIDATES_K:
if use_type_boost:
result = await session.execute(
SEARCH_SIMILAR_WITH_TYPE_BOOST_SQL,
{
"query_vec": query_vec,
"exclude_ids": exclude_ids,
"k": RETRIEVAL_CANDIDATES_K,
"boost_type1": boost_type1,
"boost1": boost1,
"boost_type2": boost_type2,
"boost2": boost2,
},
)
else:
result = await session.execute(
SEARCH_SIMILAR_SQL,
{
"query_vec": query_vec,
"exclude_ids": exclude_ids,
"k": RETRIEVAL_CANDIDATES_K,
},
)
for row in result.fetchall():
pid = row[0]
if pid in seen:
continue
product_ids.append(pid)
seen.add(pid)
if len(product_ids) >= RETRIEVAL_CANDIDATES_K:
break

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

이 후보 상품 ID를 가져오는 로직은 _run_fallback_recommendation 함수 내의 1078-1114행에 있는 로직과 매우 유사합니다. 코드 중복은 향후 버그 발생 가능성을 높이고 유지보수를 어렵게 만듭니다.

이 중복된 로직을 별도의 헬퍼 함수로 추출하여 두 곳에서 모두 재사용하는 것을 고려해 보세요. 예를 들어, 다음과 같은 헬퍼 함수를 만들 수 있습니다.

async def _retrieve_candidate_products(
    session: AsyncSession,
    query_vec: list[float],
    exclude_ids: list[int],
    use_type_boost: bool = False,
    boost_type1: str = "",
    boost1: float = 0.0,
    boost_type2: str = "",
    boost2: float = 0.0,
) -> list[int]:
    # ... 중복 로직 구현 ...
    return product_ids

이렇게 하면 _run_recommendation_with_context_run_fallback_recommendation 함수가 더 간결해지고, 추천 후보를 가져오는 로직을 한 곳에서 관리할 수 있게 됩니다.

@tkv00 tkv00 merged commit 098a6b1 into main Mar 19, 2026
7 checks passed
@tkv00 tkv00 deleted the release/HSC-398 branch March 20, 2026 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

☁️ area: INFRA 인프라/운영/배포 영역 deploy:intelligence-server Infra Team 🔥 priority: P0 즉시 처리 필요(서비스/데모 블로커) ⚠️ priority: P1 빠른 처리 필요(주요 기능 영향) release:minor 버전 minor bump: X.Y.0 🏷️ release 릴리즈 준비/버전 태깅/릴리즈 노트/릴리즈 브랜치 작업

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants