Skip to content

fix(chatbot): Gemini 모델 fallback 로직 적용 - #130

Merged
evenif99 merged 1 commit into
devfrom
fix/chatbot-model-fallback
Jun 23, 2026
Merged

fix(chatbot): Gemini 모델 fallback 로직 적용#130
evenif99 merged 1 commit into
devfrom
fix/chatbot-model-fallback

Conversation

@evenif99

@evenif99 evenif99 commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • 챗봇에 Gemini 모델 fallback 로직 적용 (fix: Gemini 모델 fallback 및 타임아웃 조정 #129 패턴과 동일)
  • 단일 모델 재시도 → 멀티 모델 fallback으로 변경 (gemini-2.0-flash-litegemini-2.5-flashgemini-1.5-flash)
  • 503/404/429 에러 발생 시 자동으로 다음 모델로 전환

Test plan

  • 챗봇 정상 응답 확인
  • Gemini 모델 장애 시 다음 모델로 fallback되는지 로그 확인
  • 타임아웃 시 ChatbotTimeoutError 정상 발생 확인

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • 챗봇의 서비스 장애 발생 시 자동으로 대체 모델로 전환하도록 개선했습니다. 이를 통해 503, 404, 429 등의 오류 상황에서 더욱 안정적인 사용자 경험을 제공합니다.

fix(chatbot): Apply Gemini model fallback logic

Replace single-model retry with multi-model fallback matching the
pattern used in moderation and judgment. On 503/404/429 errors the
chatbot now cycles through gemini-2.0-flash-lite, gemini-2.5-flash,
and gemini-1.5-flash before giving up.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@
@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
talky-owl Ready Ready Preview, Comment Jun 23, 2026 7:20am

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: f14a2615-f70a-436b-ad85-d5b87d8503c7

📥 Commits

Reviewing files that changed from the base of the PR and between 85f0eda and 2315792.

📒 Files selected for processing (1)
  • src/lib/ai/chatbot.ts

📝 Walkthrough

Walkthrough

chatbot.ts에서 단일 Gemini 모델 상수(MODEL_NAME)와 재시도 파라미터(MAX_RETRIES, RETRY_DELAY_MS)를 MODEL_FALLBACKS 배열로 교체하고, 에러 메시지 패턴 기반의 isFallbackable() 헬퍼를 추가하며, getChatbotResponse 내부의 재시도 루프를 모델 순회 방식의 폴백 라우팅으로 재구성.

Changes

Gemini 폴백 라우팅 도입

Layer / File(s) Summary
폴백 모델 설정 및 에러 분류기
src/lib/ai/chatbot.ts
MODEL_NAME, MAX_RETRIES, RETRY_DELAY_MS 상수를 MODEL_FALLBACKS 배열로 대체하고, 503/404/429 등 에러 메시지 패턴을 검사해 폴백 가능 여부를 반환하는 isFallbackable() 함수를 추가.
getChatbotResponse 폴백 루프 재구성
src/lib/ai/chatbot.ts
chatHistory를 시스템 프롬프트 주입 및 이전 대화 매핑으로 구성하고, 기존 단일 모델 sleep 기반 재시도 루프를 for (const modelName of MODEL_FALLBACKS) 순회로 교체. ChatbotTimeoutError는 즉시 rethrow, isFallbackable 에러는 경고 로그 후 다음 모델 진행, 그 외는 루프 탈출 후 ChatbotGeminiError throw.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • I5-Project/TALKY-OWL#125: chatbot.ts의 Gemini 요청/에러 처리 로직을 직접 수정하는 PR로, 이번 PR이 대체하는 단일 모델 재시도 방식이 해당 PR에 포함되어 있음.
  • I5-Project/TALKY-OWL#129: 동일하게 Gemini 의존 AI 함수에 isFallbackable 스타일의 에러 분류 및 다중 모델 폴백 리스트를 적용하는 PR로, 이번 PR의 chatbot.ts 폴백 라우팅과 직접 연관됨.

Poem

🐇 한 모델이 지치면, 다음 모델이 달리고,
503이 와도 걱정 없이 나아가네.
isFallbackable? 그래, 계속 가자!
MODEL_FALLBACKS 배열 따라 폴짝폴짝~
🦉 탈키 올빼미도 오늘은 끄덕끄덕. 🌙

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/chatbot-model-fallback

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed due to a network error.


Comment @coderabbitai help to get the list of available commands.

@evenif99
evenif99 merged commit 0267a4a into dev Jun 23, 2026
2 of 3 checks passed
@evenif99
evenif99 deleted the fix/chatbot-model-fallback branch June 23, 2026 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant